UserManagerTest::testFindAll()   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\UserBundle\Tests\Manager;
4
5
use Starkerxp\StructureBundle\Test\WebTest;
6
use Starkerxp\UserBundle\Entity\User;
7
use Starkerxp\UserBundle\Manager\UserManager;
8
9
class UserManagerTest extends WebTest
10
{
11
12
    /** @var  UserManager */
13
    protected $manager;
14
15
    public function setUp()
16
    {
17
        parent::setUp();
18
        $this->manager = $this->getContainer()->get('starkerxp_user.manager.user');
19
    }
20
21
    /**
22
     * @group user
23
     * @group manager
24
     */
25
    public function testFindAll()
26
    {
27
        $this->loadFixtureFiles(['@StarkerxpUserBundle/Tests/DataFixtures/UserManager/UserManager.yml',]);
28
        $this->assertCount(10, $this->manager->findAll());
29
    }
30
31
    /**
32
     * @group user
33
     * @group manager
34
     */
35
    public function testInsertNewUser()
36
    {
37
        $this->loadFixtureFiles(['@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml',]);
38
        $user = new User('[email protected]', ["ROLE_SUPER_ADMIN"]);
39
        $user->setPlainPassword("azerty");
40
        $this->manager->insert($user);
41
        $this->assertCount(2, $this->manager->findAll());
42
    }
43
44
    /**
45
     * @group user
46
     * @group manager
47
     */
48 View Code Duplication
    public function testUpdateUser()
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...
49
    {
50
        $this->loadFixtureFiles(['@StarkerxpUserBundle/Tests/DataFixtures/UserManager/DefaultUser.yml',]);
51
        $criteria = ['createdAt' => new \DateTime("2017-05-20 00:31:47")];
52
        /** @var User $user */
53
        $user = $this->manager->findOneBy($criteria);
54
        $this->manager->update($user);
55
        $userPostUpdate = $this->manager->findOneBy($criteria);
56
        $this->assertNotEmpty($userPostUpdate->getUpdatedAt());
57
    }
58
59
}
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...
60