From 9446c24db0f8320210afa67428c80c64d96df5cd Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 20 Jul 2024 17:50:49 +0200 Subject: [PATCH] Removed Enterprise Edition commands --- config.yaml | 11 -- .../Command/Admin/User/LockCommand.php | 94 --------------- .../Command/Admin/User/LockdownCommand.php | 90 --------------- .../Command/Admin/User/UnlockCommand.php | 108 ------------------ .../Command/Cms/Banner/ToggleCommand.php | 78 ------------- .../Command/Cms/Page/PublishCommand.php | 95 --------------- .../GiftCard/AbstractGiftCardCommand.php | 21 ---- .../Command/GiftCard/CreateCommand.php | 64 ----------- .../Magento/Command/GiftCard/InfoCommand.php | 76 ------------ .../Command/GiftCard/Pool/GenerateCommand.php | 43 ------- .../Command/GiftCard/RemoveCommand.php | 55 --------- .../Command/Indexer/ListMviewCommand.php | 90 --------------- .../Command/Indexer/ReindexMviewCommand.php | 72 ------------ .../Command/Admin/User/LockCommandTest.php | 31 ----- .../Admin/User/UnlockUserCommandTest.php | 68 ----------- 15 files changed, 996 deletions(-) delete mode 100644 src/N98/Magento/Command/Admin/User/LockCommand.php delete mode 100644 src/N98/Magento/Command/Admin/User/LockdownCommand.php delete mode 100644 src/N98/Magento/Command/Admin/User/UnlockCommand.php delete mode 100644 src/N98/Magento/Command/Cms/Banner/ToggleCommand.php delete mode 100644 src/N98/Magento/Command/Cms/Page/PublishCommand.php delete mode 100644 src/N98/Magento/Command/GiftCard/AbstractGiftCardCommand.php delete mode 100644 src/N98/Magento/Command/GiftCard/CreateCommand.php delete mode 100644 src/N98/Magento/Command/GiftCard/InfoCommand.php delete mode 100644 src/N98/Magento/Command/GiftCard/Pool/GenerateCommand.php delete mode 100644 src/N98/Magento/Command/GiftCard/RemoveCommand.php delete mode 100644 src/N98/Magento/Command/Indexer/ListMviewCommand.php delete mode 100644 src/N98/Magento/Command/Indexer/ReindexMviewCommand.php delete mode 100644 tests/N98/Magento/Command/Admin/User/LockCommandTest.php delete mode 100644 tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php diff --git a/config.yaml b/config.yaml index 5529159bd..6e3530c01 100644 --- a/config.yaml +++ b/config.yaml @@ -52,9 +52,6 @@ commands: - N98\Magento\Command\Admin\User\ListCommand - N98\Magento\Command\Admin\User\DeleteUserCommand - N98\Magento\Command\Admin\User\ChangeStatusCommand - - N98\Magento\Command\Admin\User\LockCommand - - N98\Magento\Command\Admin\User\LockdownCommand - - N98\Magento\Command\Admin\User\UnlockCommand - N98\Magento\Command\Cache\CleanCommand - N98\Magento\Command\Cache\Dir\FlushCommand - N98\Magento\Command\Cache\DisableCommand @@ -64,10 +61,8 @@ commands: - N98\Magento\Command\Cache\ReportCommand - N98\Magento\Command\Cache\ViewCommand - N98\Magento\Command\Category\Create\DummyCommand - - N98\Magento\Command\Cms\Banner\ToggleCommand - N98\Magento\Command\Cms\Block\ListCommand - N98\Magento\Command\Cms\Block\ToggleCommand - - N98\Magento\Command\Cms\Page\PublishCommand - N98\Magento\Command\Config\DeleteCommand - N98\Magento\Command\Config\DumpCommand - N98\Magento\Command\Config\GetCommand @@ -127,14 +122,8 @@ commands: - N98\Magento\Command\Eav\Attribute\ListCommand - N98\Magento\Command\Eav\Attribute\RemoveCommand - N98\Magento\Command\Eav\Attribute\ViewCommand - - N98\Magento\Command\GiftCard\CreateCommand - - N98\Magento\Command\GiftCard\InfoCommand - - N98\Magento\Command\GiftCard\RemoveCommand - - N98\Magento\Command\GiftCard\Pool\GenerateCommand - N98\Magento\Command\Indexer\ListCommand - - N98\Magento\Command\Indexer\ListMviewCommand - N98\Magento\Command\Indexer\ReindexAllCommand - - N98\Magento\Command\Indexer\ReindexMviewCommand - N98\Magento\Command\Indexer\ReindexCommand - N98\Magento\Command\Installer\InstallCommand - N98\Magento\Command\Installer\UninstallCommand diff --git a/src/N98/Magento/Command/Admin/User/LockCommand.php b/src/N98/Magento/Command/Admin/User/LockCommand.php deleted file mode 100644 index c51fd4635..000000000 --- a/src/N98/Magento/Command/Admin/User/LockCommand.php +++ /dev/null @@ -1,94 +0,0 @@ -setName('admin:user:lock') - ->addArgument('username', InputArgument::REQUIRED, 'Admin username to lock') - ->addArgument('lifetime', InputArgument::OPTIONAL, 'Optional - lock lifetime in days (default one month)') - ->setDescription( - <<getApplication()->isMagentoEnterprise(); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return void - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - - $username = $input->getArgument('username'); - $lifetime = $input->getArgument('lifetime') ?: $this->daysToSeconds(self::LIFETIME_DEFAULT); - - $user = Mage::getModel('admin/user')->loadByUsername($username); - if (!$user || !$user->getId()) { - $output->writeln("Couldn't find admin username '{$username}'"); - return 0; - } - - Mage::getResourceModel('enterprise_pci/admin_user')->lock($user->getId(), 0, $lifetime); - - $lifetimeMessage = ''; - if ($input->getArgument('lifetime')) { - $lifetimeMessage = sprintf(' for %d days.', $input->getArgument('lifetime')); - } - - $output->writeln( - sprintf('%s locked%s', $username, $lifetimeMessage) - ); - return 0; - } - - /** - * Convert a number of days to seconds for the lock lifetime parameter - * - * @param int $days - * @return int Seconds - */ - public function daysToSeconds($days) - { - return $days * 24 * 60 * 60; - } -} diff --git a/src/N98/Magento/Command/Admin/User/LockdownCommand.php b/src/N98/Magento/Command/Admin/User/LockdownCommand.php deleted file mode 100644 index 613a89c8b..000000000 --- a/src/N98/Magento/Command/Admin/User/LockdownCommand.php +++ /dev/null @@ -1,90 +0,0 @@ -setName('admin:user:lockdown') - ->addArgument('lifetime', InputArgument::OPTIONAL, 'Optional - lock lifetime in days (default one month)') - ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Dry run mode') - ->setDescription( - <<detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - - if ($dryrun = $input->getOption('dry-run')) { - $output->writeln('Dry run mode enabled.'); - } - - $lifetime = $input->getArgument('lifetime') ?: $this->daysToSeconds(self::LIFETIME_DEFAULT); - - $userIds = Mage::getModel('admin/user')->getCollection()->getAllIds(); - - if (empty($userIds)) { - $output->writeln('No admin users were found!'); - return 0; - } - - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); - $confirm = $dialog->ask( - $input, - $output, - new ConfirmationQuestion(sprintf('Really lock all %d admin users? [n]: ', is_countable($userIds) ? count($userIds) : 0), false) - ); - - if (!$confirm) { - return 0; - } - - if (!$dryrun) { - Mage::getResourceModel('enterprise_pci/admin_user')->lock($userIds, 0, $lifetime); - } - - $lifetimeMessage = ''; - if ($input->getArgument('lifetime')) { - $lifetimeMessage = sprintf(' for %d days.', $input->getArgument('lifetime')); - } - - $output->writeln( - sprintf('All %d admins locked%s', is_countable($userIds) ? count($userIds) : 0, $lifetimeMessage) - ); - return 0; - } -} diff --git a/src/N98/Magento/Command/Admin/User/UnlockCommand.php b/src/N98/Magento/Command/Admin/User/UnlockCommand.php deleted file mode 100644 index 850f57eeb..000000000 --- a/src/N98/Magento/Command/Admin/User/UnlockCommand.php +++ /dev/null @@ -1,108 +0,0 @@ -setName('admin:user:unlock') - ->addArgument( - 'username', - InputArgument::OPTIONAL, - 'Admin Username to Unlock' - ) - ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Dry run mode') - ->setDescription('Release lock on admin user for one or all users'); - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->getApplication()->isMagentoEnterprise(); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return void - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - $this->requireEnterprise($output); - if (!$this->initMagento()) { - return 0; - } - - if ($dryrun = $input->getOption('dry-run')) { - $output->writeln('Dry run mode enabled.'); - } - - // Unlock a single admin account - if ($username = $input->getArgument('username')) { - $user = Mage::getModel('admin/user')->loadByUsername($username); - if (!$user || !$user->getId()) { - $output->writeln('Couldn\'t find admin ' . $username . ''); - return 0; - } - Mage::getResourceModel('enterprise_pci/admin_user')->unlock($user->getId()); - $output->writeln('' . $username . ' unlocked'); - return 0; - } - - // Unlock all admin accounts - $userIds = Mage::getModel('admin/user')->getCollection()->getAllIds(); - - if (empty($userIds)) { - $output->writeln('No admin users found.'); - return 0; - } - - /* @var QuestionHelper $dialog */ - $dialog = $this->getHelper('question'); - $shouldUnlockAll = $dialog->ask( - $input, - $output, - new ConfirmationQuestion( - sprintf( - 'Really unlock all %d admin users? [n]: ', - is_countable($userIds) ? count($userIds) : 0 - ), - false - ) - ); - - if ($shouldUnlockAll) { - if (!$dryrun) { - Mage::getResourceModel('enterprise_pci/admin_user')->unlock($userIds); - } - $output->writeln( - sprintf('All %d admin users unlocked', is_countable($userIds) ? count($userIds) : 0) - ); - } - return 0; - } -} diff --git a/src/N98/Magento/Command/Cms/Banner/ToggleCommand.php b/src/N98/Magento/Command/Cms/Banner/ToggleCommand.php deleted file mode 100644 index d41ec1d7d..000000000 --- a/src/N98/Magento/Command/Cms/Banner/ToggleCommand.php +++ /dev/null @@ -1,78 +0,0 @@ -setName('cms:banner:toggle') - ->addArgument('banner_id', InputArgument::REQUIRED, 'Banner ID') - ->setDescription('Toggle a banner (Enterprise only)') - ; - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->getApplication()->isMagentoEnterprise(); - } - - /** - * @return \Enterprise_Banner_Model_Banner - */ - protected function _getBannerModel() - { - return $this->_getModel('enterprise_banner/banner', '\Enterprise_Banner_Model_Banner'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - $this->requireEnterprise($output); - if (!$this->initMagento()) { - return 0; - } - - $this->writeSection($output, 'Banner Toggle'); - $bannerId = $input->getArgument('banner_id'); - - $banner = $this->_getBannerModel()->load($bannerId); - - if (!$banner->getId()) { - $output->writeln('Banner was not found'); - return 0; - } - - $disabled = !$banner->getIsEnabled(); - $comment = 'Banner ' - . '' . (!$disabled ? 'disabled' : 'enabled') . ''; - - $banner->setIsEnabled($disabled); - $banner->save(); - $output->writeln($comment); - return 0; - } -} diff --git a/src/N98/Magento/Command/Cms/Page/PublishCommand.php b/src/N98/Magento/Command/Cms/Page/PublishCommand.php deleted file mode 100644 index f26b91f81..000000000 --- a/src/N98/Magento/Command/Cms/Page/PublishCommand.php +++ /dev/null @@ -1,95 +0,0 @@ -setName('cms:page:publish') - ->addArgument( - 'page_id', - InputArgument::REQUIRED, - 'Even if the Revision ID is unique, we require the page id for security reasons' - ) - ->addArgument('revision_id', InputArgument::REQUIRED, 'Revision ID (the ID, not the sequential number)') - ->setDescription('Publish a CMS page revision (Enterprise only)'); - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->getApplication()->isMagentoEnterprise(); - } - - /** - * @return \Mage_Cms_Model_Page - */ - protected function _getPageModel() - { - return $this->_getModel('cms/page', 'Mage_Cms_Model_Page'); - } - - /** - * @return \Enterprise_Cms_Model_Page_Revision - */ - protected function _getPageRevisionModel() - { - return $this->_getModel('enterprise_cms/page_revision', '\Enterprise_Cms_Model_Page_Revision'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - $this->requireEnterprise($output); - if (!$this->initMagento()) { - return 0; - } - - $this->writeSection($output, 'CMS Publish'); - $pageId = $input->getArgument('page_id'); - $revisionId = $input->getArgument('revision_id'); - - $revision = $this->_getPageRevisionModel()->load($revisionId); - - if (!$revision->getId()) { - $output->writeln('Revision was not found'); - - return 0; - } - - if ($revision->getPageId() != $pageId) { - $output->writeln(sprintf( - 'Revision\'s page id (%d) does not match the given page id', - $revision->getPageId() - )); - - return 0; - } - $revision->publish(); - $output->writeln('Page published'); - return 0; - } -} diff --git a/src/N98/Magento/Command/GiftCard/AbstractGiftCardCommand.php b/src/N98/Magento/Command/GiftCard/AbstractGiftCardCommand.php deleted file mode 100644 index b7a7031ad..000000000 --- a/src/N98/Magento/Command/GiftCard/AbstractGiftCardCommand.php +++ /dev/null @@ -1,21 +0,0 @@ -getApplication()->isMagentoEnterprise(); - } -} diff --git a/src/N98/Magento/Command/GiftCard/CreateCommand.php b/src/N98/Magento/Command/GiftCard/CreateCommand.php deleted file mode 100644 index 891ace802..000000000 --- a/src/N98/Magento/Command/GiftCard/CreateCommand.php +++ /dev/null @@ -1,64 +0,0 @@ -setName('giftcard:create') - ->addArgument( - 'amount', - InputArgument::REQUIRED, - 'Amount for new gift card' - ) - ->addOption( - 'website', - null, - InputOption::VALUE_OPTIONAL, - 'Website ID to attach gift card to' - ) - ->setDescription('Create a gift card with a specified amount'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - $data = ['status' => 1, 'is_redeemable' => 1, 'website_id' => $input->getOption('website') ?: Mage::app()->getStore(true)->getWebsiteId(), 'balance' => $input->getArgument('amount')]; - $id = Mage::getModel('enterprise_giftcardaccount/api')->create($data); - if (!$id) { - $output->writeln('Failed to create gift card'); - } - $code = Mage::getModel('enterprise_giftcardaccount/giftcardaccount') - ->load($id) - ->getCode(); - $output->writeln('Gift card ' . $code . ' was created'); - return 0; - } -} diff --git a/src/N98/Magento/Command/GiftCard/InfoCommand.php b/src/N98/Magento/Command/GiftCard/InfoCommand.php deleted file mode 100644 index 2c06d0f21..000000000 --- a/src/N98/Magento/Command/GiftCard/InfoCommand.php +++ /dev/null @@ -1,76 +0,0 @@ -setName('giftcard:info') - ->addArgument('code', InputArgument::REQUIRED, 'Gift card code') - ->addFormatOption() - ->setDescription('Get gift card account information by code'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - $this->requireEnterprise($output); - - if (!class_exists('Enterprise_GiftCardAccount_Model_Giftcardaccount')) { - return 0; - } - - if (!$this->initMagento()) { - return 0; - } - - /** @var \Enterprise_GiftCardAccount_Model_Giftcardaccount $card */ - $card = Mage::getModel('enterprise_giftcardaccount/giftcardaccount')->loadByCode($input->getArgument('code')); - if (!$card->getId()) { - $output->writeln('No gift card found for that code'); - return 0; - } - $data = [ - ['Gift Card Account ID', $card->getId()], - ['Code', $card->getCode()], - ['Status', \Enterprise_GiftCardAccount_Model_Giftcardaccount::STATUS_ENABLED == $card->getStatus() ? 'Enabled' : 'Disabled'], - ['Date Created', $card->getDateCreated()], - ['Expiration Date', $card->getDateExpires()], - ['Website ID', $card->getWebsiteId()], - ['Remaining Balance', $card->getBalance()], - ['State', $card->getStateText()], - ['Is Redeemable', $card->getIsRedeemable()] - ]; - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders(['Name', 'Value']) - ->setRows($data) - ->renderByFormat($output, $data, $input->getOption('format')); - return 0; - } -} diff --git a/src/N98/Magento/Command/GiftCard/Pool/GenerateCommand.php b/src/N98/Magento/Command/GiftCard/Pool/GenerateCommand.php deleted file mode 100644 index 4229551ed..000000000 --- a/src/N98/Magento/Command/GiftCard/Pool/GenerateCommand.php +++ /dev/null @@ -1,43 +0,0 @@ -setName('giftcard:pool:generate') - ->setDescription('Generate giftcard pool'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - - Mage::getModel('enterprise_giftcardaccount/pool')->generatePool(); - $output->writeln('New pool was generated.'); - return 0; - } -} diff --git a/src/N98/Magento/Command/GiftCard/RemoveCommand.php b/src/N98/Magento/Command/GiftCard/RemoveCommand.php deleted file mode 100644 index 33ed5d40c..000000000 --- a/src/N98/Magento/Command/GiftCard/RemoveCommand.php +++ /dev/null @@ -1,55 +0,0 @@ -setName('giftcard:remove') - ->addArgument('code', InputArgument::REQUIRED, 'Gift card code') - ->setDescription('Remove a gift card account by code'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $this->detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - $accounts = Mage::getModel('enterprise_giftcardaccount/giftcardaccount')->getCollection() - ->addFieldToFilter('code', $input->getArgument('code')); - if (!$accounts->count()) { - $output->writeln('No gift cards with matching code found'); - } else { - foreach ($accounts as $account) { - $id = $account->getId(); - $account->delete(); - $output->writeln('Deleted gift card account id ' . $id . ''); - } - } - return 0; - } -} diff --git a/src/N98/Magento/Command/Indexer/ListMviewCommand.php b/src/N98/Magento/Command/Indexer/ListMviewCommand.php deleted file mode 100644 index 944c23c78..000000000 --- a/src/N98/Magento/Command/Indexer/ListMviewCommand.php +++ /dev/null @@ -1,90 +0,0 @@ -setName('index:list:mview') - ->setDescription('Lists all magento mview indexes') - ->addFormatOption() - ; - } - - /** - * {@inheritdoc} - */ - public function getHelp(): string - { - return <<detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - - $table = []; - foreach ($this->getMetaDataCollection() as $index) { - $changelogName = $index->getData('changelog_name'); - $versionId = $index->getData('version_id'); - $pendingCount = $this->getPendingChangelogsCount($changelogName, $versionId); - if ($pendingCount > 0) { - $pendingString = "$pendingCount"; - } else { - $pendingString = "$pendingCount"; - } - - $table[] = [$index->getData('table_name'), $index->getData('view_name'), $changelogName, $index->getData('status'), $versionId, $pendingString]; - } - - /* @var TableHelper $tableHelper */ - $tableHelper = $this->getHelper('table'); - $tableHelper - ->setHeaders( - ['table_name', 'view_name', 'changelog_name', 'status', 'version_id', 'entries pending reindex'] - ) - ->renderByFormat($output, $table, $input->getOption('format')); - return 0; - } - - /** - * @param $tableName - * @param $currentVersionId - * @return int - */ - protected function getPendingChangelogsCount($tableName, $currentVersionId) - { - /** @var \Mage_Core_Model_Resource $resource */ - $resource = $this->_getSingleton('core/resource', '\Mage_Core_Model_Resource'); - $readConnection = $resource->getConnection('core_read'); - - $select = $readConnection->select() - ->from($tableName, ['count(*)']) - ->where("version_id > ?", $currentVersionId); - $todoCount = $readConnection->fetchOne($select); - - return (int) $todoCount; - } -} diff --git a/src/N98/Magento/Command/Indexer/ReindexMviewCommand.php b/src/N98/Magento/Command/Indexer/ReindexMviewCommand.php deleted file mode 100644 index 8ccf47114..000000000 --- a/src/N98/Magento/Command/Indexer/ReindexMviewCommand.php +++ /dev/null @@ -1,72 +0,0 @@ -setName('index:reindex:mview') - ->addArgument('table_name', InputArgument::REQUIRED, 'View table name"') - ->setDescription('Reindex a magento index by code using the materialised view functionality'); - } - - /** - * {@inheritdoc} - */ - public function getHelp(): string - { - return <<detectMagento($output, true); - if (!$this->initMagento()) { - return 0; - } - $tableName = $input->getArgument('table_name'); - - $indexers = $this->getIndexers(); - - if (!array_key_exists($tableName, $indexers)) { - throw new InvalidArgumentException("$tableName is not a view table"); - } - - $indexerData = $indexers[$tableName]; - $indexTable = (string) $indexerData->index_table; - $actionName = (string) $indexerData->action_model->changelog; - - $client = $this->getMviewClient(); - $client->init($indexTable); - if (!$client->getMetadata()->getId()) { - throw new InvalidArgumentException("Could not load metadata for $tableName"); - } - - $output->writeln("Starting mview indexer {$indexTable} with action {$actionName} "); - $client->execute($actionName); - $output->writeln("Done"); - return 0; - } -} diff --git a/tests/N98/Magento/Command/Admin/User/LockCommandTest.php b/tests/N98/Magento/Command/Admin/User/LockCommandTest.php deleted file mode 100644 index 133e6ebd6..000000000 --- a/tests/N98/Magento/Command/Admin/User/LockCommandTest.php +++ /dev/null @@ -1,31 +0,0 @@ -daysToSeconds($days); - self::assertSame($expected, $result); - } - - /** - * @return array - */ - public function daysProvider() - { - return [[1, 86400], [31, 2678400]]; - } -} diff --git a/tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php b/tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php deleted file mode 100644 index b0a0d337a..000000000 --- a/tests/N98/Magento/Command/Admin/User/UnlockUserCommandTest.php +++ /dev/null @@ -1,68 +0,0 @@ -setApplication($this->getApplication()); - if (!$command->isEnabled()) { - self::markTestSkipped('UnlockCommand is not enabled.'); - } - return $command; - } - - public function testUnlockAllUsersPromptNo() - { - $questionHelper = $this->getMockBuilder(QuestionHelper::class) - ->disableOriginalConstructor() - ->onlyMethods(['ask']) - ->getMock(); - - $questionHelper->expects(self::once()) - ->method('ask') - ->willReturn('n'); - - $application = $this->getApplication(); - $application->add($this->getCommand()); - $command = $this->getApplication()->find('admin:user:unlock'); - $command->getHelperSet()->set($questionHelper, 'question'); - - $commandTester = new CommandTester($command); - $commandTester->execute(['command' => $command->getName()]); - - self::assertStringNotContainsString('All admins unlocked', $commandTester->getDisplay()); - } - - public function testUnlockAllUsersPromptYes() - { - $questionHelperMock = $this->getMockBuilder(QuestionHelper::class) - ->disableOriginalConstructor() - ->onlyMethods(['ask']) - ->getMock(); - - $questionHelperMock->expects(self::once()) - ->method('ask') - ->willReturn('y'); - - $application = $this->getApplication(); - $application->add($this->getCommand()); - $command = $this->getApplication()->find('admin:user:unlock'); - $command->getHelperSet()->set($questionHelperMock, 'question'); - - $commandTester = new CommandTester($command); - $commandTester->execute(['command' => $command->getName()]); - - self::assertStringContainsString('All admins unlocked', $commandTester->getDisplay()); - } -}