noiselabs / zf-test-case-behat-extension
Integration testing for ZF MVC applications in Behat by exposing Zend\Test classes (originally built for PHPUnit)
Installs: 15 739
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 2
Open Issues: 0
Type:behat-extension
Requires
- php: ^5.5 || ^7.0
- behat/behat: ^3.0
- zendframework/zend-test: ~2.3|~3.0
Requires (Dev)
- phpunit/phpunit: ^4.0 || ^5.0 || ^6.0
- symfony/process: ~2.1|~3.0
- zendframework/zend-i18n: ~2.3|~3.0
- zendframework/zend-log: ~2.3|~3.0
- zendframework/zend-modulemanager: ~2.3|~3.0
- zendframework/zend-mvc: ~2.3|~3.0
- zendframework/zend-router: ~2.3|~3.0
- zendframework/zend-serializer: ~2.3|~3.0
This package is auto-updated.
Last update: 2024-10-11 15:09:15 UTC
README
Integration testing for ZF MVC applications in Behat by exposing Zend\Test classes (originally built for PHPUnit).
Installation
This extension requires:
- Behat 3.0+
The recommended installation method is through Composer:
$ composer require --dev noiselabs/zf-test-case-behat-extension
You can then activate the extension in your behat.yml
:
default: # ... extensions: Noiselabs\Behat\ZfTestCaseExtension\ServiceContainer\ZfTestCaseExtension: configuration: </path/to/application.config.php>
Usage
Implement ZfTestCaseAwareContext
or extend ZfTestCaseContext
:
<?php use Album\Controller\AlbumController; use Noiselabs\Behat\ZfTestCaseExtension\Context\ZfTestCaseAwareContext; use Noiselabs\Behat\ZfTestCaseExtension\TestCase\HttpControllerTestCase; class MyContext implements ZfTestCaseAwareContext { /** * @var HttpControllerTestCase */ private $testCase; public function setTestCase(HttpControllerTestCase $testCase) { $this->testCase = $testCase; } /** * @When /^the album endpoint is called$/ */ public function testIndexActionCanBeAccessed() { // See https://docs.zendframework.com/tutorials/unit-testing/ $this->testCase->dispatch('/album'); $this->testCase->assertResponseStatusCode(200); $this->testCase->assertModuleName('Album'); $this->testCase->assertControllerName(AlbumController::class); $this->testCase->assertControllerClass('AlbumController'); $this->testCase->assertMatchedRouteName('album'); } }
Copyright
Copyright (c) 2017 Vítor Brandão. Licensed under the MIT License.