1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Starkerxp\CampagneBundle\Tests\Manager; |
4
|
|
|
|
5
|
|
|
use Starkerxp\StructureBundle\Tests\WebTest; |
6
|
|
|
|
7
|
|
|
class TemplateControllerTest extends WebTest |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
public function testPostValide() |
11
|
|
|
{ |
12
|
|
|
// create our http client (Guzzle) |
13
|
|
|
$client = new \GuzzleHttp\Client(['base_uri' => 'http://web/']); |
14
|
|
|
$data = [ |
15
|
|
|
'nom' => "Mon nom", |
16
|
|
|
'sujet' => "Mon sujet", |
17
|
|
|
'message' => "Mon message", |
18
|
|
|
'type' => "email", |
19
|
|
|
]; |
20
|
|
|
$response = $client->post("app_test.php/templates", ['form_params' => $data]); |
21
|
|
|
$this->assertEquals(201, $response->getStatusCode()); |
22
|
|
|
|
23
|
|
|
$manager = $this->getContainer()->get('starkerxp_campagne.manager.template'); |
24
|
|
|
$templates = $manager->findAll(); |
25
|
|
|
$this->assertCount(1, $templates); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testPostInvalide() |
29
|
|
|
{ |
30
|
|
|
// create our http client (Guzzle) |
31
|
|
|
$client = new \GuzzleHttp\Client(['base_uri' => 'http://web/']); |
32
|
|
|
$response = $client->post("app_test.php/templates", ['form_params' => [], "exceptions"=>false]); |
33
|
|
|
$this->assertEquals(400, $response->getStatusCode()); |
34
|
|
|
$body = json_decode($response->getBody(), true)['payload']; |
35
|
|
|
$this->assertArrayHasKey("nom", $body); |
36
|
|
|
$this->assertArrayHasKey("sujet", $body); |
37
|
|
|
$this->assertArrayHasKey("message", $body); |
38
|
|
|
$this->assertArrayHasKey("type", $body); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
} |
|
|
|
|
42
|
|
|
|
This check marks files that end in a newline character, i.e. an empy line.