Example #1
0
 public function testGetTranslationFileTimestamp()
 {
     $path = 'path';
     $contextMock = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface', [], '', true, true, true, ['getPath']);
     $this->assetRepoMock->expects($this->atLeastOnce())->method('getStaticViewFileContext')->willReturn($contextMock);
     $contextMock->expects($this->atLeastOnce())->method('getPath')->willReturn($path);
     $this->directoryListMock->expects($this->atLeastOnce())->method('getPath')->willReturn($path);
     $this->driverFileMock->expects($this->once())->method('isExists')->with('path/path/js-translation.json')->willReturn(true);
     $this->driverFileMock->expects($this->once())->method('stat')->willReturn(['mtime' => 1445736974]);
     $this->assertEquals(1445736974, $this->model->getTranslationFileTimestamp());
 }
 public function testCheckActionWithError()
 {
     $this->directoryList->expects($this->once())->method('getPath')->willReturn(__DIR__);
     $this->filesystem->expects($this->once())->method('validateAvailableDiscSpace')->will($this->throwException(new \Exception("Test error message")));
     $jsonModel = $this->controller->checkAction();
     $this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('responseType', $variables);
     $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_ERROR, $variables['responseType']);
     $this->assertArrayHasKey('error', $variables);
     $this->assertEquals("Test error message", $variables['error']);
 }
 public function setUp()
 {
     $this->composerJsonFinder = $this->getMock('Magento\\Framework\\Composer\\ComposerJsonFinder', [], [], '', false);
     $this->composerJsonFinder->expects($this->once())->method('findComposerJson')->willReturn('composer.json');
     $this->directoryList = $this->getMock('Magento\\Framework\\App\\Filesystem\\DirectoryList', [], [], '', false);
     $this->directoryList->expects($this->exactly(2))->method('getPath')->willReturn('var');
     $this->reqUpdDryRunCommand = $this->getMock('Magento\\Composer\\RequireUpdateDryRunCommand', [], [], '', false);
     $this->file = $this->getMock('Magento\\Framework\\Filesystem\\Driver\\File', [], [], '', false);
     $this->file->expects($this->once())->method('copy')->with('composer.json', 'var/composer.json');
     $composerAppFactory = $this->getMock('Magento\\Framework\\Composer\\MagentoComposerApplicationFactory', [], [], '', false);
     $composerAppFactory->expects($this->once())->method('createRequireUpdateDryRunCommand')->willReturn($this->reqUpdDryRunCommand);
     $this->dependencyReadinessCheck = new DependencyReadinessCheck($this->composerJsonFinder, $this->directoryList, $this->file, $composerAppFactory);
 }
