laravel中的控制器和单元testController。并获取'tableData'的非法字符串错误,该表定义为映射$ arrViewBoundData数组
public function getGroupList()
{
try {
$requiredPermissions = [
config('permission.group_list_view_own'),
config('permission.group_list_view_all'),
];
if (!$this->userPermissionHelper->checkHasPermissionFor($requiredPermissions)) {
return view('error.permission-denied');
}
$arrGroup = $this->groupRepo->getGroupList(Input::get());
return view('group.index', $arrGroup);
} catch (\Exception $ex) {
return view('error.error_404');
}
}
public function testGetGroupListForListOfRecords()
{
$this->app->instance('middleware.disable', true);
$sampleJsonFile = file_get_contents(base_path('tests\Unit\sample_outputs\group_list.json'));
$sampleOutput = json_decode($sampleJsonFile, true);
$sampleOutput['tableData'] = array((object) $sampleOutput['tableData']);
$sampleOutput['langList'] = array((object) $sampleOutput['langList']);
$this->objMockGroupRepositoryInterface->shouldReceive('getGroupList')->andReturn($sampleOutput);
$this->app->instance(GroupRepositoryInterface::class, $this->objMockGroupRepositoryInterface);
$response = $this->call('GET', 'test-group/group');
$arrViewBoundData = $response->original;
$this->assertGreaterThan(0,count($arrViewBoundData['tableData']));
}