コード例 #1
0
 public function testSettingMultipleGroups()
 {
     // Given
     $user = new BaseUser();
     $group1 = $this->getMock('FOS\\UserBundle\\Model\\GroupInterface');
     $group1->expects($this->any())->method('getName')->will($this->returnValue('Group 1'));
     $group2 = $this->getMock('FOS\\UserBundle\\Model\\GroupInterface');
     $group2->expects($this->any())->method('getName')->will($this->returnValue('Group 2'));
     // When
     $user->setGroups(array($group1, $group2));
     // Then
     $this->assertCount(2, $user->getGroups(), 'Should have 2 groups');
     $this->assertTrue($user->hasGroup('Group 1'), 'Should have a group named "Group 1"');
     $this->assertTrue($user->hasGroup('Group 2'), 'Should have a group named "Group 2"');
 }