/** * Setup new backend * * @param Requirements_Backend $backend */ protected function setupRequirements($backend) { // Flush requirements $backend->clear(); $backend->clearCombinedFiles(); $backend->setCombinedFilesFolder('_combinedfiles'); $backend->setMinifyCombinedJSFiles(false); Requirements::flush(); }
public function clear($fileOrID = null) { parent::clear($fileOrID); singleton('require')->clearFiles($fileOrID); }
function testRequirementsBackend() { $backend = new Requirements_Backend(); $backend->js('tests/phpunit/data/a.js'); $this->assertCount(1, $backend->get_js(), "There should be only 1 file included in required javascript."); $this->assertContains('tests/phpunit/data/a.js', $backend->get_js(), "/tests/phpunit/data/a.js should be included in required javascript."); $backend->js('tests/phpunit/data/b.js'); $this->assertCount(2, $backend->get_js(), "There should be 2 files included in required javascript."); $backend->block('tests/phpunit/data/a.js'); $this->assertCount(1, $backend->get_js(), "There should be only 1 file included in required javascript."); $this->assertNotContains('tests/phpunit/data/a.js', $backend->get_js(), "/tests/phpunit/data/a.js should not be included in required javascript after it has been blocked."); $this->assertContains('tests/phpunit/data/b.js', $backend->get_js(), "/tests/phpunit/data/b.js should be included in required javascript."); $backend->css('tests/phpunit/data/a.css'); $this->assertCount(1, $backend->get_css(), "There should be only 1 file included in required css."); $this->assertArrayHasKey('a.css', $backend->get_css(), "/tests/phpunit/data/a.css should be in required css."); $this->assertContains(array('file' => 'tests/phpunit/data/a.css', 'media' => null), $backend->get_css(), "/tests/phpunit/data/a.css should be in required css."); $backend->block('tests/phpunit/data/a.css'); $this->assertCount(0, $backend->get_css(), "There should be nothing in required css after file has been blocked."); // Test unblock_all() $backend->unblock_all(); $this->assertCount(2, $backend->get_js(), "There should be only 2 files included in required css."); $this->assertCount(1, $backend->get_css(), "There should be only 1 file included in required javascript."); // Testing clear() $backend->js('tests/phpunit/data/c.css'); $backend->clear(); $this->assertCount(0, $backend->get_css(), "There should be nothing in required css after requirements cleared."); $this->assertCount(0, $backend->get_js(), "There should be nothing in required js after requirements cleared."); // Testing js block by id $backend->js('tests/phpunit/data/a.js'); $backend->block('a.js'); $this->assertCount(0, $backend->get_js(), "There should be nothing in required js after file has be blocked."); // Testing css block by id $backend->css('tests/phpunit/data/a.css'); $backend->block('a.css'); $this->assertCount(0, $backend->get_css(), "There should be nothing in required css after file has been blocked."); // Testing unblock $backend->unblock('a.js'); $this->assertCount(1, $backend->get_js(), "There should be only 1 file included in required javascript."); }