public function testExecute()
    {
        $omFactory = $this->getMock('Magento\Framework\App\ObjectManagerFactory', [], [], '', false);
        $this->objectManagerProvider->expects($this->any())
            ->method('get')
            ->will($this->returnValue($this->objectManager));

        $this->objectManagerProvider->expects($this->once())
            ->method('getObjectManagerFactory')
            ->with([])
            ->willReturn($omFactory);

        $this->deployer->expects($this->once())->method('deploy');

        $this->objectManager->expects($this->at(0))
            ->method('create')
            ->willReturn($this->filesUtil);

        $this->objectManager->expects($this->at(1))
            ->method('create')
            ->willReturn($this->deployer);

        $this->validator->expects($this->once())->method('isValid')->with('en_US')->willReturn(true);

        $this->deploymentConfig->expects($this->once())
            ->method('isAvailable')
            ->will($this->returnValue(true));
        $tester = new CommandTester($this->command);
        $tester->execute([]);
    }
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage --language (-l) and --exclude-language cannot be used at the same tim
  */
 public function testExecuteIncludedExcludedLanguages()
 {
     $this->filesUtil->expects(self::any())->method('getStaticPreProcessingFiles')->willReturn([]);
     $this->objectManager->expects($this->at(0))->method('create')->willReturn($this->filesUtil);
     $this->validator->expects(self::exactly(2))->method('isValid')->willReturnMap([['en_US', true], ['uk_UA', true]]);
     $tester = new CommandTester($this->command);
     $tester->execute(['--language' => ['en_US', 'uk_UA'], '--exclude-language' => 'ru_RU']);
 }
 public function testExecute()
 {
     $this->deployer->expects($this->once())->method('deploy');
     $this->objectManager->expects($this->at(0))->method('create')->willReturn($this->filesUtil);
     $this->objectManager->expects($this->at(1))->method('create')->willReturn($this->deployer);
     $this->validator->expects($this->once())->method('isValid')->with('en_US')->willReturn(true);
     $tester = new CommandTester($this->command);
     $tester->execute([]);
 }
Пример #4
0
 public function testExecute()
 {
     $file = 'css/styles-m' . '.less';
     $this->configLoader->expects($this->once())->method('load')->with('frontend')->willReturn([]);
     $this->objectManager->expects($this->once())->method('configure');
     $this->sourceFileGeneratorPool->expects($this->once())->method('create')->with('less')->willReturn($this->getMock('Magento\\Framework\\Less\\FileGenerator', [], [], '', false));
     $this->assetRepo->expects($this->once())->method('createAsset')->with($file, ['area' => 'frontend', 'theme' => 'Magento/blank', 'locale' => 'en_US'])->willReturn($this->getMockForAbstractClass('Magento\\Framework\\View\\Asset\\LocalInterface'));
     $this->assetSource->expects($this->once())->method('findSource')->willReturn('/dev/null');
     $this->chainFactory->expects($this->once())->method('create')->willReturn($this->getMock('Magento\\Framework\\View\\Asset\\PreProcessor\\Chain', [], [], '', false));
     $this->filesystem->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\WriteInterface', [], [], '', false));
     $this->validator->expects($this->once())->method('isValid')->with('en_US')->willReturn(true);
     $commandTester = new CommandTester($this->command);
     $commandTester->execute(['type' => 'less']);
     $this->assertContains('Successfully processed LESS and/or SASS files', $commandTester->getDisplay());
 }
 /**
  * Run test for execute method
  */
 public function testExecute()
 {
     /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder(OutputInterface::class)->getMockForAbstractClass();
     $assetMock = $this->getMockBuilder(LocalInterface::class)->getMockForAbstractClass();
     $this->validatorMock->expects(self::once())->method('isValid')->with(self::LOCALE_TEST_VALUE)->willReturn(true);
     $message = sprintf('<info>Processed Area: %s, Locale: %s, Theme: %s, File type: %s.</info>', self::AREA_TEST_VALUE, self::LOCALE_TEST_VALUE, self::THEME_TEST_VALUE, self::TYPE_TEST_VALUE);
     $outputMock->expects(self::at(0))->method('writeln')->with($message);
     $outputMock->expects(self::at(1))->method('writeln')->with('<comment>-> file-test-value/test/file</comment>');
     $outputMock->expects(self::at(2))->method('writeln')->with('<info>Successfully processed.</info>');
     $this->assetRepositoryMock->expects(self::once())->method('createAsset')->with('file-test-value/test' . DIRECTORY_SEPARATOR . 'file' . '.' . self::TYPE_TEST_VALUE, ['area' => self::AREA_TEST_VALUE, 'theme' => self::THEME_TEST_VALUE, 'locale' => self::LOCALE_TEST_VALUE])->willReturn($assetMock);
     $this->assetPublisherMock->expects(self::once())->method('publish')->with($assetMock);
     $assetMock->expects(self::once())->method('getFilePath')->willReturn(self::FILE_TEST_VALUE);
     $this->sourceThemeDeployCommand->run($this->getInputMock(), $outputMock);
 }
 /**
  * Run test for execute method with non existing theme
  *
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Verify entered values of the argument and options.
  */
 public function testExecuteNonExistingValue()
 {
     /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder(OutputInterface::class)->getMockForAbstractClass();
     $assetMock = $this->getMockBuilder(LocalInterface::class)->getMockForAbstractClass();
     $this->validatorMock->expects(self::once())->method('isValid')->with(self::LOCALE_TEST_VALUE)->willReturn(true);
     $this->assetRepositoryMock->expects(self::once())->method('createAsset')->with('file-test-value/test' . DIRECTORY_SEPARATOR . 'file' . '.' . self::TYPE_TEST_VALUE, ['area' => self::AREA_TEST_VALUE, 'theme' => self::THEME_NONEXISTING_VALUE, 'locale' => self::LOCALE_TEST_VALUE])->willReturn($assetMock);
     $this->assetPublisherMock->expects(self::once())->method('publish')->with($assetMock)->willThrowException(new \Magento\Framework\View\Asset\File\NotFoundException());
     $valueMap = [['area', self::AREA_TEST_VALUE], ['locale', self::LOCALE_TEST_VALUE], ['theme', self::THEME_NONEXISTING_VALUE], ['type', self::TYPE_TEST_VALUE]];
     $this->sourceThemeDeployCommand->run($this->getInputMock($valueMap), $outputMock);
 }