| @@ 123-139 (lines=17) @@ | ||
| 120 | * @group put |
|
| 121 | * @group controller |
|
| 122 | */ |
|
| 123 | public function testPutSansResultat() |
|
| 124 | { |
|
| 125 | $this->loadFixtureFiles( |
|
| 126 | [ |
|
| 127 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 128 | ||
| 129 | ] |
|
| 130 | ); |
|
| 131 | $data = [ |
|
| 132 | 'name' => "Mon nom", //exemple |
|
| 133 | ]; |
|
| 134 | $client = $this->getAuthClient(); |
|
| 135 | $client->request('PUT', '/api/campaigns/404', $data); |
|
| 136 | $response = $client->getResponse(); |
|
| 137 | $this->assertEquals(404, $response->getStatusCode()); |
|
| 138 | $payload = json_decode($response->getContent(), true)['payload']; |
|
| 139 | $this->assertEquals("La donnée demandée n'existe pas.", $payload); |
|
| 140 | } |
|
| 141 | ||
| 142 | ||
| @@ 148-165 (lines=18) @@ | ||
| 145 | * @group cget |
|
| 146 | * @group controller |
|
| 147 | */ |
|
| 148 | public function testCGetValideAvecResultats() |
|
| 149 | { |
|
| 150 | $this->loadFixtureFiles( |
|
| 151 | [ |
|
| 152 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 153 | ||
| 154 | '@StarkerxpCampaignBundle/Tests/DataFixtures/CampaignManager/CampaignManager.yml', |
|
| 155 | ] |
|
| 156 | ); |
|
| 157 | $client = $this->getAuthClient(); |
|
| 158 | $client->request('GET', '/api/campaigns', []); |
|
| 159 | $response = $client->getResponse(); |
|
| 160 | $this->assertEquals(200, $response->getStatusCode()); |
|
| 161 | $body = json_decode($response->getContent(), true); |
|
| 162 | $this->assertCount(10, $body); |
|
| 163 | foreach ($body as $element) { |
|
| 164 | //$this->assertArrayHasKey("nom", $body); // Exemple |
|
| 165 | } |
|
| 166 | } |
|
| 167 | ||
| 168 | /** |
|
| @@ 173-186 (lines=14) @@ | ||
| 170 | * @group cget |
|
| 171 | * @group controller |
|
| 172 | */ |
|
| 173 | public function testCGetValideSansResultat() |
|
| 174 | { |
|
| 175 | $this->loadFixtureFiles( |
|
| 176 | [ |
|
| 177 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 178 | ||
| 179 | ] |
|
| 180 | ); |
|
| 181 | $client = $this->getAuthClient(); |
|
| 182 | $client->request('GET', '/api/campaigns', []); |
|
| 183 | $response = $client->getResponse(); |
|
| 184 | $this->assertEquals(200, $response->getStatusCode()); |
|
| 185 | $body = json_decode($response->getContent(), true); |
|
| 186 | $this->assertCount(0, $body); |
|
| 187 | } |
|
| 188 | ||
| 189 | /** |
|
| @@ 241-254 (lines=14) @@ | ||
| 238 | * @group get |
|
| 239 | * @group controller |
|
| 240 | */ |
|
| 241 | public function testGetValideSansResultat() |
|
| 242 | { |
|
| 243 | $this->loadFixtureFiles( |
|
| 244 | [ |
|
| 245 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 246 | ||
| 247 | ] |
|
| 248 | ); |
|
| 249 | $client = $this->getAuthClient(); |
|
| 250 | $client->request('GET', '/api/campaigns/404', []); |
|
| 251 | $response = $client->getResponse(); |
|
| 252 | $this->assertEquals(404, $response->getStatusCode()); |
|
| 253 | $body = json_decode($response->getContent(), true); |
|
| 254 | $this->assertNotEmpty($body); |
|
| 255 | } |
|
| 256 | ||
| 257 | /** |
|
| @@ 307-320 (lines=14) @@ | ||
| 304 | * @group delete |
|
| 305 | * @group controller |
|
| 306 | */ |
|
| 307 | public function testDeleteSansResultat() |
|
| 308 | { |
|
| 309 | $this->loadFixtureFiles( |
|
| 310 | [ |
|
| 311 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 312 | ||
| 313 | ] |
|
| 314 | ); |
|
| 315 | $client = $this->getAuthClient(); |
|
| 316 | $client->request('DELETE', '/api/campaigns/404', []); |
|
| 317 | $response = $client->getResponse(); |
|
| 318 | $this->assertEquals(404, $response->getStatusCode()); |
|
| 319 | $body = json_decode($response->getContent(), true); |
|
| 320 | $this->assertNotEmpty($body); |
|
| 321 | } |
|
| 322 | } |
|
| 323 | ||
| @@ 179-190 (lines=12) @@ | ||
| 176 | * @group cget |
|
| 177 | * @group controller |
|
| 178 | */ |
|
| 179 | public function testCGetValideSansResultat() |
|
| 180 | { |
|
| 181 | $this->loadFixtureFiles( |
|
| 182 | [ |
|
| 183 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 184 | ||
| 185 | ] |
|
| 186 | ); |
|
| 187 | $client = $this->getAuthClient(); |
|
| 188 | $client->request('GET', '/api/templates', []); |
|
| 189 | $response = $client->getResponse(); |
|
| 190 | $this->assertEquals(200, $response->getStatusCode()); |
|
| 191 | $body = json_decode($response->getContent(), true); |
|
| 192 | $this->assertCount(0, $body); |
|
| 193 | } |
|
| @@ 249-260 (lines=12) @@ | ||
| 246 | * @group get |
|
| 247 | * @group controller |
|
| 248 | */ |
|
| 249 | public function testGetValideSansResultat() |
|
| 250 | { |
|
| 251 | $this->loadFixtureFiles( |
|
| 252 | [ |
|
| 253 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 254 | ||
| 255 | ] |
|
| 256 | ); |
|
| 257 | $client = $this->getAuthClient(); |
|
| 258 | $client->request('GET', '/api/templates/404', []); |
|
| 259 | $response = $client->getResponse(); |
|
| 260 | $this->assertEquals(404, $response->getStatusCode()); |
|
| 261 | $body = json_decode($response->getContent(), true); |
|
| 262 | $this->assertNotEmpty($body); |
|
| 263 | } |
|
| @@ 315-326 (lines=12) @@ | ||
| 312 | * @group delete |
|
| 313 | * @group controller |
|
| 314 | */ |
|
| 315 | public function testDeleteSansResultat() |
|
| 316 | { |
|
| 317 | $this->loadFixtureFiles( |
|
| 318 | [ |
|
| 319 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 320 | ||
| 321 | ] |
|
| 322 | ); |
|
| 323 | $client = $this->getAuthClient(); |
|
| 324 | $client->request('DELETE', '/api/templates/404', []); |
|
| 325 | $response = $client->getResponse(); |
|
| 326 | $this->assertEquals(404, $response->getStatusCode()); |
|
| 327 | $body = json_decode($response->getContent(), true); |
|
| 328 | $this->assertNotEmpty($body); |
|
| 329 | } |
|
| @@ 48-63 (lines=16) @@ | ||
| 45 | * @group post |
|
| 46 | * @group controller |
|
| 47 | */ |
|
| 48 | public function testPostInvalide() |
|
| 49 | { |
|
| 50 | $this->loadFixtureFiles( |
|
| 51 | [ |
|
| 52 | '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml', |
|
| 53 | ||
| 54 | ] |
|
| 55 | ); |
|
| 56 | $url = $this->generateUrl( |
|
| 57 | 'starkerxp_lead.lead.post', |
|
| 58 | [] |
|
| 59 | ); |
|
| 60 | $client = $this->getAuthClient(); |
|
| 61 | $client->request('POST', $url, []); |
|
| 62 | $response = $client->getResponse(); |
|
| 63 | $this->assertEquals(400, $response->getStatusCode()); |
|
| 64 | $body = json_decode($response->getContent(), true)['payload']; |
|
| 65 | //$this->assertArrayHasKey("nom", $body); // Exemple |
|
| 66 | } |
|