@@ -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); |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | private $target = [ |
| 40 | 40 | UserSwitcherFactory::class, |
| 41 | 41 | '@testCreateServiceInvokesItself' => [ |
| 42 | - 'mock' => [ '__invoke' ], |
|
| 42 | + 'mock' => ['__invoke'], |
|
| 43 | 43 | ], |
| 44 | 44 | ]; |
| 45 | 45 | |
| 46 | - private $inheritance = [ FactoryInterface::class ]; |
|
| 46 | + private $inheritance = [FactoryInterface::class]; |
|
| 47 | 47 | |
| 48 | 48 | public function testCreateServiceInvokesItself() |
| 49 | 49 | { |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $auth = $this->getMockBuilder(AuthenticationService::class)->disableOriginalConstructor()->getMock(); |
| 64 | 64 | $acl = $this->getMockBuilder(Acl::class)->disableOriginalConstructor()->getMock(); |
| 65 | 65 | $sm = $this->createServiceManagerMock(); |
| 66 | - $controllerPlugins = $this->getPluginManagerMock(['Acl' => ['service' => $acl, 'count_get' => 1]],$sm); |
|
| 66 | + $controllerPlugins = $this->getPluginManagerMock(['Acl' => ['service' => $acl, 'count_get' => 1]], $sm); |
|
| 67 | 67 | $container = $this->getServiceManagerMock([ |
| 68 | 68 | 'AuthenticationService' => ['service' => $auth, 'count_get' => 1], |
| 69 | 69 | 'ControllerPluginManager' => ['service' => $controllerPlugins, 'count_get' => 1] |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | |
| 27 | 27 | $hm = new HelperPluginManager($sm); |
| 28 | 28 | |
| 29 | - $helper = $f->__invoke($sm,Auth::class); |
|
| 29 | + $helper = $f->__invoke($sm, Auth::class); |
|
| 30 | 30 | |
| 31 | 31 | $this->assertInstanceOf('\Auth\View\Helper\Auth', $helper); |
| 32 | 32 | $this->assertSame($auth, $helper->getService()); |
@@ -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 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | ->disableOriginalConstructor() |
| 36 | 36 | ->getMock() |
| 37 | 37 | ; |
| 38 | - $this->setMockToServiceLocator('HybridAuthAdapter',$this->hybridAuthAdapter); |
|
| 38 | + $this->setMockToServiceLocator('HybridAuthAdapter', $this->hybridAuthAdapter); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function testAccessWhenNotLoggedIn() |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | public function testAccessWhenLoggedIn() |
| 53 | 53 | { |
| 54 | 54 | $this->authenticateUser(); |
| 55 | - $this->dispatch(self::URL_MY_PROFILE,Request::METHOD_GET); |
|
| 55 | + $this->dispatch(self::URL_MY_PROFILE, Request::METHOD_GET); |
|
| 56 | 56 | $result = $this->getResponse()->getContent(); |
| 57 | 57 | $this->assertNotRedirect(); |
| 58 | 58 | $this->assertResponseStatusCode(Response::STATUS_CODE_200); |
@@ -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') |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $postData = array( |
| 136 | 136 | 'name' => uniqid('name'), |
| 137 | - 'email' => uniqid('email') . '@' . uniqid('host') . '.com.pl' |
|
| 137 | + 'email' => uniqid('email').'@'.uniqid('host').'.com.pl' |
|
| 138 | 138 | ); |
| 139 | 139 | |
| 140 | 140 | $request = new Request(); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | { |
| 182 | 182 | $postData = array( |
| 183 | 183 | 'name' => uniqid('name'), |
| 184 | - 'email' => uniqid('email') . '@' . uniqid('host') . '.com.pl' |
|
| 184 | + 'email' => uniqid('email').'@'.uniqid('host').'.com.pl' |
|
| 185 | 185 | ); |
| 186 | 186 | |
| 187 | 187 | $request = new Request(); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | { |
| 229 | 229 | $postData = array( |
| 230 | 230 | 'name' => uniqid('name'), |
| 231 | - 'email' => uniqid('email') . '@' . uniqid('host') . '.com.pl' |
|
| 231 | + 'email' => uniqid('email').'@'.uniqid('host').'.com.pl' |
|
| 232 | 232 | ); |
| 233 | 233 | |
| 234 | 234 | $request = new Request(); |
@@ -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,10 +43,10 @@ discard block |
||
| 43 | 43 | private $target = [ |
| 44 | 44 | UserSwitcher::class, |
| 45 | 45 | 'getSimpleAuthMock', |
| 46 | - '@testInheritance' => [ 'as_reflection' => true ], |
|
| 46 | + '@testInheritance' => ['as_reflection' => true], |
|
| 47 | 47 | '@testInvokationProxiesToCorrectMethods' => [ |
| 48 | 48 | 'args' => false, |
| 49 | - 'mock' => [ 'clear' => 1, 'switchUser' => ['with' => 'testUserId', 'count' => 1]], |
|
| 49 | + 'mock' => ['clear' => 1, 'switchUser' => ['with' => 'testUserId', 'count' => 1]], |
|
| 50 | 50 | ], |
| 51 | 51 | '@testClearRestoresOriginalUserAndClearsSession' => [ |
| 52 | 52 | 'args' => 'getComplexAuthMock', |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | ], |
| 63 | 63 | ]; |
| 64 | 64 | |
| 65 | - private $inheritance = [ AbstractPlugin::class ]; |
|
| 65 | + private $inheritance = [AbstractPlugin::class]; |
|
| 66 | 66 | |
| 67 | 67 | public function propertiesProvider() |
| 68 | 68 | { |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | ->disableOriginalConstructor() |
| 108 | 108 | ->getMock(); |
| 109 | 109 | |
| 110 | - return [ $auth ]; |
|
| 110 | + return [$auth]; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | private function getComplexAuthMock() |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | $auth->expects($this->any())->method('getUser')->willReturn(new User()); |
| 134 | 134 | |
| 135 | - return [ $auth ]; |
|
| 135 | + return [$auth]; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | public function testInvokationProxiesToCorrectMethods() |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | public function returnReferenceProvider() |
| 150 | 150 | { |
| 151 | 151 | return [ |
| 152 | - [ null ], [ 'some/ref/uri' ], |
|
| 152 | + [null], ['some/ref/uri'], |
|
| 153 | 153 | ]; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $session = new Container(UserSwitcher::SESSION_NAMESPACE); |
| 164 | 164 | $session->isSwitchedUser = true; |
| 165 | 165 | $session->originalUser = 'switchedUser'; |
| 166 | - $oldSession = [ |
|
| 166 | + $oldSession = [ |
|
| 167 | 167 | 'oldSession' => true, |
| 168 | 168 | 'must' => 'be same' |
| 169 | 169 | ]; |
@@ -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 | } |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function setUp() |
| 23 | 23 | { |
| 24 | - $logDir = __DIR__ . '/../../../../../log/'; |
|
| 25 | - $errorLogFile = $logDir . 'error.log'; |
|
| 26 | - $yawikLogFile = $logDir . 'yawik.log'; |
|
| 24 | + $logDir = __DIR__.'/../../../../../log/'; |
|
| 25 | + $errorLogFile = $logDir.'error.log'; |
|
| 26 | + $yawikLogFile = $logDir.'yawik.log'; |
|
| 27 | 27 | |
| 28 | 28 | if ((file_exists($errorLogFile) && !is_writable($errorLogFile)) |
| 29 | 29 | || (file_exists($yawikLogFile) && !is_writable($yawikLogFile)) |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | ->getMock(); |
| 40 | 40 | $this->repositoriesMock->expects($this->any())->method('get') |
| 41 | 41 | ->will($this->returnValueMap([ |
| 42 | - [ 'Organizations/OrganizationImage', $orgImageRepo ] |
|
| 42 | + ['Organizations/OrganizationImage', $orgImageRepo] |
|
| 43 | 43 | ])); |
| 44 | 44 | |
| 45 | 45 | $manager = $this->getMockBuilder(Manager::class) |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | ; |
| 49 | 49 | $hybridAuth = $this->getMockBuilder(\Hybrid_Auth::class)->disableOriginalConstructor()->getMock(); |
| 50 | 50 | $this->setMockToServiceLocator('repositories', $this->repositoriesMock); |
| 51 | - $this->setMockToServiceLocator('Organizations\ImageFileCache\Manager',$manager); |
|
| 51 | + $this->setMockToServiceLocator('Organizations\ImageFileCache\Manager', $manager); |
|
| 52 | 52 | $this->setMockToServiceLocator('HybridAuth', $hybridAuth); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | public function assertResponseStatusCode($code) |
| 102 | 102 | { |
| 103 | 103 | if ($this->useConsoleRequest) { |
| 104 | - if (! in_array($code, [0, 1])) { |
|
| 104 | + if (!in_array($code, [0, 1])) { |
|
| 105 | 105 | throw new \PHPUnit_Framework_ExpectationFailedException($this->createFailureMessage( |
| 106 | 106 | 'Console status code assert value must be O (valid) or 1 (error)' |
| 107 | 107 | )); |
@@ -242,10 +242,10 @@ |
||
| 242 | 242 | public function provideGetDisplayNameTestData() |
| 243 | 243 | { |
| 244 | 244 | return array( |
| 245 | - array(null, null, "[email protected]", "[email protected]"), |
|
| 245 | + array(null, null, "[email protected]", "[email protected]"), |
|
| 246 | 246 | array(" Carsten ", " Bleek ", "[email protected]", "Carsten Bleek"), |
| 247 | - array(null, " Bleek ", "[email protected]", "Bleek"), |
|
| 248 | - array(" Carsten ", null, "[email protected]", "[email protected]"), |
|
| 247 | + array(null, " Bleek ", "[email protected]", "Bleek"), |
|
| 248 | + array(" Carsten ", null, "[email protected]", "[email protected]"), |
|
| 249 | 249 | ); |
| 250 | 250 | } |
| 251 | 251 | |
@@ -83,9 +83,9 @@ |
||
| 83 | 83 | */ |
| 84 | 84 | public function testGetId() |
| 85 | 85 | { |
| 86 | - $this->assertEquals('token:' . $this->target->getToken(), $this->target->getId()); |
|
| 86 | + $this->assertEquals('token:'.$this->target->getToken(), $this->target->getId()); |
|
| 87 | 87 | |
| 88 | - $id=uniqid(); |
|
| 88 | + $id = uniqid(); |
|
| 89 | 89 | $this->target->setId($id); |
| 90 | 90 | $this->assertEquals($id, $this->target->getId()); |
| 91 | 91 | } |