This example demonstrates how to use Verteller with a custom project structure.
example/
├── bin/
│ └── sync-stories.php # Custom runner with namespace resolver
├── src/
│ └── Auth/
│ └── Stories/
│ └── Login.story # Story file with scenarios
├── tests/
│ └── Story/
│ └── Auth/
│ └── LoginTest.php # Generated test file
└── README.md
-
Story file (
src/Auth/Stories/Login.story) contains three scenarios:- A simple scenario for successful login
- A simple scenario for failed login
- A scenario outline with examples for validation errors
-
Custom runner (
bin/sync-stories.php) defines how paths map to namespaces:src/Auth/Stories/Login.story→Tests\Story\Auth\LoginTest
-
Generated test (
tests/Story/Auth/LoginTest.php) contains:- Test methods for each scenario
#[CoversStory]attributes linking tests to scenarios- A data provider for the scenario outline
From the verteller root directory:
# Preview what would be synced
php example/bin/sync-stories.php --dry-run
# Actually sync (regenerate the test file)
php example/bin/sync-stories.php
# Validate mode (for CI)
php example/bin/sync-stories.php --validate- Copy
bin/sync-stories.phpto your project - Modify the namespace resolver to match your structure
- Update the
$basePathif needed - Run it!