public function testNotUnlockProcessInProductionMode()
 {
     $this->stateMock->expects(self::exactly(2))->method('getMode')->willReturn(State::MODE_PRODUCTION);
     $this->filesystemMock->expects(self::never())->method('getDirectoryWrite');
     $this->lockerProcess->lockProcess(self::LOCK_NAME);
     $this->lockerProcess->unlockProcess();
 }
 /**
  * @covers \Magento\Shipping\Model\Shipping\LabelGenerator
  * @param array $info
  * @dataProvider labelInfoDataProvider
  */
 public function testAddTrackingNumbersToShipment(array $info)
 {
     $order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $order->expects(static::once())->method('getShippingMethod')->with(true)->willReturn($this->getShippingMethodMock());
     /**
      * @var $shipmentMock \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject
      */
     $shipmentMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Shipment')->disableOriginalConstructor()->getMock();
     $shipmentMock->expects(static::once())->method('getOrder')->willReturn($order);
     $this->carrierFactory->expects(static::once())->method('create')->with(self::CARRIER_CODE)->willReturn($this->getCarrierMock());
     $labelsMock = $this->getMockBuilder('\\Magento\\Shipping\\Model\\Shipping\\Labels')->disableOriginalConstructor()->getMock();
     $labelsMock->expects(static::once())->method('requestToShipment')->with($shipmentMock)->willReturn($this->getResponseMock($info));
     $this->labelsFactory->expects(static::once())->method('create')->willReturn($labelsMock);
     $this->filesystem->expects(static::once())->method('getDirectoryWrite')->willReturn($this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'));
     $this->scopeConfig->expects(static::once())->method('getValue')->with('carriers/' . self::CARRIER_CODE . '/title', ScopeInterface::SCOPE_STORE, null)->willReturn(self::CARRIER_TITLE);
     $this->labelsFactory->expects(static::once())->method('create')->willReturn($labelsMock);
     $trackMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Shipment\\Track')->setMethods(['setNumber', 'setCarrierCode', 'setTitle'])->disableOriginalConstructor()->getMock();
     $i = 0;
     $trackingNumbers = is_array($info['tracking_number']) ? $info['tracking_number'] : [$info['tracking_number']];
     foreach ($trackingNumbers as $trackingNumber) {
         $trackMock->expects(static::at($i++))->method('setNumber')->with($trackingNumber)->willReturnSelf();
         $trackMock->expects(static::at($i++))->method('setCarrierCode')->with(self::CARRIER_CODE)->willReturnSelf();
         $trackMock->expects(static::at($i++))->method('setTitle')->with(self::CARRIER_TITLE)->willReturnSelf();
     }
     $this->trackFactory->expects(static::any())->method('create')->willReturn($trackMock);
     /**
      * @var $requestMock \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
      */
     $requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface');
     $this->labelGenerator->create($shipmentMock, $requestMock);
 }
示例#3
0
    protected function setUp()
    {
        $this->filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem')
            ->disableOriginalConstructor()
            ->getMock();
        $this->fileFactoryMock = $this->getMockBuilder('Magento\Framework\View\File\Factory')
            ->disableOriginalConstructor()
            ->getMock();
        $this->pathPatternHelperMock = $this->getMockBuilder('Magento\Framework\View\Helper\PathPattern')
            ->disableOriginalConstructor()
            ->getMock();
        $this->directoryMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface')
            ->getMockForAbstractClass();
        $this->themeMock = $this->getMockBuilder('Magento\Framework\View\Design\ThemeInterface')
            ->setMethods(['getData'])
            ->getMockForAbstractClass();

        $this->filesystemMock->expects($this->once())
            ->method('getDirectoryRead')
            ->with(DirectoryList::MODULES)
            ->willReturn($this->directoryMock);

        $this->objectManagerHelper = new ObjectManagerHelper($this);
        $this->fileCollector = $this->objectManagerHelper->getObject(
            'Magento\Framework\View\File\Collector\Base',
            [
                'filesystem' => $this->filesystemMock,
                'fileFactory' => $this->fileFactoryMock,
                'pathPatternHelper' => $this->pathPatternHelperMock,
                'subDir' => 'layout'
            ]
        );
    }
示例#4
0
 public function setUp()
 {
     $this->filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->directoryRead = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\ReadInterface', [], '', false);
     $this->filesystem->expects($this->once())->method('getDirectoryRead')->willReturn($this->directoryRead);
     $this->reader = new Reader($this->filesystem);
 }
示例#5
0
 public function testToHtml()
 {
     $fieldSet = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Fieldset', [], [], '', false);
     $form = $this->getMock('Magento\\Framework\\Data\\Form', [], [], '', false);
     $attributeModel = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
     $entityType = $this->getMock('Magento\\Eav\\Model\\Entity\\Type', [], [], '', false);
     $formElement = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Text', ['setDisabled'], [], '', false);
     $directoryReadInterface = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface');
     $this->registry->expects($this->any())->method('registry')->with('entity_attribute')->willReturn($attributeModel);
     $this->formFactory->expects($this->any())->method('create')->willReturn($form);
     $form->expects($this->any())->method('addFieldset')->willReturn($fieldSet);
     $form->expects($this->any())->method('getElement')->willReturn($formElement);
     $fieldSet->expects($this->any())->method('addField')->willReturnSelf();
     $attributeModel->expects($this->any())->method('getDefaultValue')->willReturn('default_value');
     $attributeModel->expects($this->any())->method('setDisabled')->willReturnSelf();
     $attributeModel->expects($this->any())->method('getId')->willReturn(1);
     $attributeModel->expects($this->any())->method('getEntityType')->willReturn($entityType);
     $attributeModel->expects($this->any())->method('getIsUserDefined')->willReturn(false);
     $attributeModel->expects($this->any())->method('getAttributeCode')->willReturn('attribute_code');
     $this->localeDate->expects($this->any())->method('getDateFormat')->willReturn('mm/dd/yy');
     $entityType->expects($this->any())->method('getEntityTypeCode')->willReturn('entity_type_code');
     $this->eavData->expects($this->any())->method('getFrontendClasses')->willReturn([]);
     $formElement->expects($this->exactly(3))->method('setDisabled')->willReturnSelf();
     $this->yesNo->expects($this->any())->method('toOptionArray')->willReturn(['yes', 'no']);
     $this->filesystem->expects($this->any())->method('getDirectoryRead')->willReturn($directoryReadInterface);
     $directoryReadInterface->expects($this->any())->method('getRelativePath')->willReturn('relative_path');
     $this->block->setData(['action' => 'save']);
     $this->block->toHtml();
 }
示例#6
0
    public function setup()
    {
        $this->filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem')
            ->disableOriginalConstructor()
            ->getMock();
        $this->directoryMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface')
            ->getMock();
        $this->fileFactoryMock = $this->getMockBuilder('Magento\Framework\View\File\Factory')
            ->disableOriginalConstructor()
            ->getMock();
        $this->themeMock = $this->getMockBuilder('Magento\Framework\View\Design\ThemeInterface')
            ->getMock();

        $this->filesystemMock->expects($this->any())
            ->method('getDirectoryRead')
            ->willReturn($this->directoryMock);

        $this->objectManagerHelper = new ObjectManagerHelper($this);
        $this->themeFileCollector = $this->objectManagerHelper->getObject(
            'Magento\Framework\View\File\Collector\Theme',
            [
                'filesystem' => $this->filesystemMock,
                'fileFactory' => $this->fileFactoryMock
            ]
        );
    }
示例#7
0
 public function setUp()
 {
     $this->filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->varReaderWriter = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface', [], '', false);
     $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($this->varReaderWriter));
     $this->status = new Status($this->filesystem);
 }
