コード例 #1
0
 /**
  * Tests the ability to set and then get options.
  */
 public function testGetOptions()
 {
     $this->groupService->setOptionsFor('ADMIN', $this->optionData['admin']);
     $this->groupService->setOptionsFor('USER', $this->optionData['user']);
     $options = $this->groupService->getOptionsFor('ADMIN');
     $this->assertEquals($this->optionData['admin'], $options);
     // setting; category: acp, option: access
     $this->assertTrue($this->groupService->get('ADMIN', 'acp', 'twomartens.core', 'access')->getValue());
     // the various option types are tested separately
     // here we should only test the core functionality of getEffective
     $user = $this->getMock('\\TwoMartens\\Bundle\\CoreBundle\\Model\\User');
     $user->expects($this->any())->method('getGroupNames')->willReturn(['ADMIN', 'USER']);
     /** @var User $user */
     $option = $this->groupService->getEffective($user, 'acp', 'twomartens.core', 'access');
     $this->assertTrue($option->getValue());
     $option->setValue(false);
     $this->groupService->set('ADMIN', 'acp', 'twomartens.core', $option);
     $this->assertFalse($this->groupService->getEffective($user, 'acp', 'twomartens.core', 'access')->getValue());
     $option = $this->groupService->getEffective($user, 'acp', 'twomartens.core', 'carpot');
     $this->assertNull($option);
 }