/** * Setup function for the test case */ public function setUp() { $administratorRole = new Role('TYPO3.Flow:Administrator'); $this->administratorRole = $administratorRole; $customerRole = new Role('TYPO3.Flow:Customer'); $this->customerRole = $customerRole; $mockPolicyService = $this->getMock('TYPO3\\Flow\\Security\\Policy\\PolicyService'); $mockPolicyService->expects($this->any())->method('getRole')->will($this->returnCallback(function ($roleIdentifier) use($administratorRole, $customerRole) { switch ($roleIdentifier) { case 'TYPO3.Flow:Administrator': return $administratorRole; break; case 'TYPO3.Flow:Customer': return $customerRole; break; default: throw new NoSuchRoleException(); } })); $mockPolicyService->expects($this->any())->method('hasRole')->will($this->returnCallback(function ($roleIdentifier) use($administratorRole, $customerRole) { switch ($roleIdentifier) { case 'TYPO3.Flow:Administrator': case 'TYPO3.Flow:Customer': return TRUE; break; default: return FALSE; } })); $this->account = $this->getAccessibleMock('TYPO3\\Flow\\Security\\Account', array('dummy')); $this->account->_set('policyService', $mockPolicyService); }