示例#8
0
    protected function setUp()
    {
        $this->requestMock = $this->getMock(
            '\Magento\Framework\App\Request\Http',
            ['getBasePath', 'isSecure', 'getHttpHost'],
            [],
            '',
            false,
            false
        );
        $this->requestMock->expects($this->atLeastOnce())->method('getBasePath')->will($this->returnValue('/'));
        $this->requestMock->expects($this->atLeastOnce())
            ->method('getHttpHost')
            ->will($this->returnValue('init.host'));
        $this->objectManager =  new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
        $this->validatorFactory = $this->getMockBuilder('Magento\Framework\ValidatorFactory')
            ->disableOriginalConstructor()
            ->getMock();
        $backendUrl = $this->getMock('\Magento\Backend\Model\Url', [], [], '', false);
        $backendUrl->expects($this->once())->method('getBaseUrl')->will($this->returnValue('/'));
        $this->backendUrlFactory = $this->getMock('Magento\Backend\Model\UrlFactory', ['create'], [], '', false);
        $this->backendUrlFactory->expects($this->any())->method('create')->willReturn($backendUrl);

        $this->filesystemMock = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false);
        $dirMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface');
        $this->filesystemMock->expects($this->any())
            ->method('getDirectoryWrite')
            ->will($this->returnValue($dirMock));
    }
