| @@ 110-126 (lines=17) @@ | ||
| 107 | * @group put |
|
| 108 | * @group controller |
|
| 109 | */ |
|
| 110 | public function testPutSansResultat() |
|
| 111 | { |
|
| 112 | $this->loadFixtureFiles( |
|
| 113 | [ |
|
| 114 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 115 | ] |
|
| 116 | ); |
|
| 117 | $data = [ |
|
| 118 | 'name' => "Mon nom", //exemple |
|
| 119 | ]; |
|
| 120 | $client = $this->getAuthClient(); |
|
| 121 | $client->request('PUT', '/api/campaigns/404', $data); |
|
| 122 | $response = $client->getResponse(); |
|
| 123 | $this->assertEquals(404, $response->getStatusCode()); |
|
| 124 | $payload = json_decode($response->getContent(), true)['payload']; |
|
| 125 | $this->assertEquals("La donnée demandée n'existe pas.", $payload); |
|
| 126 | } |
|
| 127 | ||
| 128 | ||
| 129 | /** |
|
| @@ 134-151 (lines=18) @@ | ||
| 131 | * @group cget |
|
| 132 | * @group controller |
|
| 133 | */ |
|
| 134 | public function testCGetValideAvecResultats() |
|
| 135 | { |
|
| 136 | $this->loadFixtureFiles( |
|
| 137 | [ |
|
| 138 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 139 | '@StarkerxpCampaignBundle/Tests/DataFixtures/CampaignManager/CampaignManager.yml', |
|
| 140 | ] |
|
| 141 | ); |
|
| 142 | $client = $this->getAuthClient(); |
|
| 143 | $client->request('GET', '/api/campaigns', []); |
|
| 144 | $response = $client->getResponse(); |
|
| 145 | $this->assertEquals(200, $response->getStatusCode()); |
|
| 146 | $body = json_decode($response->getContent(), true); |
|
| 147 | $this->assertCount(10, $body); |
|
| 148 | foreach ($body as $element) { |
|
| 149 | //$this->assertArrayHasKey("nom", $body); // Exemple |
|
| 150 | } |
|
| 151 | } |
|
| 152 | ||
| 153 | /** |
|
| 154 | * @group campaign |
|
| @@ 158-171 (lines=14) @@ | ||
| 155 | * @group cget |
|
| 156 | * @group controller |
|
| 157 | */ |
|
| 158 | public function testCGetValideSansResultat() |
|
| 159 | { |
|
| 160 | $this->loadFixtureFiles( |
|
| 161 | [ |
|
| 162 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 163 | ] |
|
| 164 | ); |
|
| 165 | $client = $this->getAuthClient(); |
|
| 166 | $client->request('GET', '/api/campaigns', []); |
|
| 167 | $response = $client->getResponse(); |
|
| 168 | $this->assertEquals(200, $response->getStatusCode()); |
|
| 169 | $body = json_decode($response->getContent(), true); |
|
| 170 | $this->assertCount(0, $body); |
|
| 171 | } |
|
| 172 | ||
| 173 | /** |
|
| 174 | * @group campaign |
|
| @@ 223-236 (lines=14) @@ | ||
| 220 | * @group get |
|
| 221 | * @group controller |
|
| 222 | */ |
|
| 223 | public function testGetValideSansResultat() |
|
| 224 | { |
|
| 225 | $this->loadFixtureFiles( |
|
| 226 | [ |
|
| 227 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 228 | ] |
|
| 229 | ); |
|
| 230 | $client = $this->getAuthClient(); |
|
| 231 | $client->request('GET', '/api/campaigns/404', []); |
|
| 232 | $response = $client->getResponse(); |
|
| 233 | $this->assertEquals(404, $response->getStatusCode()); |
|
| 234 | $body = json_decode($response->getContent(), true); |
|
| 235 | $this->assertNotEmpty($body); |
|
| 236 | } |
|
| 237 | ||
| 238 | /** |
|
| 239 | * @group campaign |
|
| @@ 286-299 (lines=14) @@ | ||
| 283 | * @group delete |
|
| 284 | * @group controller |
|
| 285 | */ |
|
| 286 | public function testDeleteSansResultat() |
|
| 287 | { |
|
| 288 | $this->loadFixtureFiles( |
|
| 289 | [ |
|
| 290 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 291 | ] |
|
| 292 | ); |
|
| 293 | $client = $this->getAuthClient(); |
|
| 294 | $client->request('DELETE', '/api/campaigns/404', []); |
|
| 295 | $response = $client->getResponse(); |
|
| 296 | $this->assertEquals(404, $response->getStatusCode()); |
|
| 297 | $body = json_decode($response->getContent(), true); |
|
| 298 | $this->assertNotEmpty($body); |
|
| 299 | } |
|
| 300 | } |
|
| 301 | ||
| @@ 176-187 (lines=12) @@ | ||
| 173 | * @group cget |
|
| 174 | * @group controller |
|
| 175 | */ |
|
| 176 | public function testCGetValideSansResultat() |
|
| 177 | { |
|
| 178 | $this->loadFixtureFiles( |
|
| 179 | [ |
|
| 180 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 181 | ] |
|
| 182 | ); |
|
| 183 | $client = $this->getAuthClient(); |
|
| 184 | $client->request('GET', '/api/templates', []); |
|
| 185 | $response = $client->getResponse(); |
|
| 186 | $this->assertEquals(200, $response->getStatusCode()); |
|
| 187 | $body = json_decode($response->getContent(), true); |
|
| 188 | $this->assertCount(0, $body); |
|
| 189 | } |
|
| 190 | ||
| @@ 243-254 (lines=12) @@ | ||
| 240 | * @group get |
|
| 241 | * @group controller |
|
| 242 | */ |
|
| 243 | public function testGetValideSansResultat() |
|
| 244 | { |
|
| 245 | $this->loadFixtureFiles( |
|
| 246 | [ |
|
| 247 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 248 | ] |
|
| 249 | ); |
|
| 250 | $client = $this->getAuthClient(); |
|
| 251 | $client->request('GET', '/api/templates/404', []); |
|
| 252 | $response = $client->getResponse(); |
|
| 253 | $this->assertEquals(404, $response->getStatusCode()); |
|
| 254 | $body = json_decode($response->getContent(), true); |
|
| 255 | $this->assertNotEmpty($body); |
|
| 256 | } |
|
| 257 | ||
| @@ 306-317 (lines=12) @@ | ||
| 303 | * @group delete |
|
| 304 | * @group controller |
|
| 305 | */ |
|
| 306 | public function testDeleteSansResultat() |
|
| 307 | { |
|
| 308 | $this->loadFixtureFiles( |
|
| 309 | [ |
|
| 310 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 311 | ] |
|
| 312 | ); |
|
| 313 | $client = $this->getAuthClient(); |
|
| 314 | $client->request('DELETE', '/api/templates/404', []); |
|
| 315 | $response = $client->getResponse(); |
|
| 316 | $this->assertEquals(404, $response->getStatusCode()); |
|
| 317 | $body = json_decode($response->getContent(), true); |
|
| 318 | $this->assertNotEmpty($body); |
|
| 319 | } |
|
| 320 | } |
|
| @@ 47-62 (lines=16) @@ | ||
| 44 | * @group post |
|
| 45 | * @group controller |
|
| 46 | */ |
|
| 47 | public function testPostInvalide() |
|
| 48 | { |
|
| 49 | $this->loadFixtureFiles( |
|
| 50 | [ |
|
| 51 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 52 | ] |
|
| 53 | ); |
|
| 54 | $url = $this->generateUrl( |
|
| 55 | 'starkerxp_lead.lead.post', |
|
| 56 | [] |
|
| 57 | ); |
|
| 58 | $client = $this->getAuthClient(); |
|
| 59 | $client->request('POST', $url, []); |
|
| 60 | $response = $client->getResponse(); |
|
| 61 | $this->assertEquals(400, $response->getStatusCode()); |
|
| 62 | $body = json_decode($response->getContent(), true)['payload']; |
|
| 63 | //$this->assertArrayHasKey("nom", $body); // Exemple |
|
| 64 | } |
|
| 65 | ||