@@ -39,14 +39,14 @@ |
||
39 | 39 | |
40 | 40 | |
41 | 41 | if (!$user) { |
42 | - return response()->json(['error' => 'Unauthorized user.'], 401); |
|
42 | + return response()->json([ 'error' => 'Unauthorized user.' ], 401); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | \Auth::login($user); |
46 | 46 | } catch (InvalidTokenException $e) { |
47 | - return response()->json(['error' => 'Invalid or no token set.'], 401); |
|
47 | + return response()->json([ 'error' => 'Invalid or no token set.' ], 401); |
|
48 | 48 | } catch (CoreException $e) { |
49 | - return response()->json(['error' => $e->getMessage()], 401); |
|
49 | + return response()->json([ 'error' => $e->getMessage() ], 401); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | return $next($request); |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | |
45 | 45 | private function getUserTokenData(): \stdClass |
46 | 46 | { |
47 | - return Cache::remember('testing:http_access_token', 60, function () { |
|
47 | + return Cache::remember('testing:http_access_token', 60, function() { |
|
48 | 48 | try { |
49 | 49 | $httpClient = new Client(); |
50 | - $response = $httpClient->post(env('AUTH0_DOMAIN') . 'oauth/token', [ |
|
50 | + $response = $httpClient->post(env('AUTH0_DOMAIN').'oauth/token', [ |
|
51 | 51 | 'form_params' => [ |
52 | 52 | 'grant_type' => 'password', |
53 | 53 | 'client_id' => env('AUTH0_CLIENT_ID'), |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ]); |
59 | 59 | return json_decode($response->getBody()->getContents()); |
60 | 60 | } catch (ClientException $exception) { |
61 | - throw new Exception("Could not obtain token from Auth0 at " . env('AUTH0_DOMAIN') . " for testing."); |
|
61 | + throw new Exception("Could not obtain token from Auth0 at ".env('AUTH0_DOMAIN')." for testing."); |
|
62 | 62 | } |
63 | 63 | }); |
64 | 64 | } |
@@ -66,30 +66,30 @@ discard block |
||
66 | 66 | protected function decodeHttpContent($content, $unwrap = true) |
67 | 67 | { |
68 | 68 | if ($unwrap) |
69 | - return json_decode($content, true)['data']; |
|
69 | + return json_decode($content, true)[ 'data' ]; |
|
70 | 70 | return json_decode($content, true); |
71 | 71 | } |
72 | 72 | |
73 | - protected function http(string $method, string $route, array $payload = []) |
|
73 | + protected function http(string $method, string $route, array $payload = [ ]) |
|
74 | 74 | { |
75 | 75 | return $this->sendRequest($method, $route, $payload, true); |
76 | 76 | } |
77 | 77 | |
78 | - private function sendRequest(string $method, string $route, array $payload = [], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
78 | + private function sendRequest(string $method, string $route, array $payload = [ ], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
79 | 79 | { |
80 | - return $this->json($method, env('API_URL') . '/' . $route, $payload, $authenticated ? [ |
|
81 | - 'Authorization' => 'Bearer ' . $this->getUserTokenData()->id_token, |
|
82 | - ] : []); |
|
80 | + return $this->json($method, env('API_URL').'/'.$route, $payload, $authenticated ? [ |
|
81 | + 'Authorization' => 'Bearer '.$this->getUserTokenData()->id_token, |
|
82 | + ] : [ ]); |
|
83 | 83 | } |
84 | 84 | |
85 | - protected function sendRequestWithToken($token, string $method, string $route, array $payload = [], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
85 | + protected function sendRequestWithToken($token, string $method, string $route, array $payload = [ ], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
86 | 86 | { |
87 | - return $this->json($method, env('API_URL') . '/' . $route, $payload, $authenticated ? [ |
|
88 | - 'Authorization' => 'Bearer ' . $token, |
|
89 | - ] : []); |
|
87 | + return $this->json($method, env('API_URL').'/'.$route, $payload, $authenticated ? [ |
|
88 | + 'Authorization' => 'Bearer '.$token, |
|
89 | + ] : [ ]); |
|
90 | 90 | } |
91 | 91 | |
92 | - protected function httpNoAuth(string $method, string $route, array $payload = []) |
|
92 | + protected function httpNoAuth(string $method, string $route, array $payload = [ ]) |
|
93 | 93 | { |
94 | 94 | return $this->sendRequest($method, $route, $payload, false); |
95 | 95 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | public function getUserByUserInfo($userInfo) |
45 | 45 | { |
46 | - return $this->upsertUser($userInfo['profile']); |
|
46 | + return $this->upsertUser($userInfo[ 'profile' ]); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | protected function upsertUser($profile) |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | throw new BadRequestHttpException('Missing token information: Auth0 user id is not set'); |
53 | 53 | } |
54 | 54 | $identifier = explode('|', $profile->user_id); |
55 | - $identityProvider = $identifier[0]; |
|
56 | - $id = $identifier[1]; |
|
55 | + $identityProvider = $identifier[ 0 ]; |
|
56 | + $id = $identifier[ 1 ]; |
|
57 | 57 | |
58 | 58 | $user = $this->service->find($id); |
59 | 59 | $newUser = false; |
@@ -34,7 +34,7 @@ |
||
34 | 34 | |
35 | 35 | public function broadcastOn() |
36 | 36 | { |
37 | - return new PrivateChannel('app.' . $this->user->getKey()); |
|
37 | + return new PrivateChannel('app.'.$this->user->getKey()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | class WebNotificationCreatedEvent extends BroadcastNotificationCreated |
15 | 15 | { |
16 | - public function broadcastAs(){ |
|
16 | + public function broadcastAs() { |
|
17 | 17 | return 'notification.created'; |
18 | 18 | } |
19 | 19 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $this->assertCount(1, $notifications); |
36 | 36 | $notification = $user->unreadNotifications()->first(); |
37 | 37 | $notificationId = $notification->getKey(); |
38 | - $response = $this->http('POST', 'v1/notifications/' . $notificationId); |
|
38 | + $response = $this->http('POST', 'v1/notifications/'.$notificationId); |
|
39 | 39 | $response->assertStatus(200); |
40 | 40 | $unreadnotifications = User::find($user->getKey())->unreadNotifications; |
41 | 41 | $this->assertCount(0, $unreadnotifications); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $response->assertStatus(200); |
51 | 51 | $notificationsReponse = $this->decodeHttpContent($response->getContent()); |
52 | 52 | $notifications = NotificationResource::collection(User::find($user->getKey())->notifications)->jsonSerialize(); |
53 | - $this->assertEquals($notificationsReponse, (array)$notifications); |
|
53 | + $this->assertEquals($notificationsReponse, (array) $notifications); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function testUnreadNotificationsRoute() |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $user->notifyNow(new UserRegisteredNotification($user)); |
60 | 60 | $notification = $user->unreadNotifications()->first(); |
61 | 61 | $notificationId = $notification->getKey(); |
62 | - $response = $this->http('POST', 'v1/notifications/' . $notificationId); |
|
62 | + $response = $this->http('POST', 'v1/notifications/'.$notificationId); |
|
63 | 63 | $response->assertStatus(200); |
64 | 64 | $response = $this->http('GET', 'v1/notifications/unread'); |
65 | 65 | $response->assertStatus(200); |