Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为Codeigniter My_ciunit控制器测试设置不同的输入_Php_Codeigniter_Testing_Phpunit - Fatal编程技术网

Php 为Codeigniter My_ciunit控制器测试设置不同的输入

Php 为Codeigniter My_ciunit控制器测试设置不同的输入,php,codeigniter,testing,phpunit,Php,Codeigniter,Testing,Phpunit,我知道如何设置和执行控制器来测试它 请参阅框架链接 但是如何定义给定的测试数据输入?当然,我可以自己设置$\u GET和$\u POST,但是输入库会重新分析它吗 我在谷歌找不到答案。我还想知道为什么Codeigniter测试的谷歌结果如此糟糕 <?php /** * @group Controller */ class SomeControllerTest extends CIUnit_TestCase { public function setUp() { // S

我知道如何设置和执行控制器来测试它

请参阅框架链接

但是如何定义给定的测试数据输入?当然,我可以自己设置$\u GET和$\u POST,但是输入库会重新分析它吗

我在谷歌找不到答案。我还想知道为什么Codeigniter测试的谷歌结果如此糟糕

<?php

/**
  * @group Controller
  */

class SomeControllerTest extends CIUnit_TestCase
{
public function setUp()
{
    // Set the tested controller
    $this->CI = set_controller('welcome');
}

public function testWelcomeController()
{

    // Call the controllers method
    $this->CI->index();

    // Fetch the buffered output
    $out = output();
            $viewData = viewvars();

    // Check if the content is OK
    $this->assertSame(0, preg_match('/(error|notice)/i', $out));
}

    public function testInput(){

        //reset $_GET and $_POST?

        $this->CI->login();

        //assert valid login etc ...
    }

是的,您需要在测试设置中或任何最有意义的地方手动设置$\u GET和$\u POST值,例如:

public function setUp()
{
    // Set the tested controller
    $this->CI = set_controller('welcome');
    // Set up the input values
    $_GET['parameter_1'] = 'Some String';
    $_GET['parameter_2'] = 123;
}

是的,您需要在测试设置中或任何最有意义的地方手动设置$\u GET和$\u POST值,例如:

public function setUp()
{
    // Set the tested controller
    $this->CI = set_controller('welcome');
    // Set up the input values
    $_GET['parameter_1'] = 'Some String';
    $_GET['parameter_2'] = 123;
}