示例#9
0
    /**
     * Clear state file
     */
    protected function tearDown()
    {
        $this->filesystem->expects($this->any())->method('getDirectoryWrite')->willReturn($this->writeInterface);
        $this->writeInterface->expects($this->any())->method('openFile')->willReturnSelf($this->absolutePath);

        $this->state->clearState();
    }
示例#10
0
 public function testSaveAuthJson()
 {
     $directoryWrite = $this->getMockForAbstractClass('\\Magento\\Framework\\Filesystem\\Directory\\WriteInterface');
     $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($directoryWrite));
     $directoryWrite->expects($this->once())->method('writeFile')->willReturn(true);
     $this->assertTrue($this->packagesAuth->saveAuthJson("testusername", "testpassword"));
 }
示例#11
0
 public function setUp()
 {
     $this->directoryReadMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', [], [], '', false);
     $this->filesystemMock = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->filesystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->directoryReadMock));
     $this->ioMock = $this->getMock('Composer\\IO\\BufferIO', [], [], '', false);
 }
示例#12
0
 public function setUp()
 {
     $this->directoryWriteMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
     $this->filesystemMock = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->filesystemMock->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($this->directoryWriteMock));
     $this->directoryListMock = $this->getMock('Magento\\Framework\\App\\Filesystem\\DirectoryList', [], [], '', false);
     $this->filePermissions = new FilePermissions($this->filesystemMock, $this->directoryListMock);
 }
示例#13
0
 public function setup()
 {
     $this->filesystemMock = $this->getMockBuilder('Magento\\Framework\\Filesystem')->disableOriginalConstructor()->getMock();
     $this->themesDirectoryMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->getMock();
     $this->filesystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->themesDirectoryMock));
     $this->fileFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\File\\Factory')->disableOriginalConstructor()->getMock();
     $this->themeMock = $this->getMockBuilder('Magento\\Framework\\View\\Design\\ThemeInterface')->getMock();
 }
示例#14
0
 public function testExecute()
 {
     $dir = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
     $dir->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0));
     $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($dir));
     $this->processor->expects($this->once())->method('reindexAll');
     $this->assertEquals('0', $this->entryPoint->launch());
 }
示例#15
0
 protected function setUp()
 {
     $this->filesystemMock = $this->getMock('Magento\\Framework\\Filesystem', array('getDirectoryWrite'), array(), '', false);
     $directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', array(), array(), '', false);
     $directoryMock->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0));
     $this->filesystemMock->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($directoryMock));
     $this->processorMock = $this->getMock('Magento\\Indexer\\Model\\Processor', array(), array(), '', false);
     $this->entryPoint = new \Magento\Indexer\App\Indexer('reportDir', $this->filesystemMock, $this->processorMock);
 }
示例#16
0
 protected function setUp()
 {
     $this->entityFactory = $this->getMockBuilder('Magento\\Framework\\Data\\Collection\\EntityFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->filesystem = $this->getMockBuilder('Magento\\Framework\\Filesystem')->disableOriginalConstructor()->getMock();
     $this->themeConfigFactory = $this->getMockBuilder('Magento\\Framework\\Config\\ThemeFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->directory = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->disableOriginalConstructor()->getMock();
     $this->filesystem->expects($this->once())->method('getDirectoryRead')->willReturn($this->directory);
     $this->model = new Collection($this->entityFactory, $this->filesystem, $this->themeConfigFactory);
 }
示例#17
0
 protected function setUp()
 {
     $this->filesystemMock = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false, false);
     $this->directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', [], [], '', false, false);
     $this->_stringMock = $this->getMock('Magento\\Framework\\Stdlib\\String', [], [], '', false, false);
     $this->_stringMock->expects($this->once())->method('upperCaseWords')->will($this->returnValue('Test/Module'));
     $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->will($this->returnValue($this->directoryMock));
     $this->_model = new \Magento\Framework\Module\Dir($this->filesystemMock, $this->_stringMock);
 }
示例#18
0
 public function setUp()
 {
     $this->filesystemMock = $this->getMockBuilder('Magento\\Framework\\Filesystem')->disableOriginalConstructor()->getMock();
     $this->dataHelperMock = $this->getMockBuilder('Magento\\Backup\\Helper\\Data')->disableOriginalConstructor()->getMock();
     $this->directoryMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\WriteInterface')->getMock();
     $this->filesystemMock->expects($this->atLeastOnce())->method('getDirectoryWrite')->with(DirectoryList::VAR_DIR)->willReturn($this->directoryMock);
     $this->objectManager = new ObjectManager($this);
     $this->backupModel = $this->objectManager->getObject('Magento\\Backup\\Model\\Backup', ['filesystem' => $this->filesystemMock, 'helper' => $this->dataHelperMock]);
 }
示例#19
0
 /**
  * Test for get method with primary scope
  *
  * @dataProvider providerGet
  * @param string $filename
  * @param array $fileList
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function testGetPrimary($filename, $fileList)
 {
     $scope = 'primary';
     $directory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Read', ['search', 'getRelativePath'], [], '', false);
     $directory->expects($this->once())->method('search')->with(sprintf('{%1$s,*/%1$s}', $filename))->will($this->returnValue($fileList));
     $this->filesystem->expects($this->once())->method('getDirectoryRead')->with(DirectoryList::CONFIG)->will($this->returnValue($directory));
     $this->iteratorFactory->expects($this->once())->method('create')->with($directory, $fileList)->will($this->returnValue(true));
     $this->assertTrue($this->model->get($filename, $scope));
 }
