/** * Sets up the fixture */ protected function setUp() { $mockUser = $this->getMockBuilder('\\Nethgui\\Authorization\\UserInterface')->disableOriginalConstructor()->setMethods(array('authenticate', 'getAuthorizationAttribute', 'asAuthorizationString', 'isAuthenticated', 'getCredential', 'getCredentials', 'hasCredential', 'getLanguageCode'))->getMock(); $mockSession = $this->getMockBuilder('\\Nethgui\\Utility\\SessionInterface')->disableOriginalConstructor()->setMethods(array('retrieve', 'store', 'login', 'logout'))->getMock(); $mockSession->expects($this->atLeastOnce())->method('retrieve')->with($this->anything())->will($this->returnValue(new \ArrayObject())); $pdpMock = $this->getMock('Nethgui\\Authorization\\PolicyDecisionPointInterface'); $pdpMock->expects($this->any())->method('authorize')->will($this->returnValue(\Nethgui\Authorization\LazyAccessControlResponse::createSuccessResponse())); $this->globalsMock = $this->getMock('\\Nethgui\\Utility\\PhpWrapper'); $this->object = new \Nethgui\System\NethPlatform($mockUser); $this->object->setSession($mockSession); $this->object->setPhpWrapper($this->globalsMock); $this->object->setPolicyDecisionPoint($pdpMock); }
/** * Construct an object to access a SME Configuration database file * with $user's privileges. * * @param string $database Database name */ public function __construct($database, \Nethgui\Authorization\UserInterface $user) { if (!$database) { throw new \InvalidArgumentException(sprintf("%s: You must provide a valid database name.", get_class($this)), 1322148910); } $this->db = $database; $this->user = $user; $this->log = new \Nethgui\Log\Nullog(); $this->readPermission = \Nethgui\Authorization\LazyAccessControlResponse::createDenyResponse(); $this->writePermission = \Nethgui\Authorization\LazyAccessControlResponse::createDenyResponse(); }
public function testCreateSuccessResponse() { $i = \Nethgui\Authorization\LazyAccessControlResponse::createSuccessResponse(); $this->assertTrue($i->isAllowed()); }