$this是什么->;dispatch(';/';)表示在zend测试中


What does $this->dispatch('/') means in zend test

我正在为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.  

http://framework.zend.com/svn/framework/standard/tags/release-1.9.8/library/Zend/Test/PHPUnit/ControllerTestCase.php

在面向对象编程中,当一个类扩展另一个类时,它继承其父类(正在扩展的类(的方法(或函数(。

可以使用$this->method从类本身或其子类(扩展它的其他类(中调用类方法。

假设dispatch没有在IndexControllerTest中定义,它必须是ControllerTestCase(IndexControllerTest扩展(的函数,并且它正在向它传递字符串'/'

看看类ControllerTestCase,会有一个名为dispatch的函数,你可以看到它在做什么。