當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ThemeInterface::expects方法代碼示例

本文整理匯總了PHP中Magento\Framework\View\Design\ThemeInterface::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP ThemeInterface::expects方法的具體用法?PHP ThemeInterface::expects怎麽用?PHP ThemeInterface::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\View\Design\ThemeInterface的用法示例。


在下文中一共展示了ThemeInterface::expects方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setup

 public function setup()
 {
     $this->themeDirectoryMock = $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->themeMock->expects($this->once())->method('getFullPath')->will($this->returnValue($this->themePath));
     $this->readDirFactory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\ReadFactory', [], [], '', false);
     $this->readDirFactory->expects($this->any())->method('create')->will($this->returnValue($this->themeDirectoryMock));
     $this->componentRegistrar = $this->getMockForAbstractClass('Magento\\Framework\\Component\\ComponentRegistrarInterface');
     $this->themeFileCollector = new Theme($this->fileFactoryMock, $this->readDirFactory, $this->componentRegistrar);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:11,代碼來源:ThemeTest.php

示例2: testGetFilesMultiple

 public function testGetFilesMultiple()
 {
     $dirPath = '/Magento_Customer/css/';
     $themePath = '/opt/magento2/app/design/frontend/Magento/blank';
     $searchPath = 'css/*.test';
     $this->themeMock->expects($this->any())->method('getFullPath')->will($this->returnValue($themePath));
     $this->themesDirectoryMock->expects($this->any())->method('getAbsolutePath')->will($this->returnValueMap([['fileA.test', $dirPath . 'fileA.test'], ['fileB.tst', $dirPath . 'fileB.tst'], ['fileC.test', $dirPath . 'fileC.test']]));
     $fileMock = $this->getMockBuilder('Magento\\Framework\\View\\File')->disableOriginalConstructor()->getMock();
     // Verifies correct files are searched for
     $this->themesDirectoryMock->expects($this->once())->method('search')->with($themePath . '/' . $searchPath)->will($this->returnValue(['fileA.test', 'fileC.test']));
     // Verifies Magento_Customer was correctly produced from directory path
     $this->fileFactoryMock->expects($this->any())->method('create')->with($this->isType('string'), null, $this->equalTo($this->themeMock))->will($this->returnValue($fileMock));
     $theme = new Theme($this->filesystemMock, $this->fileFactoryMock);
     // Only two files should be in array, which were returned from search
     $this->assertEquals([$fileMock, $fileMock], $theme->getFiles($this->themeMock, 'css/*.test'));
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:16,代碼來源:ThemeTest.php

示例3: testGetFiles

 public function testGetFiles()
 {
     $files = [];
     foreach (['shared', 'theme'] as $fileType) {
         for ($i = 0; $i < 2; $i++) {
             $file = $this->getMock('\\Magento\\Framework\\Component\\ComponentFile', [], [], '', false);
             $file->expects($this->once())->method('getFullPath')->will($this->returnValue("{$fileType}/module/{$i}/path"));
             $file->expects($this->once())->method('getComponentName')->will($this->returnValue('Module_' . $i));
             $files[$fileType][] = $file;
         }
     }
     $this->dirSearch->expects($this->any())->method('collectFilesWithContext')->willReturnMap([[ComponentRegistrar::MODULE, 'view/base/layout/*.xml', $files['shared']], [ComponentRegistrar::MODULE, 'view/frontend/layout/*.xml', $files['theme']]]);
     $this->fileFactoryMock->expects($this->atLeastOnce())->method('create')->willReturn($this->createFileMock());
     $this->themeMock->expects($this->once())->method('getData')->with('area')->willReturn('frontend');
     $result = $this->fileCollector->getFiles($this->themeMock, '*.xml');
     $this->assertCount(4, $result);
     $this->assertInstanceOf('Magento\\Framework\\View\\File', $result[0]);
     $this->assertInstanceOf('Magento\\Framework\\View\\File', $result[1]);
     $this->assertInstanceOf('Magento\\Framework\\View\\File', $result[2]);
     $this->assertInstanceOf('Magento\\Framework\\View\\File', $result[3]);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:21,代碼來源:BaseTest.php

示例4: testGetFiles

 /**
  *
  * @dataProvider getFilesDataProvider
  *
  * @param $libraryFiles array Files in lib directory
  * @param $baseFiles array Files in base directory
  * @param $themeFiles array Files in theme
  * *
  * @return void
  */
 public function testGetFiles($libraryFiles, $baseFiles, $themeFiles)
 {
     $this->fileListMock->expects($this->at(0))->method('add')->with($this->equalTo($libraryFiles));
     $this->fileListMock->expects($this->at(1))->method('add')->with($this->equalTo($baseFiles));
     $this->fileListMock->expects($this->any())->method('getAll')->will($this->returnValue(['returnedFile']));
     $subPath = '*';
     $this->libraryFilesMock->expects($this->atLeastOnce())->method('getFiles')->with($this->themeMock, $subPath)->will($this->returnValue($libraryFiles));
     $this->baseFilesMock->expects($this->atLeastOnce())->method('getFiles')->with($this->themeMock, $subPath)->will($this->returnValue($baseFiles));
     $this->overriddenBaseFilesMock->expects($this->any())->method('getFiles')->will($this->returnValue($themeFiles));
     $aggregated = new Aggregated($this->fileListFactoryMock, $this->libraryFilesMock, $this->baseFilesMock, $this->overriddenBaseFilesMock, $this->loggerMock);
     $inheritedThemeMock = $this->getMockBuilder('\\Magento\\Framework\\View\\Design\\ThemeInterface')->getMock();
     $this->themeMock->expects($this->any())->method('getInheritedThemes')->will($this->returnValue([$inheritedThemeMock]));
     $this->assertEquals(['returnedFile'], $aggregated->getFiles($this->themeMock, $subPath));
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:24,代碼來源:AggregatedTest.php

示例5: testGetFiles

 /**
  *
  * @dataProvider getFilesDataProvider
  *
  * @param $libraryFiles array Files in lib directory
  * @param $themeFiles array Files in theme
  * *
  * @return void
  */
 public function testGetFiles($libraryFiles, $themeFiles)
 {
     $this->fileListMock->expects($this->any())->method('getAll')->will($this->returnValue(['returnedFile']));
     $this->libraryDirectoryMock->expects($this->any())->method('search')->will($this->returnValue($libraryFiles));
     $this->libraryDirectoryMock->expects($this->any())->method('getAbsolutePath')->will($this->returnCallback(function ($file) {
         return '/opt/Magento/lib/' . $file;
     }));
     $themePath = '/var/Magento/ATheme';
     $subPath = '*';
     $readerMock = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->getMock();
     $this->readFactoryMock->expects($this->once())->method('create')->will($this->returnValue($readerMock));
     $this->componentRegistrarMock->expects($this->once())->method('getPath')->with(ComponentRegistrar::THEME, $themePath)->will($this->returnValue(['/path/to/theme']));
     $readerMock->expects($this->once())->method('search')->will($this->returnValue($themeFiles));
     $inheritedThemeMock = $this->getMockBuilder('\\Magento\\Framework\\View\\Design\\ThemeInterface')->getMock();
     $inheritedThemeMock->expects($this->any())->method('getFullPath')->will($this->returnValue($themePath));
     $this->themeMock->expects($this->any())->method('getInheritedThemes')->will($this->returnValue([$inheritedThemeMock]));
     $this->assertEquals(['returnedFile'], $this->library->getFiles($this->themeMock, $subPath));
 }
開發者ID:IlyaGluschenko,項目名稱:test001,代碼行數:27,代碼來源:LibraryTest.php

示例6: testGetFiles

    public function testGetFiles()
    {
        $sharedFiles = [
            'Namespace/One/view/base/layout/one.xml',
            'Namespace/Two/view/base/layout/two.xml'
        ];
        $themeFiles = [
            'Namespace/Two/view/frontend/layout/four.txt',
            'Namespace/Two/view/frontend/layout/three.xml'
        ];

        $this->directoryMock->expects($this->any())
            ->method('search')
            ->willReturnMap(
                [
                    ['*/*/view/base/layout/*.xml', null, $sharedFiles],
                    ['*/*/view/frontend/layout/*.xml', null, $themeFiles]
                ]
            );
        $this->pathPatternHelperMock->expects($this->once())
            ->method('translatePatternFromGlob')
            ->with('*.xml')
            ->willReturn('[^/]*\\.xml');
        $this->directoryMock->expects($this->atLeastOnce())
            ->method('getAbsolutePath')
            ->willReturnArgument(0);
        $this->fileFactoryMock->expects($this->atLeastOnce())
            ->method('create')
            ->willReturn($this->createFileMock());
        $this->themeMock->expects($this->once())
            ->method('getData')
            ->with('area')
            ->willReturn('frontend');

        $result = $this->fileCollector->getFiles($this->themeMock, '*.xml');
        $this->assertCount(3, $result);
        $this->assertInstanceOf('Magento\Framework\View\File', $result[0]);
        $this->assertInstanceOf('Magento\Framework\View\File', $result[1]);
        $this->assertInstanceOf('Magento\Framework\View\File', $result[2]);
    }
開發者ID:vasiljok,項目名稱:magento2,代碼行數:40,代碼來源:BaseTest.php


注:本文中的Magento\Framework\View\Design\ThemeInterface::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。