Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions tests/Controllers/RepositoryFilterControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ public function test_can_get_available_filters()

public function test_the_boolean_filter_is_applied()
{
factory(Post::class)->create(['is_active' => false,]);
factory(Post::class)->create(['is_active' => true,]);
factory(Post::class)->create(['is_active' => false]);
factory(Post::class)->create(['is_active' => true]);

$filters = base64_encode(json_encode([
[
'class' => ActiveBooleanFilter::class,
'value' => [
'is_active' => false,
],
]
],
]));

$response = $this
->withoutExceptionHandling()
->getJson('restify-api/posts?filters=' . $filters)
->getJson('restify-api/posts?filters='.$filters)
->dump()
->assertStatus(200);

Expand All @@ -47,28 +47,28 @@ public function test_the_boolean_filter_is_applied()

public function test_the_select_filter_is_applied()
{
factory(Post::class)->create(['category' => 'movie',]);
factory(Post::class)->create(['category' => 'article',]);
factory(Post::class)->create(['category' => 'movie']);
factory(Post::class)->create(['category' => 'article']);

$filters = base64_encode(json_encode([
[
'class' => SelectCategoryFilter::class,
'value' => 'article'
]
'value' => 'article',
],
]));

$response = $this
->withExceptionHandling()
->getJson('restify-api/posts?filters=' . $filters)
->getJson('restify-api/posts?filters='.$filters)
->assertStatus(200);

$this->assertCount(1, $response->json('data'));
}

public function test_the_timestamp_filter_is_applied()
{
factory(Post::class)->create(['created_at' => now()->addYear(),]);
factory(Post::class)->create(['created_at' => now()->subYear(),]);
factory(Post::class)->create(['created_at' => now()->addYear()]);
factory(Post::class)->create(['created_at' => now()->subYear()]);

$filters = base64_encode(json_encode([
[
Expand All @@ -78,12 +78,12 @@ public function test_the_timestamp_filter_is_applied()
[
'class' => CreatedAfterDateFilter::class,
'value' => now()->addWeek()->timestamp,
]
],
]));

$response = $this
->withExceptionHandling()
->getJson('restify-api/posts?filters=' . $filters)
->getJson('restify-api/posts?filters='.$filters)
->assertStatus(200);

$this->assertCount(1, $response->json('data'));
Expand Down