コード例 #1
1
 public function testToArray()
 {
     $contents = ['content1', 'content2'];
     $expectedArray = [];
     $index = 0;
     foreach ($this->filePaths as $filePath) {
         $expectedArray[$filePath] = $contents[$index];
         $this->fileReadFactory->expects($this->at($index))->method('create')->with($filePath)->willReturn($this->fileRead);
         $this->fileRead->expects($this->at($index))->method('readAll')->will($this->returnValue($contents[$index++]));
     }
     $this->assertEquals($expectedArray, $this->fileIterator->toArray());
 }
コード例 #2
0
    public function testGetConfig()
    {
        $this->fileReader->expects($this->any())->method('readAll')->will($this->returnCallback(function ($file) {
            return $file . ' content';
        }));
        $fileOne = $this->getMock('\\Magento\\Framework\\View\\File', [], [], '', false);
        $fileOne->expects($this->once())->method('getFilename')->will($this->returnValue('some/full/relative/path/file_one.js'));
        $fileOne->expects($this->once())->method('getName')->will($this->returnValue('file_one.js'));
        $fileOne->expects($this->once())->method('getModule')->will($this->returnValue('Module_One'));
        $fileTwo = $this->getMock('\\Magento\\Framework\\View\\File', [], [], '', false);
        $fileTwo->expects($this->once())->method('getFilename')->will($this->returnValue('some/full/relative/path/file_two.js'));
        $fileTwo->expects($this->once())->method('getName')->will($this->returnValue('file_two.js'));
        $theme = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Design\\ThemeInterface');
        $this->design->expects($this->once())->method('getDesignTheme')->will($this->returnValue($theme));
        $this->fileSource->expects($this->once())->method('getFiles')->with($theme, Config::CONFIG_FILE_NAME)->will($this->returnValue([$fileOne, $fileTwo]));
        $this->minificationMock->expects($this->atLeastOnce())->method('isEnabled')->with('js')->willReturn(true);
        $expected = <<<expected
(function(require){
(function() {
file_one.js content
require.config(config);
})();
(function() {
file_two.js content
require.config(config);
})();



})(require);
expected;
        $this->minifyAdapterMock->expects($this->once())->method('minify')->with($expected)->willReturnArgument(0);
        $actual = $this->object->getConfig();
        $this->assertEquals($actual, $expected);
    }
コード例 #3
0
ファイル: ReadTest.php プロジェクト: pradeep-wagento/magento2
 public function testSeek()
 {
     $offset = 5;
     $whence = SEEK_SET;
     $result = 'content';
     $this->driver->expects($this->once())->method('fileSeek')->with($this->resource, $offset, $whence)->will($this->returnValue($result));
     $this->assertEquals($result, $this->file->seek($offset, $whence));
 }
コード例 #4
0
 public function testRead()
 {
     $this->read->expects($this->at(0))->method('readAll')->will($this->returnValue(file_get_contents($this->_paths[0])));
     $this->read->expects($this->at(1))->method('readAll')->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'));
 }
コード例 #5
0
ファイル: Write.php プロジェクト: kidaa30/magento2-platformsh
 /**
  * Constructor
  *
  * @param string $path
  * @param DriverInterface $driver
  * @param string $mode
  */
 public function __construct($path, DriverInterface $driver, $mode)
 {
     $this->mode = $mode;
     parent::__construct($path, $driver);
 }