These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminBundle\Tests\Entity; |
||
4 | |||
5 | use Doctrine\Common\Collections\ArrayCollection; |
||
6 | use FOS\UserBundle\Model\GroupInterface; |
||
7 | use Kunstmaan\AdminBundle\Entity\User; |
||
8 | use PHPUnit\Framework\TestCase; |
||
9 | use Symfony\Component\Validator\Mapping\ClassMetadata; |
||
10 | |||
11 | /** |
||
12 | * Generated by PHPUnit_SkeletonGenerator on 2012-09-04 at 16:54:04. |
||
13 | */ |
||
14 | class UserTest extends TestCase |
||
15 | { |
||
16 | /** |
||
17 | * @var User |
||
18 | */ |
||
19 | protected $object; |
||
20 | |||
21 | /** |
||
22 | * Sets up the fixture, for example, opens a network connection. |
||
23 | * This method is called before a test is executed. |
||
24 | */ |
||
25 | protected function setUp() |
||
26 | { |
||
27 | $this->object = new User(); |
||
28 | } |
||
29 | |||
30 | public function test__construct() |
||
31 | { |
||
32 | $object = new User(); |
||
33 | $object->setId(1); |
||
34 | $this->assertEquals(1, $object->getId()); |
||
35 | } |
||
36 | |||
37 | public function testGetSetId() |
||
38 | { |
||
39 | $this->object->setId(3); |
||
40 | $this->assertEquals(3, $this->object->getId()); |
||
41 | } |
||
42 | |||
43 | public function testGetGroupIds() |
||
44 | { |
||
45 | $group1 = $this->createMock('FOS\UserBundle\Model\GroupInterface'); |
||
46 | $group1 |
||
47 | ->expects($this->once()) |
||
48 | ->method('getId') |
||
49 | ->will($this->returnValue(1)); |
||
50 | |||
51 | $group2 = $this->createMock('FOS\UserBundle\Model\GroupInterface'); |
||
52 | $group2 |
||
53 | ->expects($this->once()) |
||
54 | ->method('getId') |
||
55 | ->will($this->returnValue(2)); |
||
56 | |||
57 | /* @var $group1 GroupInterface */ |
||
58 | $this->object->addGroup($group1); |
||
59 | /* @var $group2 GroupInterface */ |
||
60 | $this->object->addGroup($group2); |
||
61 | |||
62 | $this->assertEquals(array(1, 2), $this->object->getGroupIds()); |
||
63 | } |
||
64 | |||
65 | View Code Duplication | public function testGetGroups() |
|
66 | { |
||
67 | /* @var $group1 GroupInterface */ |
||
68 | $group1 = $this->createMock('FOS\UserBundle\Model\GroupInterface'); |
||
69 | /* @var $group2 GroupInterface */ |
||
70 | $group2 = $this->createMock('FOS\UserBundle\Model\GroupInterface'); |
||
71 | $this->object->addGroup($group1); |
||
72 | $this->object->addGroup($group2); |
||
73 | |||
74 | $collection = new ArrayCollection(); |
||
75 | $collection->add($group1); |
||
76 | $collection->add($group2); |
||
77 | |||
78 | $this->assertEquals($collection, $this->object->getGroups()); |
||
79 | } |
||
80 | |||
81 | View Code Duplication | public function testHasRole() |
|
82 | { |
||
83 | $this->object->addRole('ROLE_CUSTOM'); |
||
84 | $this->assertTrue($this->object->hasRole('ROLE_CUSTOM')); |
||
85 | |||
86 | $this->object->removeRole('ROLE_CUSTOM'); |
||
87 | $this->assertFalse($this->object->hasRole('ROLE_CUSTOM')); |
||
88 | } |
||
89 | |||
90 | public function testGettersAndSetters() |
||
91 | { |
||
92 | $user = $this->object; |
||
93 | $user->setAdminLocale('en'); |
||
94 | $user->setPasswordChanged(true); |
||
95 | $user->setGoogleId('g0oGl3'); |
||
96 | $user->setEnabled(true); |
||
97 | |||
98 | $this->assertEquals('en', $user->getAdminLocale()); |
||
99 | $this->assertEquals('g0oGl3', $user->getGoogleId()); |
||
100 | $this->assertTrue($user->isPasswordChanged()); |
||
101 | $this->assertTrue($user->isAccountNonLocked()); |
||
102 | $this->assertEquals('Kunstmaan\AdminBundle\Form\UserType', $user->getFormTypeClass()); |
||
103 | } |
||
104 | |||
105 | public function testLoadValidatorMetadata() |
||
106 | { |
||
107 | $meta = new ClassMetadata(User::class); |
||
108 | User::loadValidatorMetadata($meta); |
||
109 | $this->assertEquals('Kunstmaan\AdminBundle\Entity\User', $meta->getClassName()); |
||
110 | $this->assertEquals('User', $meta->getDefaultGroup()); |
||
111 | $props = $meta->getConstrainedProperties(); |
||
112 | $this->assertCount(3, $props); |
||
0 ignored issues
–
show
|
|||
113 | $this->assertEquals('username', $props[0]); |
||
114 | $this->assertEquals('plainPassword', $props[1]); |
||
115 | $this->assertEquals('email', $props[2]); |
||
116 | } |
||
117 | } |
||
118 |
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: