Completed
Push — master ( 4bb011...4b99be )
by Guillaume
13:23
created

TemplateManagerTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 69
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testFindAll() 0 10 1
A testInsertNewCampaign() 0 17 1
A testUpdateCampaign() 0 16 1
1
<?php
2
3
namespace Starkerxp\CampaignBundle\Tests\Manager;
4
5
use Starkerxp\CampaignBundle\Entity\Template;
6
use Starkerxp\CampaignBundle\Manager\TemplateManager;
7
8
class TemplateManagerTest extends \Starkerxp\StructureBundle\Tests\WebTest
9
{
10
    /** @var TemplateManager */
11
    protected $manager;
12
13
    public function setUp()
14
    {
15
        parent::setUp();
16
        $this->manager = $this->getContainer()->get('starkerxp_campaign.manager.template');
17
    }
18
19
    /**
20
     * @group template
21
     * @group manager
22
     */
23
    public function testFindAll()
24
    {
25
        $this->loadFixtureFiles(
26
            [
27
                '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml',
28
                '@StarkerxpCampaignBundle/Tests/DataFixtures/TemplateManager/TemplateManager.yml',
29
            ]
30
        );
31
        $this->assertCount(10, $this->manager->findAll());
32
    }
33
34
    /**
35
     * @group template
36
     * @group manager
37
     */
38
    public function testInsertNewCampaign()
39
    {
40
        $this->loadFixtureFiles(
41
            [
42
                '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml',
43
                '@StarkerxpCampaignBundle/Tests/DataFixtures/TemplateManager/DefaultTemplate.yml',
44
            ]
45
        );
46
        $template = new Template();
47
        $template->setType("email");
48
        $template->setName("Ceci est mon nom");
49
        $template->setObject("Ceci est mon sujet");
50
        $template->setMessage("Ceci est mon message");
51
        $template->setUuid("5e6e63e6-1d74-4c4c-b19a-2741ed330837");
0 ignored issues
show
Documentation introduced by
'5e6e63e6-1d74-4c4c-b19a-2741ed330837' is of type string, but the function expects a object<Starkerxp\StructureBundle\Entity\guid>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
52
        $this->manager->insert($template);
53
        $this->assertCount(2, $this->manager->findAll());
54
    }
55
56
    /**
57
     * @group template
58
     * @group manager
59
     */
60
    public function testUpdateCampaign()
61
    {
62
        $this->loadFixtureFiles(
63
            [
64
                '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml',
65
                '@StarkerxpCampaignBundle/Tests/DataFixtures/TemplateManager/DefaultTemplate.yml',
66
            ]
67
        );
68
        $template = $this->manager->findOneBy(['uuid' => "5e6e63e6-1d74-4c4c-b19a-2741ed330836"]);
69
        $type = $template->getType();
70
        $template->setType("sms");
71
        $this->manager->update($template);
0 ignored issues
show
Documentation introduced by
$template is of type object|null, but the function expects a object<Starkerxp\StructureBundle\Entity\Entity>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
72
        $this->manager->clear();
73
        $template = $this->manager->findOneBy(['uuid' => "5e6e63e6-1d74-4c4c-b19a-2741ed330836"]);
74
        $this->assertNotEquals($type, $template->getType());
75
    }
76
}
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...
77