@@ -50,9 +50,9 @@ |
||
50 | 50 | $container = $this->getServiceManagerMock(); |
51 | 51 | $plugins = $this->getPluginManagerMock($container); |
52 | 52 | $this->target |
53 | - ->expects($this->once()) |
|
54 | - ->method('__invoke') |
|
55 | - ->with($container, 'Auth/User/Switcher') |
|
53 | + ->expects($this->once()) |
|
54 | + ->method('__invoke') |
|
55 | + ->with($container, 'Auth/User/Switcher') |
|
56 | 56 | ; |
57 | 57 | |
58 | 58 | $this->target->createService($container); |
@@ -18,44 +18,43 @@ |
||
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Class ManageControllerTest |
21 | - |
|
22 | 21 | * @package AuthTest\Controller |
23 | 22 | */ |
24 | 23 | class ManageControllerTest extends AbstractFunctionalControllerTestCase |
25 | 24 | { |
26 | - const URL_MY_PROFILE = '/en/my/profile'; |
|
25 | + const URL_MY_PROFILE = '/en/my/profile'; |
|
27 | 26 | |
28 | - private $hybridAuthAdapter; |
|
27 | + private $hybridAuthAdapter; |
|
29 | 28 | |
30 | - public function setUp() |
|
31 | - { |
|
32 | - parent::setUp(); |
|
29 | + public function setUp() |
|
30 | + { |
|
31 | + parent::setUp(); |
|
33 | 32 | |
34 | - $this->hybridAuthAdapter = $this->getMockBuilder(HybridAuth::class) |
|
35 | - ->disableOriginalConstructor() |
|
36 | - ->getMock() |
|
37 | - ; |
|
38 | - $this->setMockToServiceLocator('HybridAuthAdapter',$this->hybridAuthAdapter); |
|
39 | - } |
|
33 | + $this->hybridAuthAdapter = $this->getMockBuilder(HybridAuth::class) |
|
34 | + ->disableOriginalConstructor() |
|
35 | + ->getMock() |
|
36 | + ; |
|
37 | + $this->setMockToServiceLocator('HybridAuthAdapter',$this->hybridAuthAdapter); |
|
38 | + } |
|
40 | 39 | |
41 | - public function testAccessWhenNotLoggedIn() |
|
42 | - { |
|
43 | - $this->dispatch(self::URL_MY_PROFILE, Request::METHOD_GET); |
|
40 | + public function testAccessWhenNotLoggedIn() |
|
41 | + { |
|
42 | + $this->dispatch(self::URL_MY_PROFILE, Request::METHOD_GET); |
|
44 | 43 | |
45 | - $result = $this->getResponse()->getContent(); |
|
44 | + $result = $this->getResponse()->getContent(); |
|
46 | 45 | |
47 | - $this->assertNotRedirect(); |
|
48 | - $this->assertResponseStatusCode(Response::STATUS_CODE_401); |
|
49 | - $this->assertContains('Please authenticate yourself to proceed', $result); |
|
50 | - } |
|
46 | + $this->assertNotRedirect(); |
|
47 | + $this->assertResponseStatusCode(Response::STATUS_CODE_401); |
|
48 | + $this->assertContains('Please authenticate yourself to proceed', $result); |
|
49 | + } |
|
51 | 50 | |
52 | - public function testAccessWhenLoggedIn() |
|
53 | - { |
|
54 | - $this->authenticateUser(); |
|
55 | - $this->dispatch(self::URL_MY_PROFILE,Request::METHOD_GET); |
|
56 | - $result = $this->getResponse()->getContent(); |
|
57 | - $this->assertNotRedirect(); |
|
58 | - $this->assertResponseStatusCode(Response::STATUS_CODE_200); |
|
59 | - $this->assertContains('My profile - YAWIK', $result); |
|
60 | - } |
|
51 | + public function testAccessWhenLoggedIn() |
|
52 | + { |
|
53 | + $this->authenticateUser(); |
|
54 | + $this->dispatch(self::URL_MY_PROFILE,Request::METHOD_GET); |
|
55 | + $result = $this->getResponse()->getContent(); |
|
56 | + $this->assertNotRedirect(); |
|
57 | + $this->assertResponseStatusCode(Response::STATUS_CODE_200); |
|
58 | + $this->assertContains('My profile - YAWIK', $result); |
|
59 | + } |
|
61 | 60 | } |
@@ -125,7 +125,7 @@ |
||
125 | 125 | |
126 | 126 | $pluginManager = $this->controller->getPluginManager(); |
127 | 127 | $pluginManager->setService('redirect', $redirect); |
128 | - $pluginManager->setService('params', $params); |
|
128 | + $pluginManager->setService('params', $params); |
|
129 | 129 | |
130 | 130 | $user = $this->getMockBuilder(User::class) |
131 | 131 | ->getMock(); |
@@ -52,8 +52,8 @@ |
||
52 | 52 | |
53 | 53 | |
54 | 54 | $this->serviceMock = $this->getMockBuilder('Auth\Service\Register') |
55 | - ->disableOriginalConstructor() |
|
56 | - ->getMock(); |
|
55 | + ->disableOriginalConstructor() |
|
56 | + ->getMock(); |
|
57 | 57 | |
58 | 58 | |
59 | 59 | $this->paramsMock = $this->getMockBuilder('Zend\Mvc\Controller\Plugin\Params') |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | $_SESSION = $oldSession; |
206 | 206 | $this->assertTrue($this->target->switchUser('switchedUser')); |
207 | 207 | $this->assertEquals( |
208 | - [ |
|
209 | - 'isSwitchedUser' => true, |
|
210 | - 'originalUser' => 'originalUser', |
|
211 | - 'params' => [], 'ref' => '/some/ref', |
|
212 | - 'session' => serialize($oldSession) |
|
213 | - ], |
|
214 | - $_SESSION[UserSwitcher::SESSION_NAMESPACE]->getArrayCopy() |
|
208 | + [ |
|
209 | + 'isSwitchedUser' => true, |
|
210 | + 'originalUser' => 'originalUser', |
|
211 | + 'params' => [], 'ref' => '/some/ref', |
|
212 | + 'session' => serialize($oldSession) |
|
213 | + ], |
|
214 | + $_SESSION[UserSwitcher::SESSION_NAMESPACE]->getArrayCopy() |
|
215 | 215 | ); |
216 | 216 | $_SESSION = []; |
217 | 217 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $acl->expects($this->once())->method('setUser')->with($this->isInstanceOf(User::class)); |
236 | 236 | |
237 | 237 | $user = $this->getMockBuilder(User::class)->disableOriginalConstructor() |
238 | - ->setMethods(['getId'])->getMock(); |
|
238 | + ->setMethods(['getId'])->getMock(); |
|
239 | 239 | $user->expects($this->any())->method('getId')->willReturn('switchedUser'); |
240 | 240 | |
241 | 241 | $this->target->switchUser($user, ['ref' => 'ref']); |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | ])); |
44 | 44 | |
45 | 45 | $manager = $this->getMockBuilder(Manager::class) |
46 | - ->disableOriginalConstructor() |
|
47 | - ->getMock() |
|
48 | - ; |
|
46 | + ->disableOriginalConstructor() |
|
47 | + ->getMock() |
|
48 | + ; |
|
49 | 49 | $hybridAuth = $this->getMockBuilder(\Hybrid_Auth::class)->disableOriginalConstructor()->getMock(); |
50 | 50 | $this->setMockToServiceLocator('repositories', $this->repositoriesMock); |
51 | 51 | $this->setMockToServiceLocator('Organizations\ImageFileCache\Manager',$manager); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | public function testAccessWhenYouAreLogged() |
63 | 63 | { |
64 | - /*$repository = $this->getMockBuilder(OrganizationImage::class) |
|
64 | + /*$repository = $this->getMockBuilder(OrganizationImage::class) |
|
65 | 65 | ->disableOriginalConstructor() |
66 | 66 | ->getMock() |
67 | 67 | ; |
@@ -82,37 +82,37 @@ discard block |
||
82 | 82 | $this->assertContains('My password', $result); |
83 | 83 | } |
84 | 84 | |
85 | - public function testAccessWhenYouAreNotLoggedIn() |
|
86 | - { |
|
87 | - $this->dispatch(self::URL_MY_PASSWORD, Request::METHOD_GET); |
|
85 | + public function testAccessWhenYouAreNotLoggedIn() |
|
86 | + { |
|
87 | + $this->dispatch(self::URL_MY_PASSWORD, Request::METHOD_GET); |
|
88 | 88 | |
89 | - $result = $this->getResponse()->getContent(); |
|
89 | + $result = $this->getResponse()->getContent(); |
|
90 | 90 | |
91 | - $this->assertNotRedirect(); |
|
92 | - $this->assertResponseStatusCode(Response::STATUS_CODE_401); |
|
93 | - $this->assertContains('Please authenticate yourself to proceed', $result); |
|
94 | - } |
|
91 | + $this->assertNotRedirect(); |
|
92 | + $this->assertResponseStatusCode(Response::STATUS_CODE_401); |
|
93 | + $this->assertContains('Please authenticate yourself to proceed', $result); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Assert response status code |
|
98 | - * |
|
99 | - * @param int $code |
|
100 | - */ |
|
101 | - public function assertResponseStatusCode($code) |
|
102 | - { |
|
103 | - if ($this->useConsoleRequest) { |
|
104 | - if (! in_array($code, [0, 1])) { |
|
105 | - throw new \PHPUnit_Framework_ExpectationFailedException($this->createFailureMessage( |
|
106 | - 'Console status code assert value must be O (valid) or 1 (error)' |
|
107 | - )); |
|
108 | - } |
|
109 | - } |
|
110 | - $match = $this->getResponseStatusCode(); |
|
111 | - if ($code != $match) { |
|
112 | - throw new \PHPUnit_Framework_ExpectationFailedException($this->createFailureMessage( |
|
113 | - sprintf('Failed asserting response code "%s", actual status code is "%s"', $code, $match) |
|
114 | - )); |
|
115 | - } |
|
116 | - $this->assertEquals($code, $match); |
|
117 | - } |
|
96 | + /** |
|
97 | + * Assert response status code |
|
98 | + * |
|
99 | + * @param int $code |
|
100 | + */ |
|
101 | + public function assertResponseStatusCode($code) |
|
102 | + { |
|
103 | + if ($this->useConsoleRequest) { |
|
104 | + if (! in_array($code, [0, 1])) { |
|
105 | + throw new \PHPUnit_Framework_ExpectationFailedException($this->createFailureMessage( |
|
106 | + 'Console status code assert value must be O (valid) or 1 (error)' |
|
107 | + )); |
|
108 | + } |
|
109 | + } |
|
110 | + $match = $this->getResponseStatusCode(); |
|
111 | + if ($code != $match) { |
|
112 | + throw new \PHPUnit_Framework_ExpectationFailedException($this->createFailureMessage( |
|
113 | + sprintf('Failed asserting response code "%s", actual status code is "%s"', $code, $match) |
|
114 | + )); |
|
115 | + } |
|
116 | + $this->assertEquals($code, $match); |
|
117 | + } |
|
118 | 118 | } |
@@ -88,9 +88,9 @@ |
||
88 | 88 | |
89 | 89 | public function testWithImageField() |
90 | 90 | { |
91 | - if (! function_exists("imageftbbox")) { |
|
92 | - return $this->markTestSkipped('This test requires GD FT fonts support'); |
|
93 | - } |
|
91 | + if (! function_exists("imageftbbox")) { |
|
92 | + return $this->markTestSkipped('This test requires GD FT fonts support'); |
|
93 | + } |
|
94 | 94 | $options = new CaptchaOptions(); |
95 | 95 | $options->setMode("image"); |
96 | 96 | $testedObject = new Register(null, $options); |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | $events = $this->getMockBuilder('\Zend\EventManager\EventManager')->disableOriginalConstructor()->getMock(); |
42 | 42 | $events->expects($this->once()) |
43 | - ->method('attach')->with(MvcEvent::EVENT_DISPATCH_ERROR, [ $target, 'onDispatchError' ]) |
|
44 | - ->willReturn('worked'); |
|
43 | + ->method('attach')->with(MvcEvent::EVENT_DISPATCH_ERROR, [ $target, 'onDispatchError' ]) |
|
44 | + ->willReturn('worked'); |
|
45 | 45 | |
46 | 46 | $this->assertSame($target, $target->attach($events), 'Fluent interface broken'); |
47 | 47 | $this->assertAttributeEquals(['worked'], 'listeners', $target); |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | public function provideTestData() |
51 | 51 | { |
52 | 52 | return [ |
53 | - [ true, true, true, true ], |
|
54 | - [ false, true, true, false ], |
|
55 | - [ true, false, true, false ], |
|
56 | - [ true, true, false, false ], |
|
57 | - [ false, false, true, false ], |
|
58 | - [ false, true, false, false ], |
|
59 | - [ true, false, false, false ], |
|
60 | - [ false, false, false, false ], |
|
61 | - ]; |
|
53 | + [ true, true, true, true ], |
|
54 | + [ false, true, true, false ], |
|
55 | + [ true, false, true, false ], |
|
56 | + [ true, true, false, false ], |
|
57 | + [ false, false, true, false ], |
|
58 | + [ false, true, false, false ], |
|
59 | + [ true, false, false, false ], |
|
60 | + [ false, false, false, false ], |
|
61 | + ]; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | $event = $this->getMockBuilder('\Zend\Mvc\MvcEvent')->disableOriginalConstructor()->getMock(); |
79 | 79 | |
80 | 80 | $event->expects($this->once()) |
81 | - ->method('getParam')->with('exception') |
|
82 | - ->willReturn($exception); |
|
81 | + ->method('getParam')->with('exception') |
|
82 | + ->willReturn($exception); |
|
83 | 83 | |
84 | 84 | if ($useValidModel) { |
85 | 85 | $model = $this->getMockBuilder('\Zend\View\Model\ViewModel')->disableOriginalConstructor()->getMock(); |
@@ -89,16 +89,16 @@ discard block |
||
89 | 89 | $model->expects($this->never())->method('setTemplate'); |
90 | 90 | } |
91 | 91 | $event->expects($this->once()) |
92 | - ->method('getError') |
|
93 | - ->willReturn($useValidError ? Application::ERROR_EXCEPTION : 'NotMatchError'); |
|
92 | + ->method('getError') |
|
93 | + ->willReturn($useValidError ? Application::ERROR_EXCEPTION : 'NotMatchError'); |
|
94 | 94 | } else { |
95 | 95 | $model = 'not a view model instance'; |
96 | 96 | $event->expects($this->never())->method('getError'); |
97 | 97 | } |
98 | 98 | |
99 | 99 | $event->expects($this->once()) |
100 | - ->method('getResult') |
|
101 | - ->willReturn($model); |
|
100 | + ->method('getResult') |
|
101 | + ->willReturn($model); |
|
102 | 102 | |
103 | 103 | $target->onDispatchError($event); |
104 | 104 | } |
@@ -126,10 +126,10 @@ |
||
126 | 126 | $eventManager->expects($this->exactly(3)) |
127 | 127 | ->method('attach') |
128 | 128 | ->withConsecutive( |
129 | - [$this->equalTo(MvcEvent::EVENT_DISPATCH_ERROR), $this->identicalTo([$this->listener, 'prepareExceptionViewModel'], $this->identicalTo(null))], |
|
130 | - [$this->equalTo(MvcEvent::EVENT_RENDER_ERROR), $this->identicalTo([$this->listener, 'prepareExceptionViewModel'], $this->identicalTo(null))], |
|
131 | - [$this->equalTo(MvcEvent::EVENT_ROUTE), $this->identicalTo([$this->listener, 'checkDeactivatedUser'], $this->identicalTo(null))] |
|
132 | - ); |
|
129 | + [$this->equalTo(MvcEvent::EVENT_DISPATCH_ERROR), $this->identicalTo([$this->listener, 'prepareExceptionViewModel'], $this->identicalTo(null))], |
|
130 | + [$this->equalTo(MvcEvent::EVENT_RENDER_ERROR), $this->identicalTo([$this->listener, 'prepareExceptionViewModel'], $this->identicalTo(null))], |
|
131 | + [$this->equalTo(MvcEvent::EVENT_ROUTE), $this->identicalTo([$this->listener, 'checkDeactivatedUser'], $this->identicalTo(null))] |
|
132 | + ); |
|
133 | 133 | |
134 | 134 | $this->listener->attach($eventManager); |
135 | 135 | } |