Skip to content

Commit

Permalink
Resolved - A guest or an authenticated user can list questions (larav…
Browse files Browse the repository at this point in the history
…el-portugal#26) - minor cleanup and code style fixes
  • Loading branch information
dleicam committed Oct 27, 2020
1 parent 3db0e2c commit c66551d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion domains/Discussions/Controllers/QuestionsGetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __invoke(Request $request): AnonymousResourceCollection
'created' => 'sometimes|array|size:2',
'created.from' => 'required_with:created|date',
'created.to' => 'required_with:created|date|afterOrEqual:created.from',
'resolved' => 'sometimes|boolean'
'resolved' => 'sometimes|boolean',
]);

$question = $this->question
Expand Down
17 changes: 9 additions & 8 deletions domains/Discussions/Tests/Feature/QuestionsGetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function it_possible_to_see_a_question(): void
]
]);

$this->assertEquals(15, count($response->decodedJsonResponse()['data']));
self::assertEquals(15, count($response->decodedJsonResponse()['data']));
}

/** @test */
Expand Down Expand Up @@ -88,8 +88,8 @@ public function it_supports_pagination_navigation(): void
{
$response = $this->get(route('discussions.questions.index', ['page' => 2]));
$response->assertResponseOk();
$this->assertEquals(2, $response->decodedJsonResponse()['meta']['current_page']);
$this->assertEquals(2, $response->decodedJsonResponse()['meta']['current_page']);

self::assertEquals(2, $response->decodedJsonResponse()['meta']['current_page']);
}

/** @test */
Expand All @@ -100,7 +100,7 @@ public function it_searchable_by_author(): void

$response = $this->get(route('discussions.questions.index', ['author' => $user->id]));

$this->assertEquals(1, count($response->decodedJsonResponse()['data']));
self::assertEquals(1, count($response->decodedJsonResponse()['data']));
}

/** @test */
Expand All @@ -111,7 +111,7 @@ public function it_searchable_by_title(): void

$response = $this->get(route('discussions.questions.index', ['title' => 'LArAvEL-pt']));

$this->assertEquals(2, count($response->decodedJsonResponse()['data']));
self::assertEquals(2, count($response->decodedJsonResponse()['data']));
}

/** @test */
Expand All @@ -124,13 +124,13 @@ public function it_searchable_by_created_at(): void
'created[from]' => Carbon::now()->subMonth()->subYears(2)->toDateString(),
'created[to]' => Carbon::now()->addMonth()->subYears(2)->toDateString()
]));
$this->assertEquals(1, count($response->decodedJsonResponse()['data']));
self::assertEquals(1, count($response->decodedJsonResponse()['data']));

$response = $this->get(route('discussions.questions.index', [
'created[from]' => Carbon::now()->subMonth()->subYears(3)->toDateString(),
'created[to]' => Carbon::now()->addMonth()->subYears(2)->toDateString()
]));
$this->assertEquals(2, count($response->decodedJsonResponse()['data']));
self::assertEquals(2, count($response->decodedJsonResponse()['data']));
}

/** @test */
Expand All @@ -139,7 +139,8 @@ public function it_searchable_by_resolved(): void
QuestionFactory::new(['resolved_at' => Carbon::now()->toDateString()])->create();

$response = $this->get(route('discussions.questions.index', ['resolved' => true]));
$this->assertEquals(1, count($response->decodedJsonResponse()['data']));

self::assertEquals(1, count($response->decodedJsonResponse()['data']));
}

/** @test */
Expand Down

0 comments on commit c66551d

Please sign in to comment.