Fix test cases.

This commit is contained in:
James Cole
2018-02-28 20:18:47 +01:00
parent 46f4fa1a7d
commit fdd2dedfc6
23 changed files with 792 additions and 735 deletions

View File

@@ -1230,17 +1230,20 @@ class BinderTest extends TestCase
*/
public function testTagList()
{
$tagRepos = $this->mock(TagRepositoryInterface::class);
$tagRepos->shouldReceive('setUser');
$tags = $this->user()->tags()->whereIn('id', [1, 2])->get(['tags.*']);
$tagRepos->shouldReceive('get')->once()->andReturn($tags);
Route::middleware(Binder::class)->any(
'/_test/binder/{tagList}', function (Collection $tags) {
return 'count: ' . $tags->count();
}
);
$tags = $this->user()->tags()->whereIn('id', [1, 2])->get(['tags.*']);
$names = join(',', $tags->pluck('tag')->toArray());
$repository = $this->mock(TagRepositoryInterface::class);
$repository->shouldReceive('setUser');
$repository->shouldReceive('get')->once()->andReturn($tags);
$this->be($this->user());
$response = $this->get('/_test/binder/' . $names);
@@ -1256,6 +1259,10 @@ class BinderTest extends TestCase
*/
public function testTagListEmpty()
{
$tagRepos = $this->mock(TagRepositoryInterface::class);
$tagRepos->shouldReceive('setUser');
$tagRepos->shouldReceive('get')->once()->andReturn(new Collection());
Route::middleware(Binder::class)->any(
'/_test/binder/{tagList}', function (Collection $tags) {
return 'count: ' . $tags->count();