public function testRecursiveSearchByExtension() { $files = array(Bootstrap::getTestFilesDir() . 'directory-tests/somefilefor.test', Bootstrap::getTestFilesDir() . 'directory-tests/anotherfilefor.test', Bootstrap::getTestFilesDir() . 'directory-tests/for-recursive/recursivefilefor.test', Bootstrap::getTestFilesDir() . 'directory-tests/for-recursive/anotherfilefor.test', Bootstrap::getTestFilesDir() . 'directory-tests/for-recursive/more-recursive/morerecursivefilefor.test', Bootstrap::getTestFilesDir() . 'directory-tests/for-recursive/more-recursive/anotherfilefor.test'); $search = DirectoryUtils::recursiveSearchByExtension(Bootstrap::getTestFilesDir(), 'test'); sort($search); sort($files); $this->assertEquals($files, $search); }
/** * @expectedException \Columnis\Exception\Api\ApiRequestException */ public function testRequestFail() { $serviceManager = Bootstrap::getServiceManager(); $apiService = $serviceManager->get('Columnis\\Service\\ApiService'); /* @var $apiService ApiService */ $plugin = new Mock(); $plugin->addResponse(Bootstrap::getTestFilesDir() . 'api-responses' . DIRECTORY_SEPARATOR . 'forbidden.mock'); $mockedClient = $apiService->getHttpClient(); $mockedClient->getEmitter()->attach($plugin); $endpoint = '/non/existant/endpoint'; $uri = $apiService->getUri($endpoint); $apiService->request($uri); }
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); }
/** * @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); }
/** * @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)); }
public function testValidTemplateWithInvalidFolderContents() { $serviceManager = Bootstrap::getServiceManager(); $templateService = $serviceManager->get('Columnis\\Service\\TemplateService'); /* @var $templateService TemplateService */ $templateName = 'directory-tests'; // Existant path $path = Bootstrap::getTestFilesDir() . $templateName; $this->assertFalse($templateService->validTemplate($path)); }