/**
  * @expectedException \Zend_Json_Exception
  */
 public function testGetPackageNameInvalidJson()
 {
     $this->componentRegistrar->expects($this->once())->method('getPath')->willReturn('path/to/A');
     $this->dirRead->expects($this->once())->method('isExist')->willReturn(true);
     $this->dirRead->expects($this->once())->method('readFile')->willReturn('{"name": }');
     $this->themePackageInfo->getPackageName('themeA');
 }
Example #2
0
 /**
  * Get path to minified file for specified original file
  *
  * @param string $originalFile path to original file relative to pub/view_cache
  * @param string $targetFile path relative to pub/view_cache
  * @return void
  */
 public function minifyFile($originalFile, $targetFile)
 {
     if ($this->_isUpdateNeeded($targetFile)) {
         $content = $this->rootDirectory->readFile($originalFile);
         $content = $this->adapter->minify($content);
         $this->pubViewCacheDir->writeFile($targetFile, $content);
     }
 }
 public function testSetTemplateContext()
 {
     $template = 'themedir/template.phtml';
     $this->rootDirMock->expects($this->once())->method('isFile')->with($template)->will($this->returnValue(true));
     $context = new \Magento\Framework\Object();
     $this->_templateEngine->expects($this->once())->method('render')->with($context);
     $this->_block->setTemplateContext($context);
     $this->_block->fetchView($template);
 }
Example #4
0
 /**
  * @covers \Magento\Framework\App\Config\Initial\Reader::read
  */
 public function testReadValidConfig()
 {
     $testXmlFilesList = array(file_get_contents($this->_filePath . 'initial_config1.xml'), file_get_contents($this->_filePath . 'initial_config2.xml'));
     $expectedConfig = array('data' => array(), 'metadata' => array());
     $this->_fileResolverMock->expects($this->at(0))->method('get')->with('config.xml', 'global')->will($this->returnValue($testXmlFilesList));
     $this->_converterMock->expects($this->once())->method('convert')->with($this->anything())->will($this->returnValue($expectedConfig));
     $this->rootDirectory->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0));
     $this->rootDirectory->expects($this->any())->method('readFile')->will($this->returnValue('<config></config>'));
     $this->assertEquals($expectedConfig, $this->_model->read());
 }
Example #5
0
 public function testReadFile()
 {
     $path = 'filepath';
     $flag = 'flag';
     $context = 'context';
     $contents = 'contents';
     $this->driver->expects($this->once())->method('getAbsolutePath')->with($this->path, $path)->will($this->returnValue($path));
     $this->driver->expects($this->once())->method('fileGetContents')->with($path, $flag, $context)->will($this->returnValue($contents));
     $this->assertEquals($contents, $this->read->readFile($path, $flag, $context));
 }
Example #6
0
 /**
  * test get storage data
  */
 public function testGetStorageData()
 {
     $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->with($this->equalTo(\Magento\Framework\App\Filesystem::MEDIA_DIR))->will($this->returnValue($this->directoryReadMock));
     $this->directoryReadMock->expects($this->any())->method('isDirectory')->will($this->returnValueMap(array(array('/', true), array('folder_one', true), array('file_three.txt', false), array('folder_one/.svn', false), array('folder_one/file_one.txt', false), array('folder_one/folder_two', true), array('folder_one/folder_two/.htaccess', false), array('folder_one/folder_two/file_two.txt', false))));
     $paths = array('folder_one', 'file_three.txt', 'folder_one/.svn', 'folder_one/file_one.txt', 'folder_one/folder_two', 'folder_one/folder_two/.htaccess', 'folder_one/folder_two/file_two.txt');
     sort($paths);
     $this->directoryReadMock->expects($this->once())->method('readRecursively')->with($this->equalTo('/'))->will($this->returnValue($paths));
     $expected = array('files' => array('file_three.txt', 'folder_one/file_one.txt', 'folder_one/folder_two/file_two.txt'), 'directories' => array(array('name' => 'folder_one', 'path' => '/'), array('name' => 'folder_two', 'path' => 'folder_one')));
     $actual = $this->storageFile->getStorageData();
     $this->assertEquals($expected, $actual);
 }
