Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.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
Unit testing laravel 4中的应用程序帮助程序出现phpunit错误_Unit Testing_Laravel_Laravel 4 - Fatal编程技术网

Unit testing laravel 4中的应用程序帮助程序出现phpunit错误

Unit testing laravel 4中的应用程序帮助程序出现phpunit错误,unit-testing,laravel,laravel-4,Unit Testing,Laravel,Laravel 4,我尝试在我的laravel项目中开始使用phpunit 我调用“phpunit”并得到以下错误: $ phpunit PHPUnit 3.6.10 by Sebastian Bergmann. Configuration read from /home/bee/www/postaler/phpunit.xml EPHP Fatal error: Cannot redeclare Helper\isMenuActive() (previously declared in /home/bee

我尝试在我的laravel项目中开始使用phpunit

我调用“phpunit”并得到以下错误:

$ phpunit 
PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from /home/bee/www/postaler/phpunit.xml

EPHP Fatal error:  Cannot redeclare Helper\isMenuActive() (previously declared in /home/bee/www/postaler/app/helpers.php:4) in /home/bee/www/postaler/app/helpers.php on line 6
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP   3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:192
PHP   5. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:325
PHP   6. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:705
PHP   7. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:745
PHP   8. PHPUnit_Framework_TestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:772
PHP   9. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:751
PHP  10. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHPUnit/Framework/TestResult.php:649
PHP  11. Illuminate\Foundation\Testing\TestCase->setUp() /usr/share/php/PHPUnit/Framework/TestCase.php:801
PHP  12. Illuminate\Foundation\Testing\TestCase->refreshApplication() /home/bee/www/postaler/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:31
PHP  13. Illuminate\Foundation\Application->boot() /home/bee/www/postaler/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:48
PHP  14. Illuminate\Foundation\Application->bootApplication() /home/bee/www/postaler/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:552
PHP  15. Illuminate\Foundation\Application->fireAppCallbacks() /home/bee/www/postaler/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:569
PHP  16. call_user_func:{/home/bee/www/postaler/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:792}() /home/bee/www/postaler/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:792
PHP  17. TestCase->{closure:/home/bee/www/postaler/vendor/laravel/framework/src/Illuminate/Foundation/start.php:223-271}() /home/bee/www/postaler/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:792
PHP  18. require() /home/bee/www/postaler/vendor/laravel/framework/src/Illuminate/Foundation/start.php:239
我的助手代码

<?php namespace Helper;
//app/helpers.php

function isMenuActive($url_segment) {
    if (\Request::segment(1) == $url_segment) { return " active"; }
}
我的测试脚本

<?php
// app/tests/FromTest.php
class FromTest extends TestCase {

    public function testFrom()
    {
        $response = $this->call('GET', 'user/profile');

        $this->assertTrue(true);
    }

}

app/start/global.php
对每个请求执行一次,不应用于类/函数/常量定义。相反,将
文件
自动加载规则添加到composer.json

"files": ["src/functions.php"],
"files": ["src/functions.php"],