Completed
Push — master ( 4b99be...c5d644 )
by Guillaume
12:29
created

testInsertNewCampaignTarget()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace Starkerxp\CampaignBundle\Tests\Manager;
4
5
use Starkerxp\CampaignBundle\Entity\CampaignTarget;
6
use Starkerxp\CampaignBundle\Manager\CampaignTargetManager;
7
use Starkerxp\StructureBundle\Tests\WebTest;
8
9
class CampaignTargetManagerTest extends WebTest
10
{
11
12
    /** @var  CampaignTargetManager */
13
    protected $manager;
14
15
    public function setUp()
16
    {
17
        parent::setUp();
18
        $this->manager = $this->getContainer()->get('starkerxp_campaign.manager.cible');
19
    }
20
21
    /**
22
     * @group cible
23
     * @group manager
24
     */
25
    public function testFindAll()
26
    {
27
        $this->loadFixtureFiles(
28
            [
29
                '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml',
30
                '@StarkerxpCampaignBundle/Tests/DataFixtures/CampaignManager/CampaignManager.yml',
31
                '@StarkerxpCampaignBundle/Tests/DataFixtures/CampaignTargetManager/CampaignTargetManager.yml',
32
            ]
33
        );
34
        $this->assertCount(10, $this->manager->findAll());
35
    }
36
37
    /**
38
     * @group cible
39
     * @group manager
40
     */
41
    public function testInsertNewCampaignTarget()
42
    {
43
        $this->loadFixtureFiles(
44
            [
45
                '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml',
46
                '@StarkerxpCampaignBundle/Tests/DataFixtures/CampaignManager/CampaignManager.yml',
47
                '@StarkerxpCampaignBundle/Tests/DataFixtures/CampaignTargetManager/DefaultCampaignTarget.yml',
48
            ]
49
        );
50
        $campaigns = $this->getRepository("StarkerxpCampaignBundle:Campaign")->findBy([], ['id' => 'ASC']);
51
        $cible = new CampaignTarget();
52
        $cible->setCampaign($campaigns[1]);
53
        $this->manager->insert($cible);
54
        $this->assertCount(2, $this->manager->findAll());
55
    }
56
57
    /**
58
     * @group cible
59
     * @group manager
60
     */
61 View Code Duplication
    public function testUpdateCampaignTarget()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
    {
63
        $this->loadFixtureFiles(
64
            [
65
                '@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml',
66
                '@StarkerxpCampaignBundle/Tests/DataFixtures/CampaignManager/CampaignManager.yml',
67
                '@StarkerxpCampaignBundle/Tests/DataFixtures/CampaignTargetManager/DefaultCampaignTarget.yml',
68
            ]
69
        );
70
        $criteria = ['createdAt' => new \DateTime("2016-08-05 12:12:12")];
71
        $cible = $this->manager->findOneBy($criteria);
72
        $this->manager->update($cible);
0 ignored issues
show
Documentation introduced by
$cible 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...
73
        $ciblePostUpdate = $this->manager->findOneBy($criteria);
74
        $this->assertNotEmpty($ciblePostUpdate->getUpdatedAt());
75
    }
76
77
}
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...
78