シンプルなコントローラーアクションがありました
class CatalogController extends AbstractActionController {
public function indexAction() {
return new ViewModel();
}
// ...
}
およびその単体テスト:
class CatalogControllerTest extends AbstractHttpControllerTestCase
{
public function testIndexActionCanBeAccessed()
{
$this->routeMatch->setParam('action', 'index');
$result = $this->controller->dispatch($this->request);
$response = $this->controller->getResponse();
$this->assertEquals(200, $response->getStatusCode());
$this->assertInstanceOf('Zend\View\Model\ViewModel', $result);
}
うまくいきました。
今、私はリクエストを転送しています
public function indexAction() {
return $this->forward()->dispatch('Catalog/Controller/Catalog', array('action' => 'list-cities'));
}
の後に単体テストでエラーが発生しました$this->controller->dispatch($this->request);
:
PHP Fatal error: Call to a member function getEventManager() on a non-object in /var/www/path/to/project/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/Plugin/Forward.php on line 147
フォワードを使用してアクションメソッドをどのようにテストしますか?
どうも