Inheritance: extends PHPUnit_Framework_TestCase
Example #1
0
use Zend\ServiceManager\ServiceManager;
use Zend\Mvc\Service\ServiceManagerConfig;
use Zend\Loader\StandardAutoloader;
error_reporting(E_ALL | E_STRICT);
chdir(__DIR__);
$previousDir = '.';
while (!file_exists('config/application.config.php')) {
    $dir = dirname(getcwd());
    if ($previousDir === $dir) {
        throw new RuntimeException('Unable to locate "config/application.config.php": ' . 'is DOMPDFModule in a subdir of your application skeleton?');
    }
    $previousDir = $dir;
    chdir($dir);
}
if (is_readable(__DIR__ . '/TestConfiguration.php')) {
    $configuration = (include_once __DIR__ . '/TestConfiguration.php');
} else {
    $configuration = (include_once __DIR__ . '/TestConfiguration.php.dist');
}
// Assumes PHP Composer autoloader w/compiled classmaps, etc.
require_once 'vendor/autoload.php';
// This namespace is not in classmap.
$loader = new StandardAutoloader(array(StandardAutoloader::LOAD_NS => array('DOMPDFModuleTest' => __DIR__ . '/DOMPDFModuleTest')));
$loader->register();
$serviceManager = new ServiceManager(new ServiceManagerConfig($configuration['service_manager']));
$serviceManager->setService('ApplicationConfig', $configuration);
$serviceManager->setAllowOverride(true);
$moduleManager = $serviceManager->get('ModuleManager');
$moduleManager->loadModules();
TestCase::setServiceManager($serviceManager);
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->renderer = new PdfRenderer();
     $this->strategy = new PdfStrategy($this->renderer);
     $this->event = new ViewEvent();
     $this->response = new HttpResponse();
     $this->resolver = new TemplatePathStack();
     $this->resolver->addPath(dirname(__DIR__) . '/_templates');
     $this->renderer->setResolver($this->resolver);
     $htmlRenderer = new PhpRenderer();
     $htmlRenderer->setResolver($this->resolver);
     $this->renderer->setHtmlRenderer($htmlRenderer);
     $this->renderer->setEngine($this->getServiceManager()->get('dompdf'));
 }