|
@@ 93-108 (lines=16) @@
|
| 90 |
|
$response->assertStatus(200); |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
public function testSearchValidCards() |
| 94 |
|
{ |
| 95 |
|
// Search query |
| 96 |
|
$keyword = 'card 1'; |
| 97 |
|
|
| 98 |
|
/** @var TestResponse $response */ |
| 99 |
|
// Request to get cards by a search query and include category details |
| 100 |
|
$response = $this->getJson(sprintf('/api/cards?filter[search]=%s&include=category', $keyword)); |
| 101 |
|
|
| 102 |
|
// Assert that records found and category included |
| 103 |
|
$response->assertJsonFragment(['category']); |
| 104 |
|
$this->assertEquals('Category 1', $response->json('0.category.title')); |
| 105 |
|
$response->assertJsonFragment(['slug' => 'card-1']); |
| 106 |
|
$response->assertJsonCount(1); |
| 107 |
|
$response->assertStatus(200); |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
public function testSearchInvalidCards() |
| 111 |
|
{ |
|
@@ 124-139 (lines=16) @@
|
| 121 |
|
$response->assertStatus(200); |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
public function testSearchValidCardsWithoutCategory() |
| 125 |
|
{ |
| 126 |
|
// Search query |
| 127 |
|
$keyword = 'card 1'; |
| 128 |
|
|
| 129 |
|
/** @var TestResponse $response */ |
| 130 |
|
// Request to get cards by a search query and does not include category details |
| 131 |
|
$response = $this->getJson(sprintf('/api/cards?filter[search]=%s', $keyword)); |
| 132 |
|
|
| 133 |
|
// Assert that records does not include category details |
| 134 |
|
$response->assertJsonMissing(['category']); |
| 135 |
|
$this->assertNull($response->json('0.category.title')); |
| 136 |
|
$response->assertJsonFragment(['slug' => 'card-1']); |
| 137 |
|
$response->assertJsonCount(1); |
| 138 |
|
$response->assertStatus(200); |
| 139 |
|
} |
| 140 |
|
|
| 141 |
|
public function testFilterCardsByCategory() |
| 142 |
|
{ |