/** * @param Request $request */ protected function assertRequestAuthorisesOnStaff(Request $request) { $userIsStaff = $this->generator()->anyBoolean(); $this->httpRequest->shouldReceive('user->isStaff')->andReturn($userIsStaff); $authorised = $request->authorize($this->httpRequest); $this->assertSame($userIsStaff, $authorised); }
/** @test */ public function counter_correctly_retrieves_page_number_and_calculates_the_position() { $this->request->shouldReceive('query')->once()->andReturn('2'); $counter = $this->helper->counter(5); $this->assertEquals(6, $counter); $counter = $this->helper->counter(10); $this->assertEquals(11, $counter); }
/** @test */ public function should_return_response_lol() { $credentials = ['email' => 'badEmail', 'password' => 'password']; $this->request->shouldReceive('only')->andReturn($credentials); $this->authService->shouldReceive('loginWithCredentials')->andReturn(UserStub::create()); $this->tokenService->shouldReceive('requestAccessToken')->andReturn(EncodedToken::fromNative('token')); $this->transformer->shouldReceive('item')->andReturn('asdf'); $response = $this->authController->Login($this->request); $this->assertInstanceOf('Illuminate\\Http\\JsonResponse', $response); }
/** * @return MockInterface|User */ protected function mockRequestUser() : MockInterface { $user = $this->mockery(User::class); $this->request->shouldReceive('user')->zeroOrMoreTimes()->andReturn($user); return $user; }