示例#20
0
 /**
  * Create mocks and model
  */
 public function setUp()
 {
     $this->_helper = $this->getMock('Magento\\Captcha\\Helper\\Data', array(), array(), '', false);
     $this->_adminHelper = $this->getMock('Magento\\Captcha\\Helper\\Adminhtml\\Data', array(), array(), '', false);
     $this->_filesystem = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false);
     $this->_directory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', array(), array(), '', false);
     $this->_storeManager = $this->getMock('Magento\\Store\\Model\\StoreManager', array(), array(), '', false);
     $this->_filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($this->_directory));
     $this->_model = new \Magento\Captcha\Model\Cron($this->getMock('Magento\\Captcha\\Model\\Resource\\LogFactory', array(), array(), '', false), $this->_helper, $this->_adminHelper, $this->_filesystem, $this->_storeManager);
 }
示例#21
0
 public function setUp()
 {
     $this->filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->varReaderWriter = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface', [], '', false);
     $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($this->varReaderWriter));
     $this->logger = $this->getMockForAbstractClass('\\Psr\\Log\\LoggerInterface', [], '', false);
     $this->setupLoggerFactory = $this->getMock('\\Magento\\Setup\\Model\\Cron\\SetupLoggerFactory', [], [], '', false);
     $this->setupLoggerFactory->expects($this->once())->method('create')->with('setup-cron')->willReturn($this->logger);
     $this->status = new Status($this->filesystem, $this->setupLoggerFactory);
 }
 /**
  * @return void
  */
 protected function setUp()
 {
     $this->file = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Driver\\File')->disableOriginalConstructor()->setMethods(['filePutContents', 'getRealPath', 'createDirectory'])->getMock();
     $this->config = $this->getMockBuilder('Migration\\Config')->disableOriginalConstructor()->setMethods(['getOption'])->getMock();
     $directoryRead = $this->getMockBuilder('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->disableOriginalConstructor()->getMock();
     $directoryRead->expects($this->any())->method('getAbsolutePath')->willReturn('/path/to/var');
     $this->filesystem = $this->getMockBuilder('\\Magento\\Framework\\Filesystem')->disableOriginalConstructor()->setMethods(['getDirectoryRead'])->getMock();
     $this->filesystem->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::VAR_DIR)->willReturn($directoryRead);
     $this->fileHandler = new FileHandler($this->file, $this->config, $this->filesystem);
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $this->filesystemDriver = $this->getMockBuilder('\\Magento\\Framework\\Filesystem\\Driver\\File')->setMethods(['isExists', 'filePutContents', 'fileGetContents'])->disableOriginalConstructor()->getMock();
     $this->filesystemDriver->expects($this->any())->method('filePutContents')->will($this->returnValue(true));
     $directoryRead = $this->getMockBuilder('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->disableOriginalConstructor()->getMock();
     $directoryRead->expects($this->any())->method('getAbsolutePath')->willReturn('/path/to/var');
     $this->filesystem = $this->getMockBuilder('\\Magento\\Framework\\Filesystem')->setMethods(['getDirectoryRead'])->disableOriginalConstructor()->getMock();
     $this->filesystem->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::VAR_DIR)->willReturn($directoryRead);
     $this->file = new File($this->filesystemDriver, $this->filesystem);
 }
