|
3 | 3 |
|
4 | 4 | namespace PhpList\RestBundle\Tests\Integration\Controller; |
5 | 5 |
|
| 6 | +use PhpList\PhpList4\Domain\Repository\Messaging\SubscriberListRepository; |
6 | 7 | use PhpList\RestBundle\Controller\ListController; |
7 | 8 |
|
8 | 9 | /** |
@@ -171,6 +172,56 @@ public function getListWithCurrentSessionKeyReturnsListData() |
171 | 172 | ); |
172 | 173 | } |
173 | 174 |
|
| 175 | + /** |
| 176 | + * @test |
| 177 | + */ |
| 178 | + public function deleteListWithoutSessionKeyForExistingListReturnsForbiddenStatus() |
| 179 | + { |
| 180 | + $this->getDataSet()->addTable(static::LISTS_TABLE_NAME, __DIR__ . '/Fixtures/SubscriberList.csv'); |
| 181 | + $this->applyDatabaseChanges(); |
| 182 | + |
| 183 | + $this->client->request('delete', '/api/v2/lists/1'); |
| 184 | + |
| 185 | + $this->assertHttpForbidden(); |
| 186 | + } |
| 187 | + |
| 188 | + /** |
| 189 | + * @test |
| 190 | + */ |
| 191 | + public function deleteListWithCurrentSessionKeyForExistingListReturnsNoContentStatus() |
| 192 | + { |
| 193 | + $this->getDataSet()->addTable(static::LISTS_TABLE_NAME, __DIR__ . '/Fixtures/SubscriberList.csv'); |
| 194 | + $this->applyDatabaseChanges(); |
| 195 | + |
| 196 | + $this->authenticatedJsonRequest('delete', '/api/v2/lists/1'); |
| 197 | + |
| 198 | + $this->assertHttpNoContent(); |
| 199 | + } |
| 200 | + |
| 201 | + /** |
| 202 | + * @test |
| 203 | + */ |
| 204 | + public function deleteListWithCurrentSessionKeyForInexistentListReturnsNotFoundStatus() |
| 205 | + { |
| 206 | + $this->authenticatedJsonRequest('delete', '/api/v2/lists/999'); |
| 207 | + |
| 208 | + $this->assertHttpNotFound(); |
| 209 | + } |
| 210 | + |
| 211 | + /** |
| 212 | + * @test |
| 213 | + */ |
| 214 | + public function deleteListWithCurrentSessionKeyDeletesList() |
| 215 | + { |
| 216 | + $this->getDataSet()->addTable(static::LISTS_TABLE_NAME, __DIR__ . '/Fixtures/SubscriberList.csv'); |
| 217 | + $this->applyDatabaseChanges(); |
| 218 | + |
| 219 | + $this->authenticatedJsonRequest('delete', '/api/v2/lists/1'); |
| 220 | + |
| 221 | + $listRepository = $this->container->get(SubscriberListRepository::class); |
| 222 | + static::assertNull($listRepository->find(1)); |
| 223 | + } |
| 224 | + |
174 | 225 | /** |
175 | 226 | * @test |
176 | 227 | */ |
|
0 commit comments