Example #4
0
 public function setUpDirectoryListInstallation()
 {
     $this->directoryListMock->expects($this->at(0))->method('getPath')->with(DirectoryList::CONFIG)->will($this->returnValue(BP . '/app/etc'));
     $this->directoryListMock->expects($this->at(1))->method('getPath')->with(DirectoryList::VAR_DIR)->will($this->returnValue(BP . '/var'));
     $this->directoryListMock->expects($this->at(2))->method('getPath')->with(DirectoryList::MEDIA)->will($this->returnValue(BP . '/pub/media'));
     $this->directoryListMock->expects($this->at(3))->method('getPath')->with(DirectoryList::STATIC_VIEW)->will($this->returnValue(BP . '/pub/static'));
 }
 public function setUp()
 {
     $this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface', [], [], '', false);
     $this->log = $this->getMock('Magento\Framework\Setup\LoggerInterface', [], [], '', false);
     $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false);
     $this->path = realpath(__DIR__);
     $this->directoryList->expects($this->any())
         ->method('getRoot')
         ->willReturn($this->path);
     $this->directoryList->expects($this->any())
         ->method('getPath')
         ->willReturn($this->path);
     $this->file = $this->getMock('Magento\Framework\Filesystem\Driver\File', [], [], '', false);
     $this->filesystem = $this->getMock('Magento\Framework\Backup\Filesystem', [], [], '', false);
     $this->database = $this->getMock('Magento\Framework\Backup\Db', [], [], '', false);
     $this->helper = $this->getMock('Magento\Framework\Backup\Filesystem\Helper', [], [], '', false);
     $this->helper->expects($this->any())
         ->method('getInfo')
         ->willReturn(['writable' => true, 'size' => 100]);
     $configLoader = $this->getMock('Magento\Framework\App\ObjectManager\ConfigLoader', [], [], '', false);
     $configLoader->expects($this->any())
         ->method('load')
         ->willReturn([]);
     $this->objectManager->expects($this->any())
         ->method('get')
         ->will($this->returnValueMap([
             ['Magento\Framework\App\State', $this->getMock('Magento\Framework\App\State', [], [], '', false)],
             ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader],
         ]));
     $this->objectManager->expects($this->any())
         ->method('create')
         ->will($this->returnValueMap([
             ['Magento\Framework\Backup\Filesystem\Helper', [], $this->helper],
             ['Magento\Framework\Backup\Filesystem', [], $this->filesystem],
             ['Magento\Framework\Backup\Db', [], $this->database],
         ]));
     $this->model = new BackupRollback(
         $this->objectManager,
         $this->log,
         $this->directoryList,
         $this->file,
         $this->helper
     );
 }
 public function testExecute()
 {
     $this->directoryListMock->expects($this->atLeastOnce())->method('getPath')->willReturn(null);
     $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Framework\\App\\Cache')->willReturn($this->cacheMock);
     $this->cacheMock->expects($this->once())->method('clean');
     $writeDirectory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface');
     $writeDirectory->expects($this->atLeastOnce())->method('delete');
     $this->filesystemMock->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($writeDirectory);
     $this->deploymentConfigMock->expects($this->once())->method('get')->with(\Magento\Framework\Config\ConfigOptionsListConstants::KEY_MODULES)->willReturn(['Magento_Catalog' => 1]);
     $progressBar = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\ProgressBar')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock->expects($this->once())->method('configure');
     $this->objectManagerMock->expects($this->once())->method('create')->with('Symfony\\Component\\Console\\Helper\\ProgressBar')->willReturn($progressBar);
     $this->managerMock->expects($this->exactly(7))->method('addOperation');
     $this->managerMock->expects($this->once())->method('process');
     $tester = new CommandTester($this->command);
     $tester->execute([]);
     $this->assertContains('Generated code and dependency injection configuration successfully.', explode(PHP_EOL, $tester->getDisplay()));
     $this->assertSame(DiCompileCommand::NAME, $this->command->getName());
 }
Example #7
0
 public function testResolveSecurity()
 {
     $this->ruleMock->expects($this->once())->method('getPatternDirs')->willReturn(['var/test']);
     $directoryWeb = clone $this->directoryMock;
     $fileRead = clone $this->directoryMock;
     $this->directoryMock->expects($this->once())->method('isExist')->willReturn(true);
     $this->directoryListMock->expects($this->once())->method('getPath')->willReturn('lib_web');
     $this->readFactoryMock->expects($this->any())->method('create')->willReturnMap([['var/test', DriverPool::FILE, $this->directoryMock], ['lib_web', DriverPool::FILE, $directoryWeb], [false, DriverPool::FILE, $fileRead]]);
     $directoryWeb->expects($this->once())->method('getAbsolutePath')->willReturn('var/test/web');
     $fileRead->expects($this->once())->method('getAbsolutePath')->willReturn('var/test/web/css');
     $this->assertEquals('var/test/../file.ext', $this->object->resolve('type', '../file.ext', '', null, '', ''));
 }
Example #8
0
 protected function _setupDirectoryListMock(array $config)
 {
     $this->_directoryListMock->expects($this->any())->method('getConfig')->will($this->returnValue($config));
 }
Example #9
0
 public function testGetUri()
 {
     $this->_directoryListMock->expects($this->once())->method('getUrlPath')->with('code')->willReturn('result');
     $this->assertEquals('result', $this->_filesystem->getUri('code'));
 }
Example #10
0
 public function testIsDeployed()
 {
     $this->directoryList->expects($this->once())->method('getPath')->with('code');
     $this->sampleDataInstall->isDeployed();
 }