Example #7
0
 /**
  * test get storage data
  */
 public function testGetStorageData()
 {
     $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->with($this->equalTo(DirectoryList::MEDIA))->will($this->returnValue($this->directoryReadMock));
     $this->directoryReadMock->expects($this->any())->method('isDirectory')->will($this->returnValueMap([['/', true], ['folder_one', true], ['file_three.txt', false], ['folder_one/.svn', false], ['folder_one/file_one.txt', false], ['folder_one/folder_two', true], ['folder_one/folder_two/.htaccess', false], ['folder_one/folder_two/file_two.txt', false]]));
     $paths = ['folder_one', 'file_three.txt', 'folder_one/.svn', 'folder_one/file_one.txt', 'folder_one/folder_two', 'folder_one/folder_two/.htaccess', 'folder_one/folder_two/file_two.txt'];
     sort($paths);
     $this->directoryReadMock->expects($this->once())->method('readRecursively')->with($this->equalTo('/'))->will($this->returnValue($paths));
     $expected = ['files' => ['file_three.txt', 'folder_one/file_one.txt', 'folder_one/folder_two/file_two.txt'], 'directories' => [['name' => 'folder_one', 'path' => '/'], ['name' => 'folder_two', 'path' => 'folder_one']]];
     $actual = $this->storageFile->getStorageData();
     $this->assertEquals($expected, $actual);
 }
 public function testResolve()
 {
     $requestedFile = 'file.css';
     $expected = 'some/dir/file.less';
     $theme = $this->getMockForAbstractClass('Magento\\Framework\\View\\Design\\ThemeInterface');
     $theme->expects($this->any())->method('getFullPath')->will($this->returnValue('magento_theme'));
     $this->rule->expects($this->atLeastOnce())->method('getPatternDirs')->will($this->returnValue(['some/dir']));
     $fileExistsMap = [['file.css', false], ['file.less', true]];
     $this->directory->expects($this->any())->method('isExist')->will($this->returnValueMap($fileExistsMap));
     $actual = $this->object->resolve('type', $requestedFile, 'frontend', $theme, 'en_US', 'Magento_Module');
     $this->assertSame($expected, $actual);
 }
Example #9
0
 /**
  * Open file and detect column names
  *
  * There must be column names in the first line
  *
  * @param string $file
  * @param \Magento\Framework\Filesystem\Directory\Read $directory
  * @param string $delimiter
  * @param string $enclosure
  * @throws \LogicException
  */
 public function __construct($file, \Magento\Framework\Filesystem\Directory\Read $directory, $delimiter = ',', $enclosure = '"')
 {
     register_shutdown_function([$this, 'destruct']);
     try {
         $this->_file = $directory->openFile($directory->getRelativePath($file), 'r');
     } catch (\Magento\Framework\Exception\FileSystemException $e) {
         throw new \LogicException("Unable to open file: '{$file}'");
     }
     if ($delimiter) {
         $this->_delimiter = $delimiter;
     }
     $this->_enclosure = $enclosure;
     parent::__construct($this->_getNextRow());
 }
