Ejemplo n.º 1
0
 public function testGetAndSetNamespace()
 {
     $temp = new Temping();
     $temp->create('skeleton.php');
     $skeleton = new Skeleton($temp->getPathname('skeleton.php'));
     $this->assertSame($skeleton, $skeleton->setNamespace('Foo'));
     $this->assertSame('Foo', $skeleton->getNamespace());
     $temp->reset();
 }
Ejemplo n.º 2
0
 public function testCustomDirUsage()
 {
     $custom_dir = str_replace(Temping::TEMPING_DIR_NAME, 'test-dir', $this->createFilePath(null));
     $temp = new Temping($custom_dir);
     $temp->create('foo.txt', 'Hello, Earth');
     $path = $custom_dir . '/foo.txt';
     $this->assertFileExists($path);
     $this->assertSame('Hello, Earth', file_get_contents($path));
     $temp->create('/foo/bar/baz/etc.txt', 'Howdy');
     $long_path = $custom_dir . '/foo/bar/baz/etc.txt';
     $this->assertFileExists($long_path);
     $this->assertSame('Howdy', file_get_contents($long_path));
     $temp->reset();
     $this->assertFileNotExists($path);
     $this->assertFileNotExists($long_path);
     $this->assertFileNotExists($custom_dir);
 }
Ejemplo n.º 3
0
 public function testConcatenateAssets()
 {
     $temping = new Temping();
     $base = 'path/to/assets/';
     $this->config->set('my-module.assets.css.main', ['foo.css', 'bar/bar.css']);
     $hashed_css_file = $temping->getPathname($base . $this->assets->hashGroup('my-module:main', 'css'));
     $this->assertFileNotExists($hashed_css_file);
     $this->config->set('my-module.assets.js.main', ['foo.js', 'bar/bar.js']);
     $hashed_js_file = $temping->getPathname($base . $this->assets->hashGroup('my-module:main', 'js'));
     $this->assertFileNotExists($hashed_js_file);
     $temping = new Temping();
     $asset_files = ['foo.css', 'bar/bar.css', 'foo.js', 'bar/bar.js'];
     foreach ($asset_files as $file) {
         $temping->create($base . $file, $file);
     }
     $this->assets->concatenateAssets('my-module', $temping->getPathname('path/to/assets/'));
     $this->assertFileExists($hashed_css_file);
     $css_content = 'foo.css' . PHP_EOL . PHP_EOL . 'bar/bar.css' . PHP_EOL . PHP_EOL;
     $this->assertSame($css_content, file_get_contents($hashed_css_file));
     $this->assertFileExists($hashed_js_file);
     $js_content = 'foo.js' . PHP_EOL . PHP_EOL . 'bar/bar.js' . PHP_EOL . PHP_EOL;
     $this->assertSame($js_content, file_get_contents($hashed_js_file));
     $temping->reset();
 }
 public function testFileSpool()
 {
     //use a temporary directory so FileSpool can create the path it
     //requires
     $temping = new Temping();
     $path = $temping->getPathname('foo/bar');
     $config = ['driver' => 'file', 'path' => $path];
     $spool = $this->factory->createSpool($config);
     //clean up the temporary directory before any assertions in case they
     //fail
     $temping->reset();
     $this->assertInstanceOf('\\Swift_FileSpool', $spool);
     //FileSpool doesn't have a getPath() method
     $r = new \ReflectionClass('\\Swift_FileSpool');
     $property = $r->getProperty('_path');
     $property->setAccessible(true);
     $this->assertSame($path, $property->getValue($spool));
 }