From d9e27b5f46d302fc6d997c4f8b35a0a114725f6a Mon Sep 17 00:00:00 2001 From: James Brooks Date: Fri, 12 Jul 2019 10:41:58 +0100 Subject: [PATCH] Add tests for tags --- tests/Api/ComponentTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Api/ComponentTest.php b/tests/Api/ComponentTest.php index afabe71f3..bcb0dcae2 100644 --- a/tests/Api/ComponentTest.php +++ b/tests/Api/ComponentTest.php @@ -37,6 +37,19 @@ class ComponentTest extends AbstractApiTestCase $response->assertJsonFragment(['id' => $components[2]->id]); } + public function test_can_get_all_components_with_tags() + { + $components = factory(Component::class, 2)->create(); + $components[0]->attachTags(["Hello World"]); + $components[1]->attachTags(["Foo", "Bar"]); + + $response = $this->json('GET', '/api/v1/components', ['tags' => ['foo']]); + + $response->assertStatus(200); + $response->assertJsonMissing(['id' => $components[0]->id]); + $response->assertJsonFragment(['id' => $components[1]->id]); + } + public function test_cannot_get_invalid_component() { $response = $this->json('GET', '/api/v1/components/1');