Пример #1
0
 /**
  * @return Stdlib\TempFileObject
  */
 protected function getTempFileObject($ext = null)
 {
     return new Stdlib\TempFileObject(is_callable($this->options['tmpPath']) ? call_user_func($this->options['tmpPath']) : realpath($this->options['tmpPath']) . DIRECTORY_SEPARATOR . Stdlib\Utils\StringUtils::randString(50) . ($ext ? '.' . $ext : ''), 'w+');
 }
Пример #2
0
 /**
  *
  */
 public function testCodePhpCompile()
 {
     // /path/to/file.%
     $this->assertEquals(trim($this->getPreprocInstance(self::getFactoryOptions(array('resources' => self::getTestFilePath('test.%s'), 'options' => array('phpOnly' => true))))->process($this->data)), trim($this->phpProcess(self::getTestFilePath('test.%s'))));
     // file:///path/to/file.%
     $this->assertEquals(trim($this->getPreprocInstance(self::getFactoryOptions(array('resources' => 'file://' . self::getTestFilePath('test.%s'), 'options' => array('phpOnly' => true))))->process($this->data)), trim($this->phpProcess(self::getTestFilePath('test.%s'))));
     // /path/to/file.% as string
     $this->assertEquals(trim($this->getPreprocInstance(self::getFactoryOptions(array('resources' => file_get_contents(self::getTestFilePath('test.%s')), 'options' => array('phpOnly' => true))))->process($this->data)), trim($this->phpProcess(self::getTestFilePath('test.%s'))));
     // as fopen resource
     $this->assertEquals(trim($this->getPreprocInstance(self::getFactoryOptions(array('resources' => fopen(self::getTestFilePath('test.%s'), 'r+'), 'options' => array('phpOnly' => true))))->process($this->data)), trim($this->phpProcess(self::getTestFilePath('test.%s'))));
     // as FileObject
     $this->assertEquals(trim($this->getPreprocInstance(self::getFactoryOptions(array('resources' => new FileObject(self::getTestFilePath('test.%s'), 'r+'), 'options' => array('phpOnly' => true))))->process($this->data)), trim($this->phpProcess(self::getTestFilePath('test.%s'))));
     // test zend cache compile
     $cache = new \AthemTest\Code\Cache\ZendCache(StringUtils::randString(50));
     $this->assertEquals(trim($this->getPreprocInstance(self::getFactoryOptions(array('resources' => self::getTestFilePath('test.%s'), 'options' => array('cacheAdapter' => $cache, 'phpOnly' => true))))->process($this->data)), trim($this->phpProcess(self::getTestFilePath('test.%s'))));
     $this->assertTrue($cache->exists());
     $this->assertEquals(trim($cache->read()), trim($this->phpProcess(self::getTestFilePath('test.%s'))));
     $this->assertEquals(trim($this->getPreprocInstance(self::getFactoryOptions(array('resources' => self::getTestFilePath('test.%s'), 'options' => array('cacheAdapter' => $cache, 'phpOnly' => true))))->process($this->data)), trim($this->phpProcess(self::getTestFilePath('test.%s'))));
     // test doctrine cache compile
     $cache = new \AthemTest\Code\Cache\DoctrineCache(StringUtils::randString(50));
     $this->assertEquals(trim($this->getPreprocInstance(self::getFactoryOptions(array('resources' => self::getTestFilePath('test.%s'), 'options' => array('cacheAdapter' => $cache, 'phpOnly' => true))))->process($this->data)), trim($this->phpProcess(self::getTestFilePath('test.%s'))));
     $this->assertTrue($cache->exists());
     $this->assertEquals(trim($cache->read()), trim($this->phpProcess(self::getTestFilePath('test.%s'))));
     $this->assertEquals(trim($this->getPreprocInstance(self::getFactoryOptions(array('resources' => self::getTestFilePath('test.%s'), 'options' => array('cacheAdapter' => $cache, 'phpOnly' => true))))->process($this->data)), trim($this->phpProcess(self::getTestFilePath('test.%s'))));
 }