php - $this->dispatch ('/' ) 在 zend 测试中意味着什么

标签 php unit-testing oop

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

关于php - $this->dispatch ('/' ) 在 zend 测试中意味着什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5801942/

相关文章:

java - 使用php在android中列出mysql值

unit-testing - 为什么单元测试尝试在 Spring Boot 中的 Controller 特定单元测试中查找其他 bean

java - 面向对象设计——何时使用 getClass 和 instanceof

c# - 构建通用应用程序 - 允许客户特定的选项

javascript - 基于原型(prototype)与基于类的继承

php - 连接到远程服务器 MySQL 问题

php - cakePHP 和 EasyPHP 无法烘焙

c# - 为什么参数对于字符串数组和整数数组的行为不同?

c# - 似乎无法伪造 RNGCryptoServiceProvider

php - Laravel JWT token 在身份验证 JWT 方法中刷新后无效