/** * @group Core */ public function testPrioritySort() { $baseDirectory = '/var/www/piwik/'; $priorityPatterns = array('libs/base.css', 'libs/', 'plugins/'); $catalogSorter = new UIAssetCatalogSorter($priorityPatterns); $unsortedCatalog = new UIAssetCatalog($catalogSorter); $unsortedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'new_dir/new_file')); $unsortedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'plugins/xyz')); $unsortedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'plugins/abc')); $unsortedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'libs/xyz')); $unsortedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'libs/base.css')); $unsortedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'libs/abc')); $unsortedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'plugins/xyz')); $unsortedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'libs/base.css')); $unsortedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'libs/xyz')); $expectedCatalog = new UIAssetCatalog($catalogSorter); $expectedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'libs/base.css')); $expectedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'libs/xyz')); $expectedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'libs/abc')); $expectedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'plugins/xyz')); $expectedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'plugins/abc')); $expectedCatalog->addUIAsset(new OnDiskUIAsset($baseDirectory, 'new_dir/new_file')); $sortedCatalog = $unsortedCatalog->getSortedCatalog(); $this->assertEquals($expectedCatalog, $sortedCatalog); }
private function sortCatalog() { $this->catalog = $this->catalog->getSortedCatalog(); }