Example #1
0
 /**
  * @covers Columnis\Model\Template::getDefinedAssets
  * @covers Columnis\Model\Template::searchAssets
  */
 public function testGetAssets()
 {
     $template = new Template();
     $path = $this->getExampleTemplatePath();
     $template->setPath($path);
     $name = 'example-template';
     $template->setName($name);
     $extensions = array('css', 'js');
     $extension = $extensions[array_rand($extensions)];
     $searchAssets = array('css' => array(realpath($path . DIRECTORY_SEPARATOR . 'css/example.css'), realpath($path . DIRECTORY_SEPARATOR . 'css/example2.css')), 'js' => array(realpath($path . DIRECTORY_SEPARATOR . 'js/example.js')));
     $definedAssets = array('css' => array(realpath(Bootstrap::getTestFilesDir() . 'public.dist/css/jquery-ui.css')), 'js' => array(realpath(Bootstrap::getTestFilesDir() . 'public.dist/js/jquery-1.8.2.min.js')));
     $expectedDefinedAssets = $definedAssets[$extension];
     $expectedSearchAssets = $searchAssets[$extension];
     sort($expectedSearchAssets);
     $expectedAssets = array_merge($expectedDefinedAssets, $expectedSearchAssets);
     $this->assertEquals($expectedAssets, $template->getAssets($extension));
 }
 /**
  * Returns true if it is a valid template
  *
  * @param string $templatePath
  * @return boolean
  */
 public function validTemplate($templatePath)
 {
     if (!is_dir($templatePath)) {
         return false;
     }
     $template = new Template();
     $template->setPath($templatePath);
     return $template->isValid();
 }
 /**
  * Creats a Template instance from an array with page Data.
  *
  * @param array $data
  * @throws TemplateNameNotSetException
  * @return Template
  */
 public function createFromData(array $data)
 {
     if (isset($data['template']) && !empty($data['template'])) {
         $templateName = $data['template'];
     } else {
         throw new TemplateNameNotSetException("Template not set in page response.");
     }
     if (isset($data['template_path']) && !empty($data['template_path'])) {
         $path = $data['template_path'];
     } else {
         $path = $this->getExistantTemplatePath($templateName);
     }
     $template = new Template();
     $template->setName($templateName);
     $template->setPath($path);
     return $template;
 }