Tutorial
On this page
Here we are! 🚀
Your project is configured and ready for its first tests.
#Namespaces
We'll add two namespaces to our composer.json file:
- Shop: custom test scenarios and elements
- Tests: test suites
Copied!
1"autoload": { 2 "psr-4": { 3 "Shop\\": "src/" 4 } 5}, 6"autoload-dev": { 7 "psr-4": { 8 "Tests\\": "Tests/" 9 }10},
#Create a suite
Inside the Tests folder, create a file nammed as you want. For exemple : First.php
Copied!
1namespace Tests; 2 3use PrestaFlow\Library\Tests\TestsSuite; 4 5class First extends TestsSuite 6{ 7 public function init() 8 { 9 $this10 ->describe('PrestaFlow: my first scenario')11 ;12 }13}
If you run the prestaflow:default script, you will see your first suite in action !
#Add steps
Copied!
1namespace Tests; 2 3use PrestaFlow\Library\Tests\TestsSuite; 4 5class First extends TestsSuite 6{ 7 public function init() 8 { 9 $this10 ->describe('PrestaFlow: my first scenario')11 ->todo('To be done', function () {12 })13 ->skip('will be skipped', function () {14 })15 ;16 }17}
#Create a scenario
In the src/Tests/Scenarios folder, add a file named DoNothing.php.
In it, add your first scenario as follows:
Copied!
1namespace Shop\Tests\Scenarios; 2 3use PrestaFlow\Library\Scenarios\Scenario; 4 5class DoNothing extends Scenario 6{ 7 public function steps($testSuite) 8 { 9 $testSuite10 ->todo('will do nothing (again)', function () {11 })12 ;13 14 return $testSuite;15 }16}
You can now use it into your suite.
Copied!
1namespace Tests; 2 3use PrestaFlow\Library\Tests\TestsSuite; 4use Shop\Tests\Scenarios\DoNothing; 5 6class First extends TestsSuite 7{ 8 public function init() 9 {10 $this11 ->describe('PrestaFlow: my first scenario')12 ->scenario(DoNothing::class)13 ;14 }15}