1. Go to this page and download the library: Download stateforge/scenario-core library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stateforge / scenario-core example snippets
use Stateforge\Scenario\Core\Attribute\AsScenario;
use Stateforge\Scenario\Core\Contract\ScenarioInterface;
#[AsScenario('my-scenario')]
final class MyScenario implements ScenarioInterface
{
public function up(): void
{
// load some data
}
public function down(): void
{
// remove loaded data
}
}
use Stateforge\Scenario\Core\Attribute\ApplyScenario;
#[ApplyScenario('my-scenario')]
final class MyTest extends TestCase
{
#[ApplyScenario('my-second-scenario')]
public function testSomethingImportant(): void
{
// scenario has already been applied, data can be tested
}
}
#[ApplyScenario(UserExists::class, [ 'id' => 42 ])]
#[ApplyScenario(UserHasSubscription::class, [ 'id' => 42 ])]
final class SubscriptionTest extends TestCase
{
public function testUserHasAccess(): void
{
// system is already in the desired state
$this->assertTrue($this->service->userHasAccess(42));
}
}
use Stateforge\Scenario\Core\Attribute\RefreshDatabase;
#[RefreshDatabase]
final class MyFreshDatabaseTest extends TestCase
{
}
bash
php vendor/bin/scenario
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.