コード例 #1
0
 /**
  * @covers \Magento\Framework\View\Design\Theme\Customization\AbstractFile::prepareFile
  * @covers \Magento\Framework\View\Design\Theme\Customization\AbstractFile::_prepareFileName
  * @covers \Magento\Framework\View\Design\Theme\Customization\AbstractFile::_prepareFilePath
  * @covers \Magento\Framework\View\Design\Theme\Customization\AbstractFile::_prepareSortOrder
  * @dataProvider getTestContent
  */
 public function testPrepareFile($type, $fileContent, $expectedContent, $existedFiles)
 {
     $model = $this->_modelBuilder->getMock();
     $model->expects($this->any())->method('getType')->will($this->returnValue($type));
     $model->expects($this->any())->method('getContentType')->will($this->returnValue($type));
     $files = [];
     foreach ($existedFiles as $fileData) {
         $file = $this->getMock('Magento\\Theme\\Model\\Theme\\File', ['__wakeup', 'save'], [], '', false);
         $file->setData($fileData);
         $files[] = $file;
     }
     $customization = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\Customization', [], [], '', false);
     $customization->expects($this->atLeastOnce())->method('getFilesByType')->with($type)->will($this->returnValue($files));
     $theme = $this->getMock('Magento\\Theme\\Model\\Theme', [], [], '', false);
     $theme->expects($this->any())->method('getCustomization')->will($this->returnValue($customization));
     $file = $this->getMock('Magento\\Theme\\Model\\Theme\\File', ['__wakeup', 'getTheme', 'save'], [], '', false);
     $file->expects($this->any())->method('getTheme')->will($this->returnValue($theme));
     $file->setData($fileContent);
     /** @var $model \Magento\Framework\View\Design\Theme\Customization\AbstractFile */
     /** @var $file \Magento\Theme\Model\Theme\File */
     $model->prepareFile($file);
     $this->assertEquals($expectedContent, $file->getData());
 }
コード例 #2
0
 /**
  * Retrieve a registered instance
  *
  * @param string $name
  * @param mixed  $value
  * @param int    $create
  *
  * @throws ServiceNotFoundException
  * @return mixed
  */
 public function set($name, $value = null, $create = self::CREATE_CLASS)
 {
     if (null === $value && $create != self::CREATE_NOTHING) {
         $mockBuilder = new \PHPUnit_Framework_MockObject_MockBuilder($this->testCase, $name);
         $mockBuilder->disableOriginalConstructor();
         switch ($create) {
             case self::CREATE_ABSTRACT_CLASS:
                 $value = $mockBuilder->getMockForAbstractClass();
                 break;
             case self::CREATE_TRAIT:
                 $value = $mockBuilder->getMockForTrait();
                 break;
             default:
                 $value = $mockBuilder->getMock();
         }
     }
     $this->values[$name] = $value;
     return $this;
 }
コード例 #3
0
ファイル: MockFactory.php プロジェクト: peteraba/dm-test
 /**
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 public function getUrlMock()
 {
     $mockBuilder = new MockBuilder($this->testCase, 'Zend\\Mvc\\Controller\\Plugin\\Url');
     $mockBuilder->setMethods(['fromRoute']);
     $mockBuilder->disableOriginalConstructor();
     $urlMock = $mockBuilder->getMock();
     return $urlMock;
 }