TemplateManagerTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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\Test\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
29
                '@StarkerxpCampaignBundle/Tests/DataFixtures/TemplateManager/TemplateManager.yml',
30
            ]
31
        );
32
        $this->assertCount(10, $this->manager->findAll());
33
    }
34
35
    /**
36
     * @group template
37
     * @group manager
38
     */
39
    public function testInsertNewCampaign()
40
    {
41
        $this->loadFixtureFiles(
42
            [
43
                '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml',
44
45
                '@StarkerxpCampaignBundle/Tests/DataFixtures/TemplateManager/DefaultTemplate.yml',
46
            ]
47
        );
48
        $template = new Template();
49
        $template->setType("email");
50
        $template->setName("Ceci est mon nom");
51
        $template->setObject("Ceci est mon sujet");
52
        $template->setMessage("Ceci est mon message");
53
        $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...
54
        $this->manager->insert($template);
55
        $this->assertCount(2, $this->manager->findAll());
56
    }
57
58
    /**
59
     * @group template
60
     * @group manager
61
     */
62
    public function testUpdateCampaign()
63
    {
64
        $this->loadFixtureFiles(
65
            [
66
                '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml',
67
68
                '@StarkerxpCampaignBundle/Tests/DataFixtures/TemplateManager/DefaultTemplate.yml',
69
            ]
70
        );
71
        $template = $this->manager->findOneBy(['uuid' => "5e6e63e6-1d74-4c4c-b19a-2741ed330836"]);
72
        $type = $template->getType();
73
        $template->setType("sms");
74
        $this->manager->update($template);
0 ignored issues
show
Documentation introduced by
$template is of type object|null, but the function expects a object<Starkerxp\Structu...\Entity\AbstractEntity>.

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...
75
        $this->manager->clear();
76
        $template = $this->manager->findOneBy(['uuid' => "5e6e63e6-1d74-4c4c-b19a-2741ed330836"]);
77
        $this->assertNotEquals($type, $template->getType());
78
    }
79
}
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...
80