/** * @test */ public function settingRequestAdminPropertySetsAdminRoleInUserAuthentication() { $mockedUserAuthentication = $this->getMock(\TYPO3\CMS\Core\Authentication\AbstractUserAuthentication::class); $mockedUserAuthentication->user['admin'] = 42; $this->commandController->expects($this->once())->method('dummyCommand')->will($this->returnCallback(function () use($mockedUserAuthentication) { if ($mockedUserAuthentication->user['admin'] !== 1) { throw new \Exception('User role is not admin'); } })); $this->commandController->_set('userAuthentication', $mockedUserAuthentication); $this->commandController->_set('arguments', array()); $this->commandController->_set('commandMethodName', 'dummyCommand'); $this->commandController->_set('requestAdminPermissions', TRUE); $this->commandController->_call('callCommandMethod'); $this->assertSame(42, $mockedUserAuthentication->user['admin']); }