Example #10
0
 protected function setUp()
 {
     $this->_resolver = $this->getMock('Magento\\Framework\\View\\Element\\Template\\File\\Resolver', [], [], '', false);
     $this->_validator = $this->getMock('Magento\\Framework\\View\\Element\\Template\\File\\Validator', [], [], '', false);
     $this->rootDirMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', [], [], '', false);
     $this->rootDirMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0));
     $this->_filesystem = $this->getMock('\\Magento\\Framework\\Filesystem', [], [], '', false);
     $this->_filesystem->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::ROOT, DriverPool::FILE)->will($this->returnValue($this->rootDirMock));
     $this->_templateEngine = $this->getMock('Magento\\Framework\\View\\TemplateEnginePool', ['render', 'get'], [], '', false);
     $this->_templateEngine->expects($this->any())->method('get')->will($this->returnValue($this->_templateEngine));
     $appState = $this->getMock('Magento\\Framework\\App\\State', ['getAreaCode'], [], '', false);
     $appState->expects($this->any())->method('getAreaCode')->will($this->returnValue('frontend'));
     $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->_block = $helper->getObject('Magento\\Framework\\View\\Element\\Template', ['filesystem' => $this->_filesystem, 'enginePool' => $this->_templateEngine, 'resolver' => $this->_resolver, 'validator' => $this->_validator, 'appState' => $appState, 'data' => ['template' => 'template.phtml', 'module_name' => 'Fixture_Module']]);
 }
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Missing key 'packages' in 'composer.lock' file
  */
 public function testGetRequiredExceptionMissingPackages()
 {
     $this->directoryReadMock->expects($this->once())->method('isExist')->will($this->returnValue(true));
     $this->directoryReadMock->expects($this->once())->method('readFile')->with('composer.lock')->will($this->returnValue('{"platform-dev":{"ext-e":"*", "f":"*"}}'));
     $phpInfo = new PhpInformation($this->filesystemMock);
     $phpInfo->getRequired();
 }
Example #12
0
 public function testGetImagesJson()
 {
     $url = [['file_1.jpg', 'url_to_the_image/image_1.jpg'], ['file_2.jpg', 'url_to_the_image/image_2.jpg']];
     $mediaPath = [['file_1.jpg', 'catalog/product/image_1.jpg'], ['file_2.jpg', 'catalog/product/image_2.jpg']];
     $sizeMap = [['catalog/product/image_1.jpg', ['size' => 399659]], ['catalog/product/image_2.jpg', ['size' => 879394]]];
     $imagesResult = [['value_id' => '2', 'file' => 'file_2.jpg', 'media_type' => 'image', 'position' => '0', 'url' => 'url_to_the_image/image_2.jpg', 'size' => 879394], ['value_id' => '1', 'file' => 'file_1.jpg', 'media_type' => 'image', 'position' => '1', 'url' => 'url_to_the_image/image_1.jpg', 'size' => 399659]];
     $images = ['images' => [['value_id' => '1', 'file' => 'file_1.jpg', 'media_type' => 'image', 'position' => '1'], ['value_id' => '2', 'file' => 'file_2.jpg', 'media_type' => 'image', 'position' => '0']]];
     $this->content->setElement($this->galleryMock);
     $this->galleryMock->expects($this->once())->method('getImages')->willReturn($images);
     $this->fileSystemMock->expects($this->once())->method('getDirectoryRead')->willReturn($this->readMock);
     $this->mediaConfigMock->expects($this->any())->method('getMediaUrl')->willReturnMap($url);
     $this->mediaConfigMock->expects($this->any())->method('getMediaPath')->willReturnMap($mediaPath);
     $this->readMock->expects($this->any())->method('stat')->willReturnMap($sizeMap);
     $this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode');
     $this->assertSame(json_encode($imagesResult), $this->content->getImagesJson());
 }
Example #13
0
 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  * @throws \LogicException
  */
 public function launch()
 {
     if (!$this->_mediaDirectory) {
         $config = $this->_objectManager->create('Magento\\Core\\Model\\File\\Storage\\Config', ['cacheFile' => $this->_configCacheFile]);
         $config->save();
         $this->_mediaDirectory = str_replace($this->_workingDirectory, '', $config->getMediaDirectory());
         $allowedResources = $config->getAllowedResources();
         $this->_relativeFileName = str_replace($this->_mediaDirectory . '/', '', $this->_request->getPathInfo());
         $isAllowed = $this->_isAllowed;
         if (!$isAllowed($this->_relativeFileName, $allowedResources)) {
             throw new \LogicException('The specified path is not allowed.');
         }
     }
     if (0 !== stripos($this->_request->getPathInfo(), $this->_mediaDirectory . '/')) {
         throw new \LogicException('The specified path is not within media directory.');
     }
     $sync = $this->_objectManager->get('Magento\\Core\\Model\\File\\Storage\\Synchronization');
     $sync->synchronize($this->_relativeFileName, $this->_request->getFilePath());
     if ($this->directory->isReadable($this->directory->getRelativePath($this->_request->getFilePath()))) {
         $this->_response->setFilePath($this->_request->getFilePath());
     } else {
         $this->_response->setHttpResponseCode(404);
     }
     return $this->_response;
 }
