public function test_Should_DisplayIndexPage_When_IndexPageIsRequested() { $servers = Factory::buildList('App\\Models\\Server', [['id' => 1, 'name' => 'Server 1', 'description' => '', 'body' => '', 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon()], ['id' => 2, 'name' => 'Server 2', 'description' => '', 'body' => '', 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon()], ['id' => 3, 'name' => 'Server 3', 'description' => '', 'body' => '', 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon()]]); $perPage = 10; $this->mockServerRepository->shouldReceive('byPage')->once()->andReturn(new Illuminate\Pagination\Paginator($servers, $perPage)); $this->get('servers'); $this->assertResponseOk(); $this->assertViewHas('servers'); }
public function test_Should_DisplayIndexPage_When_IndexPageIsRequested() { $users = Factory::buildList('App\\Models\\User', [['id' => 1, 'name' => 'User 1', 'email' => '*****@*****.**', 'password' => '12345678', 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon()], ['id' => 2, 'name' => 'User 2', 'email' => '*****@*****.**', 'password' => '12345678', 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon()], ['id' => 3, 'name' => 'User 3', 'email' => '*****@*****.**', 'password' => '12345678', 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon()]]); $perPage = 10; $this->mockUserRepository->shouldReceive('byPage')->once()->andReturn(new Illuminate\Pagination\Paginator($users, $perPage)); $this->get('users'); $this->assertResponseOk(); $this->assertViewHas('users'); }
public function test_Should_DisplayIndexPage_When_IndexPageIsRequested() { $deployments = Factory::buildList('App\\Models\\Deployment', [['id' => 1, 'project_id' => 1, 'number' => 1, 'task' => 'deploy', 'user_id' => 1, 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon(), 'user' => new App\Models\User()], ['id' => 2, 'project_id' => 1, 'number' => 2, 'task' => 'deploy', 'user_id' => 1, 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon(), 'user' => new App\Models\User()], ['id' => 3, 'project_id' => 1, 'number' => 3, 'task' => 'deploy', 'user_id' => 1, 'created_at' => new Carbon\Carbon(), 'updated_at' => new Carbon\Carbon(), 'user' => new App\Models\User()]]); $perPage = 10; $project = $this->mockProjectModel->shouldReceive('getDeploymentsByPage')->once()->andReturn(new Illuminate\Pagination\Paginator($deployments, $perPage))->mock(); $this->mockProjectRepository->shouldReceive('byId')->once()->andReturn($project); $this->get('projects/1/deployments'); $this->assertResponseOk(); $this->assertViewHas('deployments'); $this->assertViewHas('project'); }