#[WinterBootTest] stereotype that registers a class as a first-class bean during startup, plus a small zero-dependency test runner (srcTests/run.php) that the framework itself uses. Together they let you write integration tests that exercise your services against a real DI container without pulling in PHPUnit.
The #[WinterBootTest] attribute
Apply #[WinterBootTest] to any class. The container treats it the same way it treats #[Service] or #[Component]: it registers the class as a bean, resolves its dependencies via #[Autowired], and runs its #[PostConstruct] hooks.
srcTests/UserServiceTest.php
dev\winterframework\stereotype\test\WinterBootTest.
The bundled test runner
Winter Boot’s own tests use a plain PHP runner with no external dependencies. You can lift the same pattern into your project.Run
From the repository root:0 when all tests pass and 1 otherwise.
Layout
run.phpdiscovers*Test.phpfiles in the directory and runs every publictest*method, printingokorFAILper test plus a pass/fail summary.Support/TestCase.phpis a base class withassertSame,assertTrue,assertFalse,assertNull, andassertThrows. Assertion failures throwAssertionFailed.Support/StubPropertySource.phpis an in-memoryPropertySourcefor tests. Choose the dataset via thedatasetkey of thepropertySourcesentry in the fixture yml, and register rows inStubPropertySource::$datasetsbefore building the context.fixtures/<name>/application.ymlis a config directory you pass tonew WinterPropertyContext(['.../fixtures/<name>']).
Add a test
1
Create the test file
Create
SomethingTest.php in srcTests/, namespace winterBootTests, class SomethingTest extends \winterBootTests\Support\TestCase.2
Add public test methods
Add public methods starting with
test. No registration is needed; run.php picks the file up automatically.Related pages
- Dependency injection explains how the container resolves
#[Autowired]dependencies in test beans. - Application lifecycle covers container boot order that also applies to test contexts.