| @@ 39-70 (lines=32) @@ | ||
| 36 | self::$functions = Mockery::mock(); |
|
| 37 | } |
|
| 38 | ||
| 39 | public function testShowLoginWithValidServiceUrl() |
|
| 40 | { |
|
| 41 | $serviceRepository = Mockery::mock(ServiceRepository::class) |
|
| 42 | ->shouldReceive('isUrlValid') |
|
| 43 | ->andReturn(true) |
|
| 44 | ->once() |
|
| 45 | ->getMock(); |
|
| 46 | app()->instance(ServiceRepository::class, $serviceRepository); |
|
| 47 | $loginInteraction = Mockery::mock(UserLogin::class) |
|
| 48 | ->shouldReceive('showLoginPage') |
|
| 49 | ->andReturnUsing( |
|
| 50 | function ($request, $errors) { |
|
| 51 | $this->assertEmpty($errors); |
|
| 52 | ||
| 53 | return 'show login called'; |
|
| 54 | } |
|
| 55 | ) |
|
| 56 | ->once() |
|
| 57 | ->shouldReceive('getCurrentUser') |
|
| 58 | ->andReturn(false) |
|
| 59 | ->once() |
|
| 60 | ->getMock(); |
|
| 61 | app()->instance(UserLogin::class, $loginInteraction); |
|
| 62 | $request = Mockery::mock(Request::class) |
|
| 63 | ->shouldReceive('get') |
|
| 64 | ->withArgs(['service', '']) |
|
| 65 | ->andReturn('what ever') |
|
| 66 | ->once() |
|
| 67 | ->getMock(); |
|
| 68 | $this->assertEquals('show login called', app()->make(SecurityController::class)->showLogin($request)); |
|
| 69 | ||
| 70 | } |
|
| 71 | ||
| 72 | public function testShowLoginWithInvalidServiceUrl() |
|
| 73 | { |
|
| @@ 72-103 (lines=32) @@ | ||
| 69 | ||
| 70 | } |
|
| 71 | ||
| 72 | public function testShowLoginWithInvalidServiceUrl() |
|
| 73 | { |
|
| 74 | $serviceRepository = Mockery::mock(ServiceRepository::class) |
|
| 75 | ->shouldReceive('isUrlValid') |
|
| 76 | ->andReturn(false) |
|
| 77 | ->once() |
|
| 78 | ->getMock(); |
|
| 79 | app()->instance(ServiceRepository::class, $serviceRepository); |
|
| 80 | $loginInteraction = Mockery::mock(UserLogin::class) |
|
| 81 | ->shouldReceive('showLoginPage') |
|
| 82 | ->andReturnUsing( |
|
| 83 | function ($request, $errors) { |
|
| 84 | $this->assertNotEmpty($errors); |
|
| 85 | $this->assertEquals(CasException::INVALID_SERVICE, $errors[0]); |
|
| 86 | ||
| 87 | return 'show login called'; |
|
| 88 | } |
|
| 89 | ) |
|
| 90 | ->once() |
|
| 91 | ->shouldReceive('getCurrentUser') |
|
| 92 | ->andReturn(false) |
|
| 93 | ->once() |
|
| 94 | ->getMock(); |
|
| 95 | app()->instance(UserLogin::class, $loginInteraction); |
|
| 96 | $request = Mockery::mock(Request::class) |
|
| 97 | ->shouldReceive('get') |
|
| 98 | ->withArgs(['service', '']) |
|
| 99 | ->andReturn('what ever') |
|
| 100 | ->once() |
|
| 101 | ->getMock(); |
|
| 102 | $this->assertEquals('show login called', app()->make(SecurityController::class)->showLogin($request)); |
|
| 103 | } |
|
| 104 | ||
| 105 | public function testShowLoginWhenLoggedInWithValidServiceUrlWithoutWarn() |
|
| 106 | { |
|