Exemplo n.º 1
0
 /**
  * Retrieve new layout update model instance with XML data from a fixture file
  *
  * @param string|array $layoutUpdatesFile
  * @return \Magento\Framework\View\Layout\ProcessorInterface
  */
 public function getLayoutUpdateFromFixture($layoutUpdatesFile)
 {
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     /** @var \Magento\Framework\View\File\Factory $fileFactory */
     $fileFactory = $objectManager->get('Magento\\Framework\\View\\File\\Factory');
     $files = array();
     foreach ((array) $layoutUpdatesFile as $filename) {
         $files[] = $fileFactory->create($filename, 'Magento_View');
     }
     $fileSource = $this->_testCase->getMockForAbstractClass('Magento\\Framework\\View\\File\\CollectorInterface');
     $fileSource->expects(\PHPUnit_Framework_TestCase::any())->method('getFiles')->will(\PHPUnit_Framework_TestCase::returnValue($files));
     $cache = $this->_testCase->getMockForAbstractClass('Magento\\Framework\\Cache\\FrontendInterface');
     return $objectManager->create('Magento\\Framework\\View\\Layout\\ProcessorInterface', array('fileSource' => $fileSource, 'cache' => $cache));
 }
 /**
  * @param \PHPUnit_Framework_TestCase $test
  * @param \Closure                    $qbCallback
  * @param array                       $fields
  *
  * @return \Doctrine\ORM\EntityManagerInterface
  */
 public static function create(\PHPUnit_Framework_TestCase $test, \Closure $qbCallback, $fields)
 {
     $query = $test->getMockForAbstractClass('Doctrine\\ORM\\AbstractQuery', [], '', false, true, true, ['execute']);
     $query->expects($test->any())->method('execute')->will($test->returnValue(true));
     if (Version::compare('2.5.0') < 1) {
         $entityManager = $test->getMock('Doctrine\\ORM\\EntityManagerInterface');
         $qb = $test->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->setConstructorArgs([$entityManager])->getMock();
     } else {
         $qb = $test->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
     }
     $qb->expects($test->any())->method('select')->will($test->returnValue($qb));
     $qb->expects($test->any())->method('getQuery')->will($test->returnValue($query));
     $qb->expects($test->any())->method('where')->will($test->returnValue($qb));
     $qb->expects($test->any())->method('orderBy')->will($test->returnValue($qb));
     $qb->expects($test->any())->method('andWhere')->will($test->returnValue($qb));
     $qb->expects($test->any())->method('leftJoin')->will($test->returnValue($qb));
     $qbCallback($qb);
     $repository = $test->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($test->any())->method('createQueryBuilder')->will($test->returnValue($qb));
     $metadata = $test->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
     $metadata->expects($test->any())->method('getFieldNames')->will($test->returnValue($fields));
     $metadata->expects($test->any())->method('getName')->will($test->returnValue('className'));
     $em = $test->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $em->expects($test->any())->method('getRepository')->will($test->returnValue($repository));
     $em->expects($test->any())->method('getClassMetadata')->will($test->returnValue($metadata));
     return $em;
 }
Exemplo n.º 3
0
function mockFileOutputStream(PHPUnit_Framework_TestCase $testcase, File $file)
{
    $in = $testcase->getMockForAbstractClass('BapCat\\Interfaces\\Persist\\FileOutputStream', [$file]);
    $in->method('write')->will($testcase->returnCallback(function ($data) {
        return strlen($data);
    }));
    return $in;
}
Exemplo n.º 4
0
function mockFileWriter(PHPUnit_Framework_TestCase $testcase, File $file)
{
    $in = $testcase->getMockForAbstractClass(FileWriter::class, [$file]);
    $in->method('write')->will($testcase->returnCallback(function ($data) {
        return strlen($data);
    }));
    return $in;
}
Exemplo n.º 5
0
 /**
  * Get mock without call of original constructor
  *
  * @param string $className
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 protected function _getMockWithoutConstructorCall($className)
 {
     $class = new \ReflectionClass($className);
     $mock = null;
     if ($class->isAbstract()) {
         $mock = $this->_testObject->getMockForAbstractClass($className, [], '', false, false);
     } else {
         $mock = $this->_testObject->getMock($className, [], [], '', false, false);
     }
     return $mock;
 }
Exemplo n.º 6
0
 /**
  * Creates a mock object for an abstract class using a fluent interface.
  *
  * @return PHPUnit_Framework_MockObject_MockObject
  */
 public function getMockForAbstractClass()
 {
     return $this->testCase->getMockForAbstractClass($this->className, $this->constructorArgs, $this->mockClassName, $this->originalConstructor, $this->originalClone, $this->autoload, $this->methods, $this->cloneArguments);
 }
Exemplo n.º 7
0
 /**
  * @param \PHPUnit_Framework_TestCase $test
  *
  * @return \PHPUnit_Framework_MockObject_MockObject|\LightSaml\Binding\AbstractBinding
  */
 public static function getBindingMock(\PHPUnit_Framework_TestCase $test)
 {
     return $test->getMockForAbstractClass(\LightSaml\Binding\AbstractBinding::class);
 }