Пример #1
0
<?php

/**
 * Optional add magento lib classes
 * @var \Composer\Autoload\ClassLoader $loader
 */
$loader = (require '../../vendor/autoload.php');
$loader->add('', '../../vendor/firegento/magento/lib');
use JSiefer\ClassMocker\ClassMocker;
use JSiefer\MageMock\Mage\MageFacade;
use JSiefer\MageMock\MagentoMock;
$magentoFramework = new MagentoMock();
$classMocker = new ClassMocker();
$classMocker->setGenerationDir('./var/generation');
$classMocker->mockFramework($magentoFramework);
$classMocker->enable();
$nameResolver = new \JSiefer\MageMock\ClassNameResolver();
$nameResolver->registerNamespace('sample', 'Magemock_Sample');
MageFacade::setNameResolver($nameResolver);
Пример #2
0
 /**
  * Check and validate generation folder
  *
  * @return void
  * @test
  * @expectedException \RuntimeException
  * @expectedExceptionMessage Failed to create class generation folder
  */
 public function shouldFailOnInvalidGenerationDir()
 {
     $vfs = vfsStream::setup('generation');
     $testDir = $vfs->url() . '/test';
     file_put_contents($testDir, 'Not a dir!');
     $classMocker = new ClassMocker();
     $classMocker->setGenerationDir($testDir);
     $classMocker->mock('ShouldFailOnInvalidGenerationDirTestClass');
     $classMocker->autoload('ShouldFailOnInvalidGenerationDirTestClass');
 }