Completed
Push — master ( b902ad...a16ed8 )
by Guillaume
02:37
created

TemplateControllerTest::testPostInvalide()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 12
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
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
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
42