/** * @test */ public function isAccessibleReturnsTrueIfRoleIsEveryone() { $mockSecurityContext = $this->getMock('TYPO3\\Flow\\Security\\Context'); $mockSecurityContext->expects($this->any())->method('isInitialized')->will($this->returnValue(TRUE)); $mockSecurityContext->expects($this->at(0))->method('hasRole')->with('SomeRole')->will($this->returnValue(FALSE)); $mockSecurityContext->expects($this->at(1))->method('hasRole')->with('Everyone')->will($this->returnValue(TRUE)); $this->nodeData->_set('securityContext', $mockSecurityContext); $this->nodeData->setAccessRoles(array('SomeRole', 'Everyone', 'SomeOtherRole')); $this->assertTrue($this->nodeData->isAccessible()); }
/** * @test */ public function isAccessibleReturnsTrueIfRoleIsEveryone() { /** @var Context|\PHPUnit_Framework_MockObject_MockObject $mockSecurityContext */ $mockSecurityContext = $this->createMock('TYPO3\\Flow\\Security\\Context'); $mockSecurityContext->expects($this->at(0))->method('canBeInitialized')->will($this->returnValue(true)); $mockSecurityContext->expects($this->at(1))->method('hasRole')->with('SomeRole')->will($this->returnValue(false)); $mockSecurityContext->expects($this->at(2))->method('hasRole')->with('Everyone')->will($this->returnValue(true)); $this->inject($this->nodeData, 'securityContext', $mockSecurityContext); $this->nodeData->setAccessRoles(array('SomeRole', 'Everyone', 'SomeOtherRole')); $this->assertTrue($this->nodeData->isAccessible()); }
/** * Tells if this node may be accessed according to the current security context. * * @return boolean * @api */ public function isAccessible() { return $this->nodeData->isAccessible(); }