@@ -6,8 +6,8 @@ This library is here to help you with Integration and [Functional Tests](http://
66
77- [ Setup] ( #setup )
88- [ Usage] ( #usage )
9- - [ DI module - Nette\DI integration] ( #nettedimodule )
10- - [ Application module - Nette\Application integration] ( #netteapplicationmodule )
9+ - [DI module - Nette\DI integration](#nettedimodule)
10+ - [Application module - Nette\Application integration](#netteapplicationmodule)
1111- [ Development] ( #development )
1212
1313## Setup
@@ -22,7 +22,7 @@ composer require contributte/codeception
2222
2323When you want to write an integration test to make sure that some services work well together you need to create the DI container first.
2424
25- ``` yml
25+ ``` yaml
2626# /tests/integration.suite.yml
2727error_level : " E_ALL"
2828class_name : IntegrationSuiteTester
@@ -42,35 +42,36 @@ modules:
4242 # newContainerForEachTest: true
4343```
4444
45- ``` yml
45+ ``` neon
4646# /tests/integration/config/config.neon
4747services:
48- - MyService
48+ - MyService
4949```
5050
5151``` php
5252# /tests/integration/src/MyServiceTest.php
5353use Codeception\Test\Unit;
54+
5455class MyServiceTest extends Unit
5556{
56- public function testMyService() : void
57- {
58- // Here you can override the configFiles from integration.suite.yml if needed.
59- // The newContainerForEachTest option is required for this.
60- // $this->tester->useConfigFiles(['config/another-config.neon']);
61- $this->assertInstanceOf(MyService::class, $this->tester->grabService(MyService::class));
62- }
57+ public function testMyService(): void
58+ {
59+ // Here you can override the configFiles from integration.suite.yml if needed.
60+ // The newContainerForEachTest option is required for this.
61+ // $this->tester->useConfigFiles(['config/another-config.neon']);
62+ $this->assertInstanceOf(MyService::class, $this->tester->grabService(MyService::class));
63+ }
6364}
6465```
65- ` useConfigFiles ` method takes array of file paths that are either absolute or relative to suite root.
66+ ` useConfigFiles ` method takes array of file paths that are either absolute or relative to suite root.
6667
6768### NetteApplicationModule
6869
6970In functional tests you want to emulate the HTTP request and run ` Nette\Application\Application ` to handle it.
7071
7172Unfortunately Nette framework has some downsides like the fact that Request and Response are registered as services in the DI Container. For this reason the NetteApplicationModule requires ` Contributte\Codeception\DI\CodeceptionExtension ` to override the default implementations. ** Beware that this is meant for the functional tests only. Do NOT register the extension outside of tests.**
7273
73- ``` yml
74+ ``` yaml
7475# /tests/functional.suite.yml
7576error_level : " E_ALL"
7677class_name : FunctionalSuiteTester
@@ -86,25 +87,25 @@ modules:
8687 - config/config.neon
8788` ` `
8889
89- ` ` ` yml
90+ ` ` ` neon
9091# /tests/functional/config/config.neon
9192extensions :
92- codeception : Contributte\Codeception\DI\HttpExtension
93+ codeception: Contributte\Codeception\DI\HttpExtension
9394```
9495
9596``` php
9697# /tests/functional/src/HomepageTest.php
9798use Codeception\Test\Unit;
9899class HomepageTest extends Unit
99100{
100- public function testHomepage() : void
101- {
102- // Create http request and run Nette\Application\Application. See Contributte\Codeception\Connector\NetteConnector for details.
103- $this->tester->amOnPage('/');
104- // Assert that the response is what you expect.
105- $this->tester->seeResponseCodeIs(200);
106- $this->tester->see('Hello World!', 'h1');
107- }
101+ public function testHomepage(): void
102+ {
103+ // Create http request and run Nette\Application\Application. See Contributte\Codeception\Connector\NetteConnector for details.
104+ $this->tester->amOnPage('/');
105+ // Assert that the response is what you expect.
106+ $this->tester->seeResponseCodeIs(200);
107+ $this->tester->see('Hello World!', 'h1');
108+ }
108109}
109110```
110111
@@ -116,7 +117,7 @@ Simply run scripts in `Makefile` and make sure that qa, tester and phpstan passe
116117
117118You can use these commands to do more specific tasks.
118119
119- ```
120+ ``` bash
120121# generate necessary files to run the tests
121122./vendor/bin/codecept build
122123
0 commit comments