Example #14
0
 public function testResolveNonexistentFile()
 {
     $this->readFactoryMock->expects($this->any())->method('create')->willReturn($this->directoryMock);
     $this->ruleMock->expects($this->once())->method('getPatternDirs')->willReturn(['some/dir']);
     $this->directoryMock->expects($this->once())->method('isExist')->willReturn(false);
     $this->assertFalse($this->object->resolve('type', 'file.ext', 'frontend', $this->getMockForTheme('magento_theme'), 'en_US', 'Magento_Module'));
 }
 public function testCheckUpdater()
 {
     $json = [ReadinessCheck::KEY_READINESS_CHECKS => [CronScriptReadinessCheck::UPDATER_KEY_FILE_PERMISSIONS_VERIFIED => true], ReadinessCheck::KEY_CURRENT_TIMESTAMP => 200, ReadinessCheck::KEY_LAST_TIMESTAMP => 140];
     $this->read->expects($this->once())->method('readFile')->willReturn(json_encode($json));
     $expected = ['success' => true];
     $this->assertEquals($expected, $this->cronScriptReadinessCheck->checkUpdater());
 }
Example #16
0
 /**
  * Get path to custom view configuration file
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @return string|null
  */
 public function getCustomViewConfigPath(\Magento\Framework\View\Design\ThemeInterface $theme)
 {
     $path = null;
     if ($theme->getId()) {
         $path = $this->mediaDirectoryRead->getAbsolutePath(self::DIR_NAME . '/' . $theme->getId() . '/' . $this->filename);
     }
     return $path;
 }
Example #17
0
 public function testProcessRequestReturnsNotFoundIfFileIsNotSynchronized()
 {
     $this->sync->expects($this->once())->method('synchronize')->with(self::RELATIVE_FILE_PATH);
     $this->directoryMock->expects($this->once())->method('getAbsolutePath')->with()->will($this->returnValue(self::MEDIA_DIRECTORY));
     $this->directoryMock->expects($this->once())->method('isReadable')->with(self::RELATIVE_FILE_PATH)->will($this->returnValue(false));
     $this->responseMock->expects($this->once())->method('setHttpResponseCode')->with(404);
     $this->assertSame($this->responseMock, $this->model->launch());
 }
Example #18
0
 /**
  * Retrieve data from file
  *
  * @param string $file
  * @return array
  */
 protected function _getFileData($file)
 {
     $data = [];
     if ($this->directory->isExist($this->directory->getRelativePath($file))) {
         $this->_csvParser->setDelimiter(',');
         $data = $this->_csvParser->getDataPairs($file);
     }
     return $data;
 }
Example #19
0
 /**
  * Search for minified file provided along with the original file in the code base
  *
  * @param string $originalFile
  * @return bool|string
  */
 protected function _findOriginalMinifiedFile($originalFile)
 {
     $fileInfo = pathinfo($originalFile);
     $minifiedFile = $fileInfo['dirname'] . '/' . $fileInfo['filename'] . '.min.' . $fileInfo['extension'];
     if ($this->rootDirectory->isExist($minifiedFile)) {
         return $minifiedFile;
     }
     return false;
 }
