1 | <?php |
||
9 | class CategoryControllerTest extends FeatureTestCase |
||
10 | { |
||
11 | /** |
||
12 | * A basic test example. |
||
13 | * |
||
14 | * @test |
||
15 | * |
||
16 | * @return void |
||
17 | */ |
||
18 | public function it_return_all_subcategories_of_a_category() |
||
19 | { |
||
20 | // Arrange |
||
21 | $category = factory(Category::class)->create(); |
||
22 | $subCategory1 = factory(Category::class)->create(['parent_id' => $category->id]); |
||
23 | $subCategory2 = factory(Category::class)->create(['parent_id' => $category->id]); |
||
24 | |||
25 | $url = '/api/v1/category/%d/subcategories'; |
||
26 | $url = sprintf($url, $category->id); |
||
27 | |||
28 | // Act |
||
29 | $this->ensureAuthenticated(); |
||
30 | $response = $this->get($url); |
||
31 | |||
32 | // Assert |
||
33 | $response->assertStatus(200) |
||
34 | ->assertJsonFragment([ |
||
35 | 'id' => $subCategory1->id, |
||
36 | 'name' => $subCategory1->name, |
||
37 | ])->assertJsonFragment([ |
||
38 | 'id' => $subCategory2->id, |
||
39 | 'name' => $subCategory2->name, |
||
40 | ]); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * A basic test example. |
||
45 | * |
||
46 | * @test |
||
47 | * |
||
48 | * @return void |
||
49 | */ |
||
50 | public function it_can_access_just_root_categories_of_a_user() |
||
98 | } |
||
99 |