示例#24
0
 /**
  * Set up test
  */
 protected function setUp()
 {
     $entryPoint = '';
     $this->filesystemMock = $this->getMock('\\Magento\\Framework\\Filesystem', ['getDirectoryRead'], [], '', false);
     $this->indexerFactoryMock = $this->getMock('Magento\\Indexer\\Model\\IndexerFactory', ['create', 'load', 'reindexAll', 'getTitle'], [], '', false);
     $this->indexersFactoryMock = $this->getMock('Magento\\Indexer\\Model\\Indexer\\CollectionFactory', ['create', 'getItems'], [], '', false);
     $readInterfaceMock = $this->getMockForAbstractClass('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface', [], '', false, false, true, []);
     $this->filesystemMock->expects($this->once())->method('getDirectoryRead')->will($this->returnValue($readInterfaceMock));
     $this->model = new \Magento\Indexer\Model\Shell($this->filesystemMock, $entryPoint, $this->indexersFactoryMock, $this->indexerFactoryMock);
 }
 /**
  * Create mocks and model
  */
 public function setUp()
 {
     $this->_helper = $this->getMock('Magento\\Captcha\\Helper\\Data', [], [], '', false);
     $this->_adminHelper = $this->getMock('Magento\\Captcha\\Helper\\Adminhtml\\Data', [], [], '', false);
     $this->_filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->_directory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
     $this->_storeManager = $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false);
     $this->_filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($this->_directory));
     $this->_deleteExpiredImages = new \Magento\Captcha\Cron\DeleteExpiredImages($this->_helper, $this->_adminHelper, $this->_filesystem, $this->_storeManager);
 }
示例#26
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);
 }
示例#27
0
 public function testConstructStream()
 {
     $this->markTestSkipped('MAGETWO-17084: Replace PHP native calls');
     $stream = 'data://text/plain;base64,' . base64_encode("column1,column2\nvalue1,value2\n");
     $this->_directoryMock->expects($this->any())->method('openFile')->will($this->returnValue(new \Magento\Framework\Filesystem\File\Read($stream, new \Magento\Framework\Filesystem\Driver\Http())));
     $this->_filesystem->expects($this->any())->method('getDirectoryWrite')->will($this->returnValue($this->_directoryMock));
     $model = new \Magento\ImportExport\Model\Import\Source\Csv($stream, $this->_filesystem);
     foreach ($model as $value) {
         $this->assertSame(['column1' => 'value1', 'column2' => 'value2'], $value);
     }
 }
示例#28
0
 protected function setUp()
 {
     $this->filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->materializationStrategyFactory = $this->getMock('Magento\\Framework\\App\\View\\Asset\\MaterializationStrategy\\Factory', [], [], '', false);
     $this->object = new Publisher($this->filesystem, $this->materializationStrategyFactory);
     $this->rootDirWrite = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface');
     $this->staticDirRead = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\ReadInterface');
     $this->staticDirWrite = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface');
     $this->filesystem->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::STATIC_VIEW)->will($this->returnValue($this->staticDirRead));
     $this->filesystem->expects($this->any())->method('getDirectoryWrite')->will($this->returnValueMap([[DirectoryList::ROOT, DriverPool::FILE, $this->rootDirWrite], [DirectoryList::STATIC_VIEW, DriverPool::FILE, $this->staticDirWrite]]));
 }
 public function setUp()
 {
     self::$log = '';
     $this->directoryWriteMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
     $this->directoryWriteMock->expects($this->any())->method('readFile')->with('install.log')->will($this->returnCallback(['Magento\\Setup\\Test\\Unit\\Model\\WebLoggerTest', 'readLog']));
     $this->directoryWriteMock->expects($this->any())->method('writeFile')->with('install.log')->will($this->returnCallback(['Magento\\Setup\\Test\\Unit\\Model\\WebLoggerTest', 'writeToLog']));
     $this->directoryWriteMock->expects($this->any())->method('isExist')->will($this->returnCallback(['Magento\\Setup\\Test\\Unit\\Model\\WebLoggerTest', 'isExist']));
     $this->filesystemMock = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->filesystemMock->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($this->directoryWriteMock));
     $this->webLogger = new WebLogger($this->filesystemMock);
 }
示例#30
0
 /**
  * @param bool $isExist
  * @param array $callCount
  * @dataProvider executeProvider
  */
 public function testExecute($isExist, $callCount)
 {
     $this->_response->expects($this->once())->method('setCode')->with(0);
     $this->_response->expects($this->once())->method('getCode')->will($this->returnValue(0));
     $dir = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
     $dir->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0));
     $dir->expects($this->once())->method('isExist')->will($this->returnValue($isExist));
     $dir->expects($this->exactly($callCount))->method('delete')->will($this->returnValue(true));
     $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($dir));
     $this->processor->expects($this->once())->method('reindexAll');
     $this->assertEquals(0, $this->entryPoint->launch()->getCode());
 }