Example #20
0
 /**
  * Set properties from config
  *
  * @param array $config
  * @return void
  * @throws \Magento\Framework\Filesystem\FilesystemException
  */
 protected function setProperties(array $config)
 {
     parent::setProperties($config);
     if (isset($config['permissions'])) {
         $this->permissions = $config['permissions'];
     }
     if (isset($config['allow_create_dirs'])) {
         $this->allowCreateDirs = (bool) $config['allow_create_dirs'];
     }
 }
Example #21
0
 public function testResolveFromCache()
 {
     $expectedPath = '/some/dir/file.ext';
     $this->cache->expects($this->once())->method('getFromCache')->with('type', 'file.ext', 'frontend', 'magento_theme', 'en_US', 'Magento_Module')->will($this->returnValue($expectedPath));
     $this->directory->expects($this->once())->method('getAbsolutePath')->with($expectedPath)->will($this->returnValue($expectedPath));
     $this->rule->expects($this->never())->method('getPatternDirs');
     $this->cache->expects($this->never())->method('saveToCache');
     $actualPath = $this->object->resolve('type', 'file.ext', 'frontend', $this->getMockForTheme('magento_theme'), 'en_US', 'Magento_Module');
     $this->assertSame($expectedPath, $actualPath);
 }
 public function testGetImagesJson()
 {
     $url = [['file_1.jpg', 'url_to_the_image/image_1.jpg'], ['file_2.jpg', 'url_to_the_image/image_2.jpg']];
     $mediaPath = [['file_1.jpg', 'catalog/product/image_1.jpg'], ['file_2.jpg', 'catalog/product/image_2.jpg']];
     // @codingStandardsIgnoreStart
     $encodedString = '[{"value_id":"1","file":"image_1.jpg","media_type":"image","url":"http:\\/\\/magento2.dev\\/pub\\/media\\/catalog\\/product\\/image_1.jpg","size":879394},{"value_id":"2","file":"image_2.jpg","media_type":"image","url":"http:\\/\\/magento2.dev\\/pub\\/media\\/catalog\\/product\\/image`_2.jpg","size":399659}]';
     // @codingStandardsIgnoreEnd
     $images = ['images' => [['value_id' => '1', 'file' => 'file_1.jpg', 'media_type' => 'image'], ['value_id' => '2', 'file' => 'file_2.jpg', 'media_type' => 'image']]];
     $firstStat = ['size' => 879394];
     $secondStat = ['size' => 399659];
     $this->content->setElement($this->galleryMock);
     $this->galleryMock->expects($this->any())->method('getImages')->willReturn($images);
     $this->fileSystemMock->expects($this->once())->method('getDirectoryRead')->willReturn($this->readMock);
     $this->mediaConfigMock->expects($this->any())->method('getMediaUrl')->willReturnMap($url);
     $this->mediaConfigMock->expects($this->any())->method('getMediaPath')->willReturn($mediaPath);
     $this->readMock->expects($this->at(0))->method('stat')->willReturn($firstStat);
     $this->readMock->expects($this->at(1))->method('stat')->willReturn($secondStat);
     $this->jsonEncoderMock->expects($this->once())->method('encode')->willReturn($encodedString);
     $this->assertSame($encodedString, $this->content->getImagesJson());
 }
Example #23
0
 public function testUploadJsFile()
 {
     $fileName = 'file.name';
     $this->_fileSizeMock->expects($this->once())->method('getMaxFileSize')->will($this->returnValue(600 * self::MB_MULTIPLIER));
     $this->_service = new \Magento\Theme\Model\Uploader\Service($this->_filesystemMock, $this->_fileSizeMock, $this->_uploaderFactory, ['js' => '500M']);
     $this->_directoryMock->expects($this->once())->method('getRelativePath')->with($fileName)->will($this->returnValue($fileName));
     $this->_directoryMock->expects($this->once())->method('readFile')->with($fileName)->will($this->returnValue('content'));
     $this->_uploader->expects($this->once())->method('validateFile')->will($this->returnValue(['name' => $fileName, 'tmp_name' => $fileName]));
     $this->_uploader->expects($this->once())->method('getFileSize')->will($this->returnValue('499'));
     $this->assertEquals(['content' => 'content', 'filename' => $fileName], $this->_service->uploadJsFile($fileName));
 }
