@@ -31,6 +31,9 @@ discard block |
||
| 31 | 31 | $this->adapter = $adapter; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | + /** |
|
| 35 | + * @param string $id |
|
| 36 | + */ |
|
| 34 | 37 | public function get($id) |
| 35 | 38 | { |
| 36 | 39 | return $this->select(['admin_user_id' => $id])->current(); |
@@ -40,7 +43,7 @@ discard block |
||
| 40 | 43 | * Get admin user by email. |
| 41 | 44 | * |
| 42 | 45 | * @param string $email email |
| 43 | - * @return array|\ArrayObject|null |
|
| 46 | + * @return string |
|
| 44 | 47 | */ |
| 45 | 48 | public function getByEmail(string $email) |
| 46 | 49 | { |
@@ -50,7 +53,6 @@ discard block |
||
| 50 | 53 | /** |
| 51 | 54 | * Updates login data. |
| 52 | 55 | * |
| 53 | - * @param string $uuid admin user id |
|
| 54 | 56 | * @return int number of affected rows |
| 55 | 57 | */ |
| 56 | 58 | public function updateLogin(string $userId): int |
@@ -58,6 +60,11 @@ discard block |
||
| 58 | 60 | return $this->update(['last_login' => date('Y-m-d H:i:s')], ['admin_user_id' => $userId]); |
| 59 | 61 | } |
| 60 | 62 | |
| 63 | + /** |
|
| 64 | + * @param string $userId |
|
| 65 | + * |
|
| 66 | + * @return \Zend\Db\Sql\Select |
|
| 67 | + */ |
|
| 61 | 68 | public function getPaginationSelect($userId) |
| 62 | 69 | { |
| 63 | 70 | $select = $this->getSql()->select()->order(['created_at' => 'desc']); |
@@ -67,6 +74,9 @@ discard block |
||
| 67 | 74 | return $select; |
| 68 | 75 | } |
| 69 | 76 | |
| 77 | + /** |
|
| 78 | + * @param integer $limit |
|
| 79 | + */ |
|
| 70 | 80 | public function getRandom($limit) |
| 71 | 81 | { |
| 72 | 82 | $select = $this->getSql()->select() |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Admin\Mapper; |
| 5 | 5 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function get($id) |
| 35 | 35 | { |
| 36 | - return $this->select(['admin_user_id' => $id])->current(); |
|
| 36 | + return $this->select([ 'admin_user_id' => $id ])->current(); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function getByEmail(string $email) |
| 46 | 46 | { |
| 47 | - return $this->select(['email' => $email])->current(); |
|
| 47 | + return $this->select([ 'email' => $email ])->current(); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function updateLogin(string $userId): int |
| 57 | 57 | { |
| 58 | - return $this->update(['last_login' => date('Y-m-d H:i:s')], ['admin_user_id' => $userId]); |
|
| 58 | + return $this->update([ 'last_login' => date('Y-m-d H:i:s') ], [ 'admin_user_id' => $userId ]); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function getPaginationSelect($userId) |
| 62 | 62 | { |
| 63 | - $select = $this->getSql()->select()->order(['created_at' => 'desc']); |
|
| 63 | + $select = $this->getSql()->select()->order([ 'created_at' => 'desc' ]); |
|
| 64 | 64 | |
| 65 | 65 | $select->where->notEqualTo('admin_user_id', $userId); |
| 66 | 66 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function getRandom($limit) |
| 71 | 71 | { |
| 72 | 72 | $select = $this->getSql()->select() |
| 73 | - ->where(['status' => 1]) |
|
| 73 | + ->where([ 'status' => 1 ]) |
|
| 74 | 74 | ->order(new Expression('rand()')) |
| 75 | 75 | ->limit($limit); |
| 76 | 76 | |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public function getUuid($adminUserId) |
| 81 | 81 | { |
| 82 | - $user = $this->select(['admin_user_id' => $adminUserId])->current(); |
|
| 82 | + $user = $this->select([ 'admin_user_id' => $adminUserId ])->current(); |
|
| 83 | 83 | |
| 84 | - if(!$user) { |
|
| 84 | + if (!$user) { |
|
| 85 | 85 | throw new \Exception('Admin user does not exist!', 400); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Core\Service; |
| 5 | 5 | |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function __invoke(ContainerInterface $container): MeetupApiService |
| 17 | 17 | { |
| 18 | - $config = $container->get('config')['meetupApi']; |
|
| 18 | + $config = $container->get('config')[ 'meetupApi' ]; |
|
| 19 | 19 | |
| 20 | - return new MeetupApiService($config['key']); |
|
| 20 | + return new MeetupApiService($config[ 'key' ]); |
|
| 21 | 21 | } |
| 22 | 22 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Web\Action; |
| 6 | 6 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | $page = $this->pageService->getHomepage(); |
| 60 | 60 | |
| 61 | - return new HtmlResponse($this->template->render('web::home', ['page' => $page, 'layout' => 'layout/web'])); |
|
| 61 | + return new HtmlResponse($this->template->render('web::home', [ 'page' => $page, 'layout' => 'layout/web' ])); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Admin\Service; |
| 6 | 6 | |
@@ -81,17 +81,17 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function loginUser($email, $password) |
| 83 | 83 | { |
| 84 | - if(!$email || !$password) { |
|
| 84 | + if (!$email || !$password) { |
|
| 85 | 85 | throw new \Exception('Both email and password are required.', 400); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $user = $this->adminUsersMapper->getByEmail($email); |
| 89 | 89 | |
| 90 | - if(!$user) { |
|
| 90 | + if (!$user) { |
|
| 91 | 91 | throw new \Exception('User does not exist.'); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if(!$this->crypt->verify($password, $user->password)) { |
|
| 94 | + if (!$this->crypt->verify($password, $user->password)) { |
|
| 95 | 95 | throw new \Exception('Password does not match.'); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $filter = $this->adminUserFilter->getInputFilter()->setData($data); |
| 137 | 137 | |
| 138 | - if(!$filter->isValid()) { |
|
| 138 | + if (!$filter->isValid()) { |
|
| 139 | 139 | throw new FilterException($filter->getMessages()); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | 'profile_img' => $this->upload->uploadImage($data, 'profile_img') |
| 145 | 145 | ]; |
| 146 | 146 | |
| 147 | - unset($data['confirm_password']); |
|
| 148 | - $data['password'] = $this->crypt->create($data['password']); |
|
| 149 | - $data['admin_user_id'] = Uuid::uuid1()->toString(); |
|
| 150 | - $data['admin_user_uuid'] = (new MysqlUuid($data['admin_user_id']))->toFormat(new Binary); |
|
| 147 | + unset($data[ 'confirm_password' ]); |
|
| 148 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); |
|
| 149 | + $data[ 'admin_user_id' ] = Uuid::uuid1()->toString(); |
|
| 150 | + $data[ 'admin_user_uuid' ] = (new MysqlUuid($data[ 'admin_user_id' ]))->toFormat(new Binary); |
|
| 151 | 151 | |
| 152 | 152 | return $this->adminUsersMapper->insert($data); |
| 153 | 153 | } |
@@ -161,17 +161,17 @@ discard block |
||
| 161 | 161 | $filter = $this->adminUserFilter->getInputFilter()->setData($data); |
| 162 | 162 | |
| 163 | 163 | // we dont want to force user to enter the password again |
| 164 | - if($data['password'] == '') { |
|
| 164 | + if ($data[ 'password' ] == '') { |
|
| 165 | 165 | $filter->remove('password'); |
| 166 | 166 | $filter->remove('confirm_password'); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // if we want to keep same email |
| 170 | - if($user->email == $data['email']) { |
|
| 170 | + if ($user->email == $data[ 'email' ]) { |
|
| 171 | 171 | $filter->remove('email'); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if(!$filter->isValid()) { |
|
| 174 | + if (!$filter->isValid()) { |
|
| 175 | 175 | throw new FilterException($filter->getMessages()); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -181,26 +181,26 @@ discard block |
||
| 181 | 181 | ]; |
| 182 | 182 | |
| 183 | 183 | // We don't want to force user to re-upload image on edit |
| 184 | - if(!$data['face_img']) { |
|
| 185 | - unset($data['face_img']); |
|
| 184 | + if (!$data[ 'face_img' ]) { |
|
| 185 | + unset($data[ 'face_img' ]); |
|
| 186 | 186 | } |
| 187 | - else{ |
|
| 187 | + else { |
|
| 188 | 188 | $this->upload->deleteFile($user->face_img); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if(!$data['profile_img']) { |
|
| 192 | - unset($data['profile_img']); |
|
| 191 | + if (!$data[ 'profile_img' ]) { |
|
| 192 | + unset($data[ 'profile_img' ]); |
|
| 193 | 193 | } |
| 194 | - else{ |
|
| 194 | + else { |
|
| 195 | 195 | $this->upload->deleteFile($user->profile_img); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if(isset($data['password'])) { |
|
| 199 | - unset($data['confirm_password']); |
|
| 200 | - $data['password'] = $this->crypt->create($data['password']); |
|
| 198 | + if (isset($data[ 'password' ])) { |
|
| 199 | + unset($data[ 'confirm_password' ]); |
|
| 200 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - return $this->adminUsersMapper->update($data, ['admin_user_id' => $userId]); |
|
| 203 | + return $this->adminUsersMapper->update($data, [ 'admin_user_id' => $userId ]); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -212,14 +212,14 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public function delete($userId) |
| 214 | 214 | { |
| 215 | - if(!($adminUser = $this->getUser($userId))) { |
|
| 215 | + if (!($adminUser = $this->getUser($userId))) { |
|
| 216 | 216 | throw new \Exception('Admin user not found.'); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | $this->upload->deleteFile($adminUser->face_img); |
| 220 | 220 | $this->upload->deleteFile($adminUser->profile_img); |
| 221 | 221 | |
| 222 | - return (bool)$this->adminUsersMapper->delete(['admin_user_id' => $userId]); |
|
| 222 | + return (bool) $this->adminUsersMapper->delete([ 'admin_user_id' => $userId ]); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | 'admin/pagination' => __DIR__ . '/../templates/admin/partial/pagination.phtml', |
| 14 | 14 | ], |
| 15 | 15 | 'paths' => [ |
| 16 | - 'admin' => [__DIR__ . '/../templates/admin'], |
|
| 16 | + 'admin' => [ __DIR__ . '/../templates/admin' ], |
|
| 17 | 17 | ], |
| 18 | 18 | ], |
| 19 | 19 | |
@@ -37,25 +37,25 @@ discard block |
||
| 37 | 37 | 'name' => 'auth', |
| 38 | 38 | 'path' => '/auth/:action', |
| 39 | 39 | 'middleware' => Controller\AuthController::class, |
| 40 | - 'allowed_methods' => ['GET', 'POST'], |
|
| 40 | + 'allowed_methods' => [ 'GET', 'POST' ], |
|
| 41 | 41 | ], |
| 42 | 42 | [ |
| 43 | 43 | 'name' => 'admin', |
| 44 | 44 | 'path' => '/admin', |
| 45 | 45 | 'middleware' => Action\IndexAction::class, |
| 46 | - 'allowed_methods' => ['GET'], |
|
| 46 | + 'allowed_methods' => [ 'GET' ], |
|
| 47 | 47 | ], |
| 48 | 48 | [ |
| 49 | 49 | 'name' => 'admin.users', |
| 50 | 50 | 'path' => '/admin/users', |
| 51 | 51 | 'middleware' => Controller\UserController::class, |
| 52 | - 'allowed_methods' => ['GET'] |
|
| 52 | + 'allowed_methods' => [ 'GET' ] |
|
| 53 | 53 | ], |
| 54 | 54 | [ |
| 55 | 55 | 'name' => 'admin.users.action', |
| 56 | 56 | 'path' => '/admin/users/:action/:id', |
| 57 | 57 | 'middleware' => Controller\UserController::class, |
| 58 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 58 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 59 | 59 | ], |
| 60 | 60 | ], |
| 61 | 61 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | 'middleware_pipeline' => [ |
| 70 | 70 | // execute this middleware on every /admin[*] path |
| 71 | 71 | 'permission' => [ |
| 72 | - 'middleware' => [Middleware\AdminAuth::class], |
|
| 72 | + 'middleware' => [ Middleware\AdminAuth::class ], |
|
| 73 | 73 | 'priority' => 100, |
| 74 | 74 | 'path' => '/admin' |
| 75 | 75 | ], |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Admin\Factory\Service; |
| 6 | 6 | |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __invoke(ContainerInterface $container): AdminUserService |
| 23 | 23 | { |
| 24 | - $config = $container->get('config')['upload']; |
|
| 25 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
| 24 | + $config = $container->get('config')[ 'upload' ]; |
|
| 25 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
| 26 | 26 | |
| 27 | 27 | return new AdminUserService( |
| 28 | 28 | new Bcrypt(), |
@@ -15,13 +15,13 @@ discard block |
||
| 15 | 15 | $request = $request->withAttribute('action', 'login'); |
| 16 | 16 | $response = new \Zend\Diactoros\Response\EmptyResponse(); |
| 17 | 17 | $router = $this->getMockBuilder('Zend\Expressive\Router\RouterInterface') |
| 18 | - ->setMethods(['generateUri']) |
|
| 18 | + ->setMethods([ 'generateUri' ]) |
|
| 19 | 19 | ->getMockForAbstractClass(); |
| 20 | 20 | $router->expects(static::at(0)) |
| 21 | 21 | ->method('generateUri') |
| 22 | 22 | ->will(static::returnValue('http://unfinished.dev/admin')); |
| 23 | 23 | $sessionManager = $this->getMockBuilder('Zend\Session\SessionManager') |
| 24 | - ->setMethods(['getStorage', 'writeClose']) |
|
| 24 | + ->setMethods([ 'getStorage', 'writeClose' ]) |
|
| 25 | 25 | ->getMock(); |
| 26 | 26 | $sessionManager->expects(static::at(0)) |
| 27 | 27 | ->method('getStorage') |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** @var \Zend\Diactoros\Response\EmptyResponse $response */ |
| 35 | 35 | $response = $auth($request, $response); |
| 36 | 36 | static::assertSame(302, $response->getStatusCode()); |
| 37 | - static::assertSame(['http://unfinished.dev/admin'], $response->getHeader('Location')); |
|
| 37 | + static::assertSame([ 'http://unfinished.dev/admin' ], $response->getHeader('Location')); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function testIfUserNotLoggedInLoginActionShouldTakeHimToLoginHtmlPage() |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | ->disableOriginalConstructor() |
| 44 | 44 | ->getMockForAbstractClass(); |
| 45 | 45 | $template = $this->getMockBuilder('Zend\Expressive\Template\TemplateRendererInterface') |
| 46 | - ->setMethods(['render']) |
|
| 46 | + ->setMethods([ 'render' ]) |
|
| 47 | 47 | ->getMockForAbstractClass(); |
| 48 | 48 | $template->expects(static::at(0)) |
| 49 | 49 | ->method('render') |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $router = $this->getMockBuilder('Zend\Expressive\Router\RouterInterface') |
| 55 | 55 | ->getMockForAbstractClass(); |
| 56 | 56 | $sessionManager = $this->getMockBuilder('Zend\Session\SessionManager') |
| 57 | - ->setMethods(['getStorage', 'writeClose']) |
|
| 57 | + ->setMethods([ 'getStorage', 'writeClose' ]) |
|
| 58 | 58 | ->getMock(); |
| 59 | 59 | $sessionManager->expects(static::at(0)) |
| 60 | 60 | ->method('getStorage') |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $request = $request->withAttribute('action', 'logout'); |
| 82 | 82 | $response = new \Zend\Diactoros\Response\EmptyResponse(); |
| 83 | 83 | $router = $this->getMockBuilder('Zend\Expressive\Router\RouterInterface') |
| 84 | - ->setMethods(['generateUri']) |
|
| 84 | + ->setMethods([ 'generateUri' ]) |
|
| 85 | 85 | ->getMockForAbstractClass(); |
| 86 | 86 | $router->expects(static::at(0)) |
| 87 | 87 | ->method('generateUri') |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | $response = $auth($request, $response); |
| 97 | 97 | static::assertNull($sessionManager->getStorage()->user); |
| 98 | 98 | static::assertSame(302, $response->getStatusCode()); |
| 99 | - static::assertSame(['http://unfinished.dev/admin'], $response->getHeader('Location')); |
|
| 99 | + static::assertSame([ 'http://unfinished.dev/admin' ], $response->getHeader('Location')); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | public function testUserLoginHandleWithCorrectCredentialsShouldSetUserInSessionStorage() |
| 103 | 103 | { |
| 104 | 104 | $adminUserService = $this->getMockBuilder('Core\Service\AdminUserService.old') |
| 105 | 105 | ->disableOriginalConstructor() |
| 106 | - ->setMethods(['loginUser']) |
|
| 106 | + ->setMethods([ 'loginUser' ]) |
|
| 107 | 107 | ->getMockForAbstractClass(); |
| 108 | 108 | $adminUserService->expects(static::once()) |
| 109 | 109 | ->method('loginUser') |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $request = $request->withAttribute('action', 'loginHandle'); |
| 123 | 123 | $response = new \Zend\Diactoros\Response\EmptyResponse(); |
| 124 | 124 | $router = $this->getMockBuilder('Zend\Expressive\Router\RouterInterface') |
| 125 | - ->setMethods(['generateUri']) |
|
| 125 | + ->setMethods([ 'generateUri' ]) |
|
| 126 | 126 | ->getMockForAbstractClass(); |
| 127 | 127 | $router->expects(static::at(0)) |
| 128 | 128 | ->method('generateUri') |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | $response = $auth($request, $response); |
| 136 | 136 | static::assertTrue($sessionManager->getStorage()->user->isLoggedIn); |
| 137 | 137 | static::assertSame(302, $response->getStatusCode()); |
| 138 | - static::assertSame(['http://unfinished.dev/admin'], $response->getHeader('Location')); |
|
| 138 | + static::assertSame([ 'http://unfinished.dev/admin' ], $response->getHeader('Location')); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | public function testUserLoginHandleWithWrongCredentialsShouldNotSetUserInSessionStorage() |
| 142 | 142 | { |
| 143 | 143 | $adminUserService = $this->getMockBuilder('Core\Service\AdminUserService.old') |
| 144 | 144 | ->disableOriginalConstructor() |
| 145 | - ->setMethods(['loginUser']) |
|
| 145 | + ->setMethods([ 'loginUser' ]) |
|
| 146 | 146 | ->getMockForAbstractClass(); |
| 147 | 147 | $template = $this->getMockBuilder('Zend\Expressive\Template\TemplateRendererInterface') |
| 148 | 148 | ->getMockForAbstractClass(); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $request = $request->withAttribute('action', 'loginHandle'); |
| 155 | 155 | $response = new \Zend\Diactoros\Response\EmptyResponse(); |
| 156 | 156 | $router = $this->getMockBuilder('Zend\Expressive\Router\RouterInterface') |
| 157 | - ->setMethods(['generateUri']) |
|
| 157 | + ->setMethods([ 'generateUri' ]) |
|
| 158 | 158 | ->getMockForAbstractClass(); |
| 159 | 159 | $router->expects(static::at(0)) |
| 160 | 160 | ->method('generateUri') |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $response = $auth($request, $response); |
| 169 | 169 | static::assertNull($sessionManager->getStorage()->user); |
| 170 | 170 | static::assertSame(302, $response->getStatusCode()); |
| 171 | - static::assertSame(['http://unfinished.dev/admin'], $response->getHeader('Location')); |
|
| 171 | + static::assertSame([ 'http://unfinished.dev/admin' ], $response->getHeader('Location')); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | public function testUserLoginHandleWitAlreadyLoggedInUserShouldRedirectToAdminPage() |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $request = $request->withAttribute('action', 'loginHandle'); |
| 183 | 183 | $response = new \Zend\Diactoros\Response\EmptyResponse(); |
| 184 | 184 | $router = $this->getMockBuilder('Zend\Expressive\Router\RouterInterface') |
| 185 | - ->setMethods(['generateUri']) |
|
| 185 | + ->setMethods([ 'generateUri' ]) |
|
| 186 | 186 | ->getMockForAbstractClass(); |
| 187 | 187 | $router->expects(static::at(0)) |
| 188 | 188 | ->method('generateUri') |
@@ -196,14 +196,14 @@ discard block |
||
| 196 | 196 | /** @var \Zend\Diactoros\Response\HtmlResponse $response */ |
| 197 | 197 | $response = $auth($request, $response); |
| 198 | 198 | static::assertSame(302, $response->getStatusCode()); |
| 199 | - static::assertSame(['http://unfinished.dev/admin'], $response->getHeader('Location')); |
|
| 199 | + static::assertSame([ 'http://unfinished.dev/admin' ], $response->getHeader('Location')); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function testUserLoginHandleShouldThrowExceptionAndDisplayMessage() |
| 203 | 203 | { |
| 204 | 204 | $adminUserService = $this->getMockBuilder('Core\Service\AdminUserService.old') |
| 205 | 205 | ->disableOriginalConstructor() |
| 206 | - ->setMethods(['loginUser']) |
|
| 206 | + ->setMethods([ 'loginUser' ]) |
|
| 207 | 207 | ->getMockForAbstractClass(); |
| 208 | 208 | $adminUserService->expects(static::once()) |
| 209 | 209 | ->method('loginUser') |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | ->method('render') |
| 215 | 215 | ->will(static::returnCallback( |
| 216 | 216 | function($tpl, $error) { |
| 217 | - return $error['error']; |
|
| 217 | + return $error[ 'error' ]; |
|
| 218 | 218 | } |
| 219 | 219 | )); |
| 220 | 220 | $request = new \Zend\Diactoros\ServerRequest(); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | $sessionStorage = new \Zend\Session\Storage\ArrayStorage(); |
| 14 | 14 | $sessionStorage->user = $user; |
| 15 | 15 | $template = $this->getMockBuilder(\Zend\Expressive\Template\TemplateRendererInterface::class) |
| 16 | - ->setMethods(['render']) |
|
| 16 | + ->setMethods([ 'render' ]) |
|
| 17 | 17 | ->getMockForAbstractClass(); |
| 18 | 18 | $template->expects(static::once()) |
| 19 | 19 | ->method('render') |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | ->getMock(); |
| 24 | 24 | $sessionManager = $this->getMockBuilder(\Zend\Session\SessionManager::class) |
| 25 | 25 | ->disableOriginalConstructor() |
| 26 | - ->setMethods(['getStorage']) |
|
| 26 | + ->setMethods([ 'getStorage' ]) |
|
| 27 | 27 | ->getMock(); |
| 28 | 28 | $sessionManager->expects(static::any()) |
| 29 | 29 | ->method('getStorage') |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | $sessionStorage = new \Zend\Session\Storage\ArrayStorage(); |
| 50 | 50 | $sessionStorage->user = $user; |
| 51 | 51 | $template = $this->getMockBuilder(\Zend\Expressive\Template\TemplateRendererInterface::class) |
| 52 | - ->setMethods(['render']) |
|
| 52 | + ->setMethods([ 'render' ]) |
|
| 53 | 53 | ->getMockForAbstractClass(); |
| 54 | 54 | $template->expects(static::once()) |
| 55 | 55 | ->method('render') |
| 56 | 56 | ->will(static::returnValue('test')); |
| 57 | 57 | $adminUserService = $this->getMockBuilder(\Admin\Service\AdminUserService::class) |
| 58 | 58 | ->disableOriginalConstructor() |
| 59 | - ->setMethods(['getUser']) |
|
| 59 | + ->setMethods([ 'getUser' ]) |
|
| 60 | 60 | ->getMock(); |
| 61 | 61 | $adminUserService->expects(static::once()) |
| 62 | 62 | ->method('getUser') |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | $sessionStorage = new \Zend\Session\Storage\ArrayStorage(); |
| 87 | 87 | $sessionStorage->user = $user; |
| 88 | 88 | $template = $this->getMockBuilder(\Zend\Expressive\Template\TemplateRendererInterface::class) |
| 89 | - ->setMethods(['render']) |
|
| 89 | + ->setMethods([ 'render' ]) |
|
| 90 | 90 | ->getMockForAbstractClass(); |
| 91 | 91 | $template->expects(static::once()) |
| 92 | 92 | ->method('render') |
| 93 | 93 | ->will(static::returnValue('test')); |
| 94 | 94 | $adminUserService = $this->getMockBuilder(\Admin\Service\AdminUserService::class) |
| 95 | 95 | ->disableOriginalConstructor() |
| 96 | - ->setMethods(['getUser']) |
|
| 96 | + ->setMethods([ 'getUser' ]) |
|
| 97 | 97 | ->getMock(); |
| 98 | 98 | $adminUserService->expects(static::once()) |
| 99 | 99 | ->method('getUser') |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $request = new \Zend\Diactoros\ServerRequest(); |
| 107 | 107 | $request = $request->withAttribute('action', 'edit'); |
| 108 | 108 | $request = $request->withAttribute('id', 1); |
| 109 | - $request = $request->withParsedBody(['user' => 'test']); |
|
| 109 | + $request = $request->withParsedBody([ 'user' => 'test' ]); |
|
| 110 | 110 | $response = new \Zend\Diactoros\Response(); |
| 111 | 111 | $userController = new \Admin\Controller\UserController( |
| 112 | 112 | $template, |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | ->will(static::returnValue('http://unfinished.dev/admin/users')); |
| 139 | 139 | $request = new \Zend\Diactoros\ServerRequest(); |
| 140 | 140 | $request = $request->withAttribute('action', 'save'); |
| 141 | - $request = $request->withParsedBody(['user' => 'test']); |
|
| 141 | + $request = $request->withParsedBody([ 'user' => 'test' ]); |
|
| 142 | 142 | $response = new \Zend\Diactoros\Response(); |
| 143 | 143 | $userController = new \Admin\Controller\UserController( |
| 144 | 144 | $template, |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $request = new \Zend\Diactoros\ServerRequest(); |
| 178 | 178 | $request = $request->withAttribute('action', 'save'); |
| 179 | 179 | $request = $request->withAttribute('id', 2); |
| 180 | - $request = $request->withParsedBody(['user' => 'test']); |
|
| 180 | + $request = $request->withParsedBody([ 'user' => 'test' ]); |
|
| 181 | 181 | $response = new \Zend\Diactoros\Response(); |
| 182 | 182 | $userController = new \Admin\Controller\UserController( |
| 183 | 183 | $template, |
@@ -215,11 +215,11 @@ discard block |
||
| 215 | 215 | ->getMockForAbstractClass(); |
| 216 | 216 | $router->expects(static::at(0)) |
| 217 | 217 | ->method('generateUri') |
| 218 | - ->willThrowException(new \Core\Exception\FilterException(['test error'])); |
|
| 218 | + ->willThrowException(new \Core\Exception\FilterException([ 'test error' ])); |
|
| 219 | 219 | $request = new \Zend\Diactoros\ServerRequest(); |
| 220 | 220 | $request = $request->withAttribute('action', 'save'); |
| 221 | 221 | $request = $request->withAttribute('id', 2); |
| 222 | - $request = $request->withParsedBody(['user' => 'test']); |
|
| 222 | + $request = $request->withParsedBody([ 'user' => 'test' ]); |
|
| 223 | 223 | $response = new \Zend\Diactoros\Response(); |
| 224 | 224 | $userController = new \Admin\Controller\UserController( |
| 225 | 225 | $template, |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | ->willThrowException(new \Exception('test error')); |
| 263 | 263 | $request = new \Zend\Diactoros\ServerRequest(); |
| 264 | 264 | $request = $request->withAttribute('action', 'save'); |
| 265 | - $request = $request->withParsedBody(['user' => 'test']); |
|
| 265 | + $request = $request->withParsedBody([ 'user' => 'test' ]); |
|
| 266 | 266 | $response = new \Zend\Diactoros\Response(); |
| 267 | 267 | $userController = new \Admin\Controller\UserController( |
| 268 | 268 | $template, |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | $template = $this->getMockBuilder(\Zend\Expressive\Template\TemplateRendererInterface::class) |
| 321 | 321 | ->getMockForAbstractClass(); |
| 322 | 322 | $adminUserService = $this->getMockBuilder(\Admin\Service\AdminUserService::class) |
| 323 | - ->setMethods(['delete']) |
|
| 323 | + ->setMethods([ 'delete' ]) |
|
| 324 | 324 | ->disableOriginalConstructor() |
| 325 | 325 | ->getMock(); |
| 326 | 326 | $adminUserService->expects(static::once()) |
@@ -16,13 +16,13 @@ |
||
| 16 | 16 | public function testGetRandomShouldReturnArray() |
| 17 | 17 | { |
| 18 | 18 | $adminUserService = $this->getMockBuilder('Core\Service\AdminUserService.old') |
| 19 | - ->setMethods(['getForWeb']) |
|
| 19 | + ->setMethods([ 'getForWeb' ]) |
|
| 20 | 20 | ->disableOriginalConstructor() |
| 21 | 21 | ->getMockForAbstractClass(); |
| 22 | 22 | $adminUserService->expects(static::once()) |
| 23 | 23 | ->method('getForWeb') |
| 24 | - ->willReturn([]); |
|
| 24 | + ->willReturn([ ]); |
|
| 25 | 25 | $adminUserHelper = new \Admin\View\Helper\WebAdminUserHelper($adminUserService); |
| 26 | - static::assertSame([], $adminUserHelper->getRandom()); |
|
| 26 | + static::assertSame([ ], $adminUserHelper->getRandom()); |
|
| 27 | 27 | } |
| 28 | 28 | } |