我正在为 zend 项目编写单元测试, 我想知道
<?php
class IndexControllerTest extends ControllerTestCase
{
public function testHomePage() {
$this->dispatch('/');
}
}
ControllerTestcase.php 扩展了 Zend/Test/PHPUnit/ControllerTestCase.php
<?php
require_once 'Zend/Application.php';
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';
class ControllerTestCase
extends Zend_Test_PHPUnit_ControllerTestCase
{
protected $application;
public function setUp() {
$this->bootstrap = array($this,'appBootstrap');
parent::setUp();
}
public function appBootstrap() {
$this->application =
new Zend_Application(APPLICATION_ENV,
APPLICATION_PATH.'/configs/application.ini');
$this->application->bootstrap();
}
}
$this->dispatch('/'); 的作用是什么方法?这是否意味着将请求转发到应用程序的根目录?
最佳答案
从注释到此方法:
* Dispatch the MVC
*
* If a URL is provided, sets it as the request URI in the request object.
* Then sets test case request and response objects in front controller,
* disables throwing exceptions, and disables returning the response.
* Finally, dispatches the front controller.
关于php - $this->dispatch ('/' ) 在 zend 测试中意味着什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5801942/