Example #1
0
 public function testBaseDirectory()
 {
     $dir = new Directory();
     $dir->setPath(__DIR__);
     $ext = new BasicExtension();
     $this->assertInstanceOf('Bolt\\Extension\\AbstractExtension', $ext->setBaseDirectory($dir));
     $this->assertInstanceOf('Bolt\\Filesystem\\Handler\\Directory', $ext->getBaseDirectory());
     $this->assertSame(__DIR__, $ext->getBaseDirectory()->getPath());
 }
 public function testBaseDirectory()
 {
     $app = $this->getApp();
     $webDir = $app['filesystem']->getDir('extensions://');
     $dir = new Directory();
     $dir->setPath(__DIR__);
     $ext = new BasicExtension();
     $ext->setWebDirectory($webDir);
     $this->assertInstanceOf('Bolt\\Extension\\AbstractExtension', $ext->setBaseDirectory($dir));
     $this->assertInstanceOf('Bolt\\Filesystem\\Handler\\Directory', $ext->getBaseDirectory());
     $this->assertSame(__DIR__, $ext->getBaseDirectory()->getPath());
 }
 /**
  * Sets the current handler and path.
  */
 protected function setCurrent()
 {
     if (!isset($this->contents[$this->position])) {
         $this->current = null;
         $this->key = null;
         return;
     }
     $this->current = $this->contents[$this->position];
     $path = $this->current->getFullPath();
     if ($this->mode & static::KEY_FOR_GLOB) {
         // Glob code requires absolute paths, so prefix path
         // with leading slash, but not before mount point
         if (strpos($path, '://') > 0) {
             $path = str_replace('://', ':///', $path);
         } else {
             $path = '/' . ltrim($path, '/');
         }
     }
     $this->key = $path;
 }
Example #4
0
 public function testExists()
 {
     $dir = new Directory($this->filesystem);
     $this->assertTrue($dir->exists());
 }
Example #5
0
 public function testConfigFileInvalidYaml()
 {
     $app = $this->getApp();
     $filesystem = $app['filesystem'];
     $file = new YamlFile();
     $filesystem->getFile('config://extensions/config.bolt.yml', $file);
     $file->put("\tever so slightly invalid yaml");
     $ext = new ConfigExtension();
     $dir = new Directory();
     $dir->setPath('local/bolt/config');
     $ext->setBaseDirectory($dir);
     $refObj = new \ReflectionObject($ext);
     $method = $refObj->getMethod('getConfig');
     $method->setAccessible(true);
     $ext->setContainer($app);
     $this->setExpectedException('Bolt\\Filesystem\\Exception\\ParseException', 'A YAML file cannot contain tabs as indentation');
     $conf = $method->invoke($ext);
     $this->assertSame(['blame' => 'gnomes'], $conf);
 }
Example #6
0
 public function testRegisterValidAssetsThemePath()
 {
     $app = $this->getApp();
     $mock = $this->getMock('\\Bolt\\Filesystem\\Manager', ['has']);
     $mock->expects($this->at(1))->method('has')->willReturn(true)->with('theme://js/test.js');
     $dir = new Directory();
     $dir->setPath('local/bolt/koala');
     $ext = new AssetExtension();
     $ext->setAssets([new JavaScript('js/test.js')]);
     $ext->setContainer($app);
     $ext->setBaseDirectory($dir);
     $ext->setRelativeUrl('/extensions/local/bolt/koala/');
     $app['filesystem'] = $mock;
     $ext->register($app);
     $fileQueue = $app['asset.queue.file']->getQueue();
     $queued = reset($fileQueue['javascript']);
     $this->assertInstanceOf('Bolt\\Asset\\File\\JavaScript', $queued);
     $this->assertSame('/theme/base-2014/js/test.js', $queued->getFileName());
 }