noiselabs / zf-test-case-behat-extension
通过暴露Zend\Test类(最初为PHPUnit构建)进行ZF MVC应用的集成测试
0.2.0
2017-09-19 12:15 UTC
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-09-11 14:58:43 UTC
README
通过暴露Zend\Test类(最初为PHPUnit构建)在Behat中对ZF MVC应用进行集成测试。
安装
此扩展需要
- Behat 3.0+
推荐的安装方法是使用Composer
$ composer require --dev noiselabs/zf-test-case-behat-extension
然后您可以在您的behat.yml
中激活此扩展
default: # ... extensions: Noiselabs\Behat\ZfTestCaseExtension\ServiceContainer\ZfTestCaseExtension: configuration: </path/to/application.config.php>
用法
实现ZfTestCaseAwareContext
或扩展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'); } }
版权
版权(c)2017 Vítor Brandão。许可协议MIT License。