/** * @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']); }
/** * Call command */ protected function callCommandMethod() { $this->settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'newsImporter'); /** @var StorageRepository $storageRepository */ $storageRepository = $this->objectManager->get(StorageRepository::class); foreach ($storageRepository->findAll() as $storage) { $storage->setEvaluatePermissions(FALSE); } parent::callCommandMethod(); }