Exemplo n.º 1
0
 public function testGetUri()
 {
     $serviceManager = Bootstrap::getServiceManager();
     $apiService = $serviceManager->get('Columnis\\Service\\ApiService');
     /* @var $apiService ApiService */
     $endpoint = "/" . Bootstrap::getRandString();
     $clientNumber = $apiService->getClientNumber();
     $this->assertEquals($clientNumber . '/columnis' . $endpoint, $apiService->getUri($endpoint));
 }
Exemplo n.º 2
0
 public function testIsSubpath()
 {
     $folder = Bootstrap::getRandString();
     $subfolder = Bootstrap::getRandString();
     $path = __DIR__ . DIRECTORY_SEPARATOR . $folder;
     $subpath = $path . DIRECTORY_SEPARATOR . $subfolder;
     $create = mkdir($path);
     $this->assertTrue($create);
     $create2 = mkdir($subpath);
     $this->assertTrue($create2);
     $res = DirectoryUtils::isSubpath($path, $subpath);
     $this->assertTrue($res);
     $deleted = rmdir($subpath);
     $this->assertTrue($deleted);
     $deleted2 = rmdir($path);
     $this->assertTrue($deleted2);
 }
 public function testResolve()
 {
     $serviceManager = Bootstrap::getServiceManager();
     $templateAssetsResolver = $serviceManager->get('Columnis\\Model\\TemplateAssetsResolver');
     /* @var $templateAssetsResolver TemplateAssetsResolver */
     $templateAssetsResolver->setMimeResolver($serviceManager->get('AssetManager\\Service\\MimeResolver'));
     $templateAssetsResolver->setAggregateResolver($serviceManager->get('AssetManager\\Service\\AggregateResolver'));
     $templateAssetsResolver->setAssetFilterManager($serviceManager->get('AssetManager\\Service\\AssetFilterManager'));
     $alias = 'templates/example-template/css/minified.css';
     $assetCollection = $templateAssetsResolver->resolve($alias);
     $this->assertInstanceOf('Assetic\\Asset\\AssetCollection', $assetCollection);
     $sources = array();
     foreach ($assetCollection as $asset) {
         $sources[] = $asset->getSourceRoot() . DIRECTORY_SEPARATOR . $asset->getSourcePath();
     }
     $expectedSources = array(Bootstrap::getTestFilesDir() . 'public.dist/css/jquery-ui.css', Bootstrap::getTestFilesDir() . 'public.dist/templates/example-template/css/example.css', Bootstrap::getTestFilesDir() . 'public.dist/templates/example-template/css/example2.css');
     $this->assertEquals($expectedSources, $sources);
 }
Exemplo n.º 4
0
 /**
  * @expectedException \Columnis\Exception\Page\PageWithoutTemplateException
  */
 public function testFetchWithoutTemplate()
 {
     $serviceManager = Bootstrap::getServiceManager();
     $pageService = $serviceManager->get('Columnis\\Service\\PageService');
     /* @var $pageService \Columnis\Service\PageService */
     $apiService = $pageService->getApiService();
     $plugin = new Mock();
     $plugin->addResponse(Bootstrap::getTestFilesDir() . 'api-responses' . DIRECTORY_SEPARATOR . 'generate-invalid.mock');
     $mockedClient = $apiService->getHttpClient();
     $mockedClient->getEmitter()->attach($plugin);
     $page = new Page();
     $page->setId(1);
     $pageService->fetch($page);
 }
Exemplo n.º 5
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));
 }
 /**
  * @expectedException \Columnis\Exception\Templates\PathNotFoundException
  */
 public function testCreateFromDataWithInvalidTemplatePath()
 {
     $serviceManager = Bootstrap::getServiceManager();
     $templateService = $serviceManager->get('Columnis\\Service\\TemplateService');
     /* @var $templateService TemplateService */
     $path = 'unexistant/path/to/templates' . 'example-template';
     $data = array('template' => 'example-template', 'template_path' => $path);
     $templateService->createFromData($data);
 }
 public function setUp()
 {
     $this->setApplicationConfig(Bootstrap::getConfig());
     parent::setUp();
 }