【发布时间】:2016-10-31 20:52:27
【问题描述】:
我正在尝试通过在单元测试中调用我的控制器操作来内部测试 API。出于某种原因,我收到 InvalidArgumentException: Route [ListController@create] not defined。任何人都可以帮忙吗?
ListControllerTest.phpuse Guzzle\Tests\GuzzleTestCase,
Guzzle\Plugin\Mock\MockPlugin,
Guzzle\Http\Message\Response,
Guzzle\Http\Client,
Guzzle\Service\Client as ServiceClient,
Guzzle\Http\EntityBody;
class ListTest extends TestCase {
public function testCreateList()
{
$user_id = getTestReceiverUserId();
$response = $this->action(
'POST',
'ListController@create',
[
'body' => array(
"name" => "open,shared",
"users" => array(array("user_id" => $user_id)),
"visibility" => "2",
"joinability" => "2",
"adminship" => "1",
"color" => "#2bc069"
),
'headers' => array('Auth' => getTestAuthSender())
]
);
}
路由.php
Route::group(array('namespace' => 'App\Controllers\v2', 'prefix' => '2.0'), function()
{
Route::controller('user', 'UserController');
Route::controller('invite', 'InviteController');
Route::controller('list', 'ListController');
Route::post('/login','AuthController@login');
Route::any('/logout','AuthController@logout');
});
列表控制器.php
namespace App\Controllers\v1;
use BaseController;
use Timothylhuillier\LaravelMixpanel\Facades\LaravelMixpanel;
class ListController extends BaseController
{
public function postCreate()
{
Some Code
}
【问题讨论】:
-
你使用的是什么版本的 Laravel?
-
我使用的是 4.2 版
-
@RossWilson 你知道问题是什么吗?
标签: php api unit-testing phpunit