Download the PHP package parf/spartan-test without Composer
On this page you can find all versions of the php package parf/spartan-test. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package spartan-test
Spartan Test
PHP 8+ unit and web tests that read like PHP and run like scripts.
Spartan Test is a small testing framework for developers who want tests to stay close
to the code they exercise. A test is an ordinary PHP expression followed by its
expected result, all inside a simple executable .stest file.
Run it directly:
That is a complete test.
✦ What Makes It Distinctive
- ▶ Tests are executable files. Run one file directly, pass several files to
stest, or discover a complete suite withstest-all. - ↻ Expected results live beside the code. If a result is missing, Spartan Test generates and saves it. Results stay readable, reviewable, and easy to track in Git.
- ◆ PHP remains visible. Use normal expressions, application objects, closures, functions, exceptions, and setup code without wrapping every check in a test class.
- ◎ Unit and web tests use the same format. Test return values, services, pages,
redirects, cookies, APIs, headers, and response content from
.stestfiles. - ⚡ Repository-scale execution is built in.
stest-allprovides discovery, file-level tags, selection filters, and high-I/O parallel execution. - ✓ CI behavior is predictable. Failures return nonzero, intentional skips remain successful, and infrastructure errors are not reported as passing tests.
How A Test File Works
Each entry has a simple role:
Spartan Test captures:
- return values;
- thrown exceptions and errors;
- stdout from
echoandprint; - PHP notices and warnings;
- web responses and request state.
When an expected result is absent, the first run adds its canonical PHP representation
to the file. A later value change fails normally. Use --generate when updating stored
results is intentional.
You can also use focused matchers when an exact value is unnecessary:
Setup code supports normal PHP syntax. Multi-line PHP works as expected; only the first
physical line needs the ; setup prefix.
◎ Unit And Web Testing
Unit-style tests call PHP directly:
Web tests keep cookies and referrers between requests and can check pages, redirects, JSON APIs, headers, XPath results, and response content:
See Web Tests for the request syntax and runnable examples.
Running Tests
Use stest-all for a repository:
By default, suite discovery includes executable and non-executable .stest files, while
skipping hidden paths, vendor, and node_modules. Install
fd for faster discovery in large repositories;
systems without it automatically use find. GNU Parallel powers suite execution.
Run stest --help or stest-all --help for all CLI options.
◆ Application Integration
Spartan Test searches the test directory and its parents for configuration and common bootstrap files:
bootstrap/autoload.phpvendor/autoload.phpinit.php
Use --init=/path/to/bootstrap.php for a one-off override, or configure your project in
stest-config.json / stest-config.local.json.
Installation
Requirements:
- PHP 8.0 or newer;
- GNU Parallel for
stest-all; fdis optional and recommended for large repositories.
Composer
Git
Learn More
- Complete syntax
- Web testing
- Configuration
- Examples
- Changelog and new features
Start with the first test, then explore advanced result matching.