【发布时间】:2015-07-20 02:30:22
【问题描述】:
以下简单的控制器测试向 PostsController@index 操作发出“GET”请求:
<?php
class PostsControllerTest extends TestCase {
public function testIndex()
{
$response = $this->action('GET', 'PostsController@index');
}
}
据我了解,如果我的控制器中不存在 index 方法,那么在我的命令行中调用 phpunit 时,我不应该得到绿灯。
然而我的控制器看起来像这样:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class PostsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Response
*/
// public function index()
// {
// //
// return 'Posts Index';
//}
}
你可以清楚地看到 index 方法被注释掉了,我仍然得到这个:
**OK (1 test, 0 assertions)**
有什么建议吗?
【问题讨论】:
标签: php unit-testing laravel testing