Example #24
0
 public function testProcessRequestReturnsFileIfItsProperlySynchronized()
 {
     $relativeFilePath = '_files';
     $filePath = str_replace('\\', '/', __DIR__ . '/' . $relativeFilePath);
     $this->_requestMock->expects($this->any())->method('getPathInfo')->will($this->returnValue($this->_mediaDirectory . '/'));
     $this->_sync->expects($this->once())->method('synchronize');
     $this->_requestMock->expects($this->any())->method('getFilePath')->will($this->returnValue($filePath));
     $this->directoryReadMock->expects($this->once())->method('getRelativePath')->with($filePath)->will($this->returnValue($relativeFilePath));
     $this->directoryReadMock->expects($this->once())->method('isReadable')->with($relativeFilePath)->will($this->returnValue(true));
     $this->_responseMock->expects($this->once())->method('setFilePath')->with($filePath);
     $this->assertSame($this->_responseMock, $this->_model->launch());
 }
Example #25
0
 /**
  * Go through all modules and find composer.json files of active modules
  *
  * @return FileIterator
  */
 public function getComposerJsonFiles()
 {
     $result = [];
     foreach ($this->modulesList->getNames() as $moduleName) {
         $file = $this->getModuleDir('', $moduleName) . '/composer.json';
         $path = $this->modulesDirectory->getRelativePath($file);
         if ($this->modulesDirectory->isExist($path)) {
             $result[] = $path;
         }
     }
     return $this->fileIteratorFactory->create($this->modulesDirectory, $result);
 }
Example #26
0
 public function testRead()
 {
     $this->_filesystemDirectoryMock->expects($this->at(1))->method('readFile')->will($this->returnValue(file_get_contents($this->_paths[0])));
     $this->_filesystemDirectoryMock->expects($this->at(3))->method('readFile')->will($this->returnValue(file_get_contents($this->_paths[1])));
     $this->_moduleDirResolver->expects($this->at(0))->method('getModuleName')->with(__DIR__ . '/_files/Fixture/ModuleOne/etc/email_templates_one.xml')->will($this->returnValue('Fixture_ModuleOne'));
     $this->_moduleDirResolver->expects($this->at(1))->method('getModuleName')->with(__DIR__ . '/_files/Fixture/ModuleTwo/etc/email_templates_two.xml')->will($this->returnValue('Fixture_ModuleTwo'));
     $constraint = function (\DOMDocument $actual) {
         try {
             $expected = file_get_contents(__DIR__ . '/_files/email_templates_merged.xml');
             $expectedNorm = preg_replace('/xsi:noNamespaceSchemaLocation="[^"]*"/', '', $expected, 1);
             $actualNorm = preg_replace('/xsi:noNamespaceSchemaLocation="[^"]*"/', '', $actual->saveXML(), 1);
             \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expectedNorm, $actualNorm);
             return true;
         } catch (\PHPUnit_Framework_AssertionFailedError $e) {
             return false;
         }
     };
     $expectedResult = new \stdClass();
     $this->_converter->expects($this->once())->method('convert')->with($this->callback($constraint))->will($this->returnValue($expectedResult));
     $this->assertSame($expectedResult, $this->_model->read('scope'));
 }
Example #27
0
 protected function setUp()
 {
     $this->resolver = $this->getMock('Magento\\Framework\\View\\Element\\Template\\File\\Resolver', [], [], '', false);
     $this->validator = $this->getMock('Magento\\Framework\\View\\Element\\Template\\File\\Validator', [], [], '', false);
     $this->rootDirMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', [], [], '', false);
     $this->rootDirMock->expects($this->any())->method('getRelativePath')->willReturnArgument(0);
     $this->filesystem = $this->getMock('\\Magento\\Framework\\Filesystem', [], [], '', false);
     $this->filesystem->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::ROOT, DriverPool::FILE)->willReturn($this->rootDirMock);
     $this->templateEngine = $this->getMock('Magento\\Framework\\View\\TemplateEnginePool', ['render', 'get'], [], '', false);
     $this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->templateEngine->expects($this->any())->method('get')->willReturn($this->templateEngine);
     $appState = $this->getMock('Magento\\Framework\\App\\State', ['getAreaCode'], [], '', false);
     $appState->expects($this->any())->method('getAreaCode')->willReturn('frontend');
     $storeManagerMock = $this->getMock(StoreManager::class, [], [], '', false);
     $storeMock = $this->getMock(Store::class, [], [], '', false);
     $storeManagerMock->expects($this->any())->method('getStore')->willReturn($storeMock);
     $storeMock->expects($this->any())->method('getCode')->willReturn('storeCode');
     $urlBuilderMock = $this->getMock(UrlInterface::class, [], [], '', false);
     $urlBuilderMock->expects($this->any())->method('getBaseUrl')->willReturn('baseUrl');
     $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->block = $helper->getObject('Magento\\Framework\\View\\Element\\Template', ['filesystem' => $this->filesystem, 'enginePool' => $this->templateEngine, 'resolver' => $this->resolver, 'validator' => $this->validator, 'appState' => $appState, 'logger' => $this->loggerMock, 'storeManager' => $storeManagerMock, 'urlBuilder' => $urlBuilderMock, 'data' => ['template' => 'template.phtml', 'module_name' => 'Fixture_Module']]);
 }
Example #28
0
 /**
  * Return default path related data
  *
  * @param string $configPath
  * @return array
  */
 protected function _preparePathData($configPath)
 {
     $themeDirectory = dirname($configPath);
     if ($this->_directory->isExist($themeDirectory)) {
         $fullPath = $this->_directory->getRelativePath($themeDirectory);
         $pathPieces = explode('/', $fullPath);
         $area = array_shift($pathPieces);
         return ['area' => $area, 'theme_path_pieces' => $pathPieces];
     } else {
         $fullPath = $this->rootDirectory->getRelativePath($themeDirectory);
         return $this->themeDirs->getAreaConfiguration($fullPath);
     }
 }
Example #29
0
 /**
  * Install application
  *
  * @param \Magento\Install\Model\Installer\Console $installer
  * @return void
  */
 protected function _handleInstall(\Magento\Install\Model\Installer\Console $installer)
 {
     if (isset($this->_arguments['config']) && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($this->_arguments['config']))) {
         $config = (array) (include $this->_arguments['config']);
         $this->_arguments = array_merge((array) $config, $this->_arguments);
     }
     $result = $installer->install($this->_arguments);
     if (!$installer->hasErrors()) {
         $msg = 'Installed successfully' . ($result ? ' (encryption key "' . $result . '")' : '');
         $this->_output->success($msg . PHP_EOL);
     } else {
         $this->_output->error(implode(PHP_EOL, $installer->getErrors()) . PHP_EOL);
     }
 }
Example #30
0
 public function testReadFileCustomProtocol()
 {
     $path = 'filepath';
     $flag = 'flag';
     $context = 'context';
     $protocol = 'ftp';
     $contents = 'contents';
     $fileMock = $this->getMock('Magento\\Framework\\Filesystem\\File\\Read', [], [], '', false);
     $fileMock->expects($this->once())->method('readAll')->with($flag, $context)->will($this->returnValue($contents));
     $this->driver->expects($this->once())->method('getAbsolutePath')->with($this->path, $path, $protocol)->will($this->returnValue($path));
     $this->driver->expects($this->never())->method('fileGetContents');
     $this->fileFactory->expects($this->once())->method('create')->with($path, $protocol, $this->driver)->will($this->returnValue($fileMock));
     $this->assertEquals($contents, $this->read->readFile($path, $flag, $context, $protocol));
 }