diff --git a/.docs/README.md b/.docs/README.md index 0f1c138..c4146e6 100644 --- a/.docs/README.md +++ b/.docs/README.md @@ -6,8 +6,8 @@ This library is here to help you with Integration and [Functional Tests](http:// - [Setup](#setup) - [Usage](#usage) - - [DI module - Nette\DI integration](#nettedimodule) - - [Application module - Nette\Application integration](#netteapplicationmodule) + - [DI module - Nette\DI integration](#nettedimodule) + - [Application module - Nette\Application integration](#netteapplicationmodule) - [Development](#development) ## Setup @@ -22,7 +22,7 @@ composer require contributte/codeception When you want to write an integration test to make sure that some services work well together you need to create the DI container first. -```yml +```yaml # /tests/integration.suite.yml error_level: "E_ALL" class_name: IntegrationSuiteTester @@ -42,27 +42,28 @@ modules: # newContainerForEachTest: true ``` -```yml +```neon # /tests/integration/config/config.neon services: - - MyService + - MyService ``` ```php # /tests/integration/src/MyServiceTest.php use Codeception\Test\Unit; + class MyServiceTest extends Unit { - public function testMyService(): void - { - // Here you can override the configFiles from integration.suite.yml if needed. - // The newContainerForEachTest option is required for this. - // $this->tester->useConfigFiles(['config/another-config.neon']); - $this->assertInstanceOf(MyService::class, $this->tester->grabService(MyService::class)); - } + public function testMyService(): void + { + // Here you can override the configFiles from integration.suite.yml if needed. + // The newContainerForEachTest option is required for this. + // $this->tester->useConfigFiles(['config/another-config.neon']); + $this->assertInstanceOf(MyService::class, $this->tester->grabService(MyService::class)); + } } ``` -`useConfigFiles` method takes array of file paths that are either absolute or relative to suite root. +`useConfigFiles` method takes array of file paths that are either absolute or relative to suite root. ### NetteApplicationModule @@ -70,7 +71,7 @@ In functional tests you want to emulate the HTTP request and run `Nette\Applicat Unfortunately 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.** -```yml +```yaml # /tests/functional.suite.yml error_level: "E_ALL" class_name: FunctionalSuiteTester @@ -86,10 +87,10 @@ modules: - config/config.neon ``` -```yml +```neon # /tests/functional/config/config.neon extensions: - codeception: Contributte\Codeception\DI\HttpExtension + codeception: Contributte\Codeception\DI\HttpExtension ``` ```php @@ -97,14 +98,14 @@ extensions: use Codeception\Test\Unit; class HomepageTest extends Unit { - public function testHomepage(): void - { - // Create http request and run Nette\Application\Application. See Contributte\Codeception\Connector\NetteConnector for details. - $this->tester->amOnPage('/'); - // Assert that the response is what you expect. - $this->tester->seeResponseCodeIs(200); - $this->tester->see('Hello World!', 'h1'); - } + public function testHomepage(): void + { + // Create http request and run Nette\Application\Application. See Contributte\Codeception\Connector\NetteConnector for details. + $this->tester->amOnPage('/'); + // Assert that the response is what you expect. + $this->tester->seeResponseCodeIs(200); + $this->tester->see('Hello World!', 'h1'); + } } ``` @@ -116,7 +117,7 @@ Simply run scripts in `Makefile` and make sure that qa, tester and phpstan passe You can use these commands to do more specific tasks. -``` +```bash # generate necessary files to run the tests ./vendor/bin/codecept build diff --git a/README.md b/README.md index 5e34ead..c40d74f 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ To install latest version of `contributte/codeception` use [Composer](https://getcomposer.com). -``` +```bash composer require contributte/codeception ```