Passed
Push — main ( c3a0f3...6d7bd8 )
by Slawomir
05:24
created
tests/Modules/Comments/Unit/Repository/InMemoryCommentsRepository.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     public function updatePostHeader(UpdateExistingCommentsPostHeaderDto $updatedPostHeader): void
61 61
     {
62 62
         foreach (self::$postHeaders
63
-                     ->filter(function ($header) use ($updatedPostHeader) {
63
+                     ->filter(function($header) use ($updatedPostHeader) {
64 64
                          return $header->getId() == $updatedPostHeader->getId() && $header->getVersion() <= $updatedPostHeader->getVersion();
65 65
                      })
66 66
                      ->toArray() as $header) {
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     public function deletePostHeader(DeleteExistingCommentsPostHeaderDto $deletedPostHeader): void
75 75
     {
76 76
         self::$postHeaders = self::$postHeaders->filter(
77
-           function ($header) use ($deletedPostHeader) {
77
+           function($header) use ($deletedPostHeader) {
78 78
                 return $header->getId() != $deletedPostHeader->getId();
79 79
             }
80 80
         )->realize();
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
     public function findPostHeaders(?\DateTime $from = null): array
84 84
     {
85 85
         return self::$postHeaders
86
-            ->filter(function ($header) use ($from) {
86
+            ->filter(function($header) use ($from) {
87 87
                 return $from == null || $header->getCreatedAt() >= $from;
88 88
             })
89
-            ->map(function ($header) {
89
+            ->map(function($header) {
90 90
                 return new CommentsPostHeaderDto(
91 91
                     $header->getId(),
92 92
                     $header->getTitle(),
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
         $id = new Ulid();
107 107
         $parentComment = null;
108 108
         if ($newComment->getParentId() != null) {
109
-            $parentComment = self::$comments->find(function ($comment) use ($newComment) {
109
+            $parentComment = self::$comments->find(function($comment) use ($newComment) {
110 110
                 return $comment->getId() == $newComment->getParentId();
111 111
             });
112 112
         }
113
-        $post = self::$postHeaders->find(function ($post) use ($newComment) {
113
+        $post = self::$postHeaders->find(function($post) use ($newComment) {
114 114
             return $post->getId() == $newComment->getPostId();
115 115
         });
116 116
         $comment = new InMemoryComment(
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
     public function getCommentsCount(Ulid $postId): int
132 132
     {
133 133
         return self::$postHeaders
134
-            ->filter(function ($post) use ($postId) {
134
+            ->filter(function($post) use ($postId) {
135 135
                 return $post->getId() == $postId;
136 136
             })
137
-            ->map(function ($post) {
137
+            ->map(function($post) {
138 138
                 return count($post->getComments());
139 139
             })
140 140
             ->first();
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
     public function findCommentsByPostId(Ulid $postId): array
144 144
     {
145 145
         $post = self::$postHeaders
146
-            ->find(function ($post) use ($postId) {
146
+            ->find(function($post) use ($postId) {
147 147
                 return $post->getId() == $postId;
148 148
             });
149 149
         if ($post == null) {
150 150
             return [];
151 151
         }
152 152
         return Collection::from($post->getComments())
153
-            ->map(function ($comment) {
153
+            ->map(function($comment) {
154 154
                 $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null;
155 155
                 return new CommentDto(
156 156
                     $comment->getId(),
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $from = ($pageNo - 1) * self::PAGE_SIZE;
168 168
         $to = $from + self::PAGE_SIZE;
169 169
         $data = self::$comments
170
-            ->map(function ($comment) {
170
+            ->map(function($comment) {
171 171
                 $parentId = $comment->getParentComment() != null ? $comment->getParentComment()->getId() : null;
172 172
                 return new CommentWithPostDto(
173 173
                     $comment->getId(),
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
                     $comment->getPost()->getTitle(),
180 180
                     $comment->getPost()->getSummary(),
181 181
                     self::$postHeaders
182
-                        ->filter(function ($post) use ($comment) {
182
+                        ->filter(function($post) use ($comment) {
183 183
                             return $post->getId() == $comment->getPost()->getId();
184 184
                         })->size(),
185 185
                     $comment->getPost()->getTags(),
186 186
 
187 187
                 );
188 188
             })
189
-            ->sort(function ($c1, $c2) {
189
+            ->sort(function($c1, $c2) {
190 190
                 return $c1->getCreatedAt() < $c2->getCreatedAt() ? 1 : -1;
191 191
             })
192 192
             ->slice($from, $to)
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     public function commentExists(Ulid $commentId): bool
198 198
     {
199 199
         return self::$comments
200
-            ->filter(function ($comment) use ($commentId) {
200
+            ->filter(function($comment) use ($commentId) {
201 201
                 return $comment->getId() == $commentId;
202 202
             })->sizeIsGreaterThan(0);
203 203
     }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     public function postExists(Ulid $postId): bool
206 206
     {
207 207
         return self::$postHeaders
208
-            ->filter(function ($post) use ($postId) {
208
+            ->filter(function($post) use ($postId) {
209 209
                 return $post->getId() == $postId;
210 210
             })->sizeIsGreaterThan(0);
211 211
     }
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
     public function deleteCommentsForPost(Ulid $postId)
214 214
     {
215 215
         self::$comments = self::$comments
216
-            ->filter(function ($comment) use ($postId) {
216
+            ->filter(function($comment) use ($postId) {
217 217
                 return $comment->getPost()->getId() != $postId;
218 218
             })
219 219
             ->realize();
220
-        $post = self::$postHeaders->find(function ($post) use ($postId) {
220
+        $post = self::$postHeaders->find(function($post) use ($postId) {
221 221
             $post->getId() == $postId;
222 222
         });
223 223
         if ($post != null) {
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
     public function updateUserName(UpdatedCommentsPostHeadersUserNameDto $updatedUserName): void
230 230
     {
231 231
         self::$postHeaders
232
-            ->filter(function ($post) use ($updatedUserName) {
232
+            ->filter(function($post) use ($updatedUserName) {
233 233
                 return $post->getCreatedByName() == $updatedUserName->getOldUserName();
234 234
             })
235
-            ->each(function ($post) use ($updatedUserName) {
235
+            ->each(function($post) use ($updatedUserName) {
236 236
                 $post->setCreatedByName($updatedUserName->getNewUserName());
237 237
             })
238 238
             ->realize();
Please login to merge, or discard this patch.
tests/Modules/Comments/Integration/Http/CommentsHttpTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     public function findLatestComments(FindLatestCommentsQuery $query): Page
30 30
     {
31 31
         $client = $this->getClient();
32
-        $client->request('GET', '/api/comments/?pageNo=' . $query->getPageNo());
32
+        $client->request('GET', '/api/comments/?pageNo='.$query->getPageNo());
33 33
         return $this->responseObject($client, Page::class);
34 34
     }
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public function findCommentsForPost(FindCommentsByPostIdQuery $query): array
41 41
     {
42 42
         $client = $this->getClient();
43
-        $client->request('GET', '/api/comments/' . $query->getPostId());
43
+        $client->request('GET', '/api/comments/'.$query->getPostId());
44 44
         return $this->responseObjects($client, FindCommentsByPostIdQueryResponse::class);
45 45
     }
46 46
 
Please login to merge, or discard this patch.