| Conditions | 1 |
| Paths | 1 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function testGroupDefinitionAware() |
||
| 15 | { |
||
| 16 | $group = $this->getMockBuilder('Opensoft\RolloutBundle\Rollout\GroupDefinitionInterface')->getMock(); |
||
| 17 | $group->expects($this->once())->method('getName')->will($this->returnValue('test_group')); |
||
| 18 | |||
| 19 | $callback = function (RolloutUserInterface $user) { |
||
| 20 | return $user->name == 'test_user'; |
||
|
|
|||
| 21 | }; |
||
| 22 | |||
| 23 | $group->expects($this->once())->method('getCallback')->will($this->returnValue($callback)); |
||
| 24 | |||
| 25 | $rollout = new GroupDefinitionAwareRollout(new ArrayStorage()); |
||
| 26 | |||
| 27 | $rollout->addGroupDefinition($group); |
||
| 28 | |||
| 29 | $this->assertEquals(1, count($rollout->getGroupDefinitions())); |
||
| 30 | $this->assertTrue($rollout->isActiveInGroup('test_group', new User('test_user'))); |
||
| 31 | $this->assertFalse($rollout->isActiveInGroup('test_group', new User('other_user'))); |
||
| 32 | } |
||
| 33 | } |
||
| 55 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: