/**
  * Constructor - finds and parses the ini file the plugin uses.
  *
  * @return void
  */
 public function __construct($options = array())
 {
     if (empty($options['noconfig'])) {
         $config = AssetConfig::buildFromIniFile();
         $this->config($config);
     }
 }
 /**
  * Config setter, used for testing the controller.
  */
 protected function _getConfig()
 {
     if (empty($this->_Config)) {
         $this->_Config = AssetConfig::buildFromIniFile();
     }
     return $this->_Config;
 }
/**
 * Constructor - finds and parses the ini file the plugin uses.
 *
 * @return void
 */
	public function __construct(View $View, $settings = array()) {
		if (empty($settings['noconfig'])) {
			$config = AssetConfig::buildFromIniFile();
			$this->config($config);
		}
		parent::__construct($View, $settings);
	}
	public function setUp() {
		parent::setUp();
		$this->_pluginPath = App::pluginPath('AssetCompress');
		$this->testConfig = $this->_pluginPath . 'Test' . DS . 'test_files' . DS . 'Config' . DS . 'integration.ini';

		$map = array(
			'TEST_FILES/' => $this->_pluginPath . 'Test' . DS . 'test_files' . DS
		);
		App::build(array(
			'Plugin' => array($map['TEST_FILES/'] . 'Plugin' . DS )
		));
		CakePlugin::load('TestAssetIni');
		
		AssetConfig::clearAllCachedKeys();

		$config = AssetConfig::buildFromIniFile($this->testConfig, $map);
		$config->filters('js', null, array());
		$this->Compressor = $this->getMock('AssetCompressor', array('_getConfig'));
		$this->Compressor->expects($this->atLeastOnce())
			->method('_getConfig')
			->will($this->returnValue($config));

		$this->request = new CakeRequest(null, false);
		$this->response = $this->getMock('CakeResponse', array('checkNotModified', 'type', 'send'));
		Configure::write('debug', 2);
	}
 /**
  * Create the configuration object used in other classes.
  *
  */
 public function startup()
 {
     parent::startup();
     AssetConfig::clearAllCachedKeys();
     $this->_Config = AssetConfig::buildFromIniFile($this->params['config']);
     $this->AssetBuild->setThemes($this->_findThemes());
     $this->out();
 }
 function setUp()
 {
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $this->testConfig = $this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'config' . DS . 'config.ini';
     $this->config = AssetConfig::buildFromIniFile($this->testConfig);
     $this->config->cachePath('js', TMP);
     $this->cache = new AssetCache($this->config);
 }
 function testBuildFileNameTheme()
 {
     $this->config = AssetConfig::buildFromIniFile($this->_themeConfig);
     $this->config->theme('blue');
     $this->config->cachePath('css', TMP);
     $this->cache = new AssetCache($this->config);
     $result = $this->cache->buildFileName('themed.css');
     $this->assertEqual('blue-themed.css', $result);
 }
 function testExceptionOnBogusFile()
 {
     try {
         $config = AssetConfig::buildFromIniFile('/bogus');
         $this->assertFalse(true, 'Exception not thrown.');
     } catch (Exception $e) {
         $this->assertEqual('Configuration file "/bogus" was not found.', $e->getMessage());
     }
 }
 function setUp()
 {
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $testFile = $this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'config' . DS . 'config.ini';
     AssetConfig::clearAllCachedKeys();
     $this->config = AssetConfig::buildFromIniFile($testFile);
     $this->config->paths('js', array($this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'js' . DS, $this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'js' . DS . '*'));
     $this->config->paths('css', array($this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'css' . DS, $this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'css' . DS . '*'));
     $this->Compiler = new AssetCompiler($this->config);
 }
Beispiel #10
0
 /**
  * Create the configuration object used in other classes.
  *
  */
 public function startup()
 {
     parent::startup();
     $config = null;
     if (isset($this->params['config'])) {
         $config = $this->params['config'];
     }
     AssetConfig::clearAllCachedKeys();
     $this->_Config = AssetConfig::buildFromIniFile($config);
 }
 /**
  * start a test
  *
  * @return void
  **/
 function startTest()
 {
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $testFile = $this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'config' . DS . 'config.ini';
     AssetConfig::clearAllCachedKeys();
     $this->Helper = new AssetCompressHelper(array('noconfig' => true));
     $Config = AssetConfig::buildFromIniFile($testFile);
     $this->Helper->config($Config);
     $this->Helper->Html = new HtmlHelper();
     Router::reload();
     Configure::write('debug', 2);
 }
 public function setUp()
 {
     parent::setUp();
     $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
     $in = $this->getMock('ConsoleInput', array(), array(), '', false);
     $this->Task = $this->getMock('AssetBuildTask', array('in', 'err', 'createFile', '_stop', 'clear'), array($out, $out, $in));
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $this->testFilePath = $this->_pluginPath . 'Test/test_files/View/Parse/';
     $this->testConfig = $this->_pluginPath . 'Test' . DS . 'test_files' . DS . 'Config' . DS . 'config.ini';
     AssetConfig::clearAllCachedKeys();
     $this->config = AssetConfig::buildFromIniFile($this->testConfig);
     $this->Task->setConfig($this->config);
 }
 function setUp()
 {
     parent::setUp();
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $this->testConfig = $this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'config' . DS . 'integration.ini';
     $map = array('TEST_FILES/' => $this->_pluginPath . 'tests' . DS . 'test_files' . DS);
     AssetConfig::clearAllCachedKeys();
     $config = AssetConfig::buildFromIniFile($this->testConfig, $map);
     $config->filters('js', null, array());
     $this->Controller = new TestAssetsController();
     $this->Controller->constructClasses();
     $this->Controller->_Config = $config;
     $this->_debug = Configure::read('debug');
 }
 public function setUp()
 {
     parent::setUp();
     Cache::drop(AssetConfig::CACHE_CONFIG);
     Cache::config(AssetConfig::CACHE_CONFIG, array('engine' => 'File'));
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $this->_testFiles = App::pluginPath('AssetCompress') . 'Test' . DS . 'test_files' . DS;
     $this->testConfig = $this->_testFiles . 'Config' . DS . 'config.ini';
     $this->_themeConfig = $this->_testFiles . 'Config' . DS . 'themed.ini';
     App::build(array('Plugin' => array($this->_testFiles . 'Plugin' . DS)));
     CakePlugin::load('TestAssetIni');
     AssetConfig::clearAllCachedKeys();
     $this->config = AssetConfig::buildFromIniFile($this->testConfig);
 }
 function setUp()
 {
     parent::setUp();
     $this->Dispatcher =& new TestAssetBuildTaskMockShellDispatcher();
     $this->Task =& new MockAssetBuildTask($this->Dispatcher);
     $this->Task->Dispatch =& $this->Dispatcher;
     $this->Task->Dispatch->shellPaths = App::path('shells');
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $this->testFilePath = $this->_pluginPath . 'tests/test_files/views/';
     $this->testConfig = $this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'config' . DS . 'config.ini';
     AssetConfig::clearAllCachedKeys();
     $this->config = AssetConfig::buildFromIniFile($this->testConfig);
     $this->Task->setConfig($this->config);
 }
 function setUp()
 {
     parent::setUp();
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $this->testConfig = $this->_pluginPath . 'Test' . DS . 'test_files' . DS . 'Config' . DS . 'integration.ini';
     $map = array('TEST_FILES/' => $this->_pluginPath . 'Test' . DS . 'test_files' . DS);
     AssetConfig::clearAllCachedKeys();
     $config = AssetConfig::buildFromIniFile($this->testConfig, $map);
     $config->filters('js', null, array());
     $this->Controller = $this->getMock('AssetsController', array('render'), array(new CakeRequest(null, false), new CakeResponse()));
     $this->Controller->constructClasses();
     $this->Controller->response = $this->getMock('CakeResponse');
     $this->Controller->_Config = $config;
     $this->_debug = Configure::read('debug');
 }
    function testCombineThemeFileWithNonTheme()
    {
        App::build(array('views' => array($this->_testFiles . 'views' . DS)));
        $Config = AssetConfig::buildFromIniFile($this->_themeConfig);
        $Config->paths('css', array($this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'css' . DS . '**'));
        $Config->theme('red');
        $Compiler = new AssetCompiler($Config);
        $result = $Compiler->generate('combined.css');
        $expected = <<<TEXT
@import url("reset/reset.css");
#nav {
\twidth:100%;
}body {
\tcolor: red !important;
}
TEXT;
        $this->assertEqual($result, $expected);
    }
 /**
  * start a test
  *
  * @return void
  **/
 function setUp()
 {
     parent::setUp();
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $testFile = $this->_pluginPath . 'Test' . DS . 'test_files' . DS . 'Config' . DS . 'config.ini';
     AssetConfig::clearAllCachedKeys();
     Cache::drop(AssetConfig::CACHE_CONFIG);
     Cache::config(AssetConfig::CACHE_CONFIG, array('path' => TMP, 'prefix' => 'asset_compress_test_', 'engine' => 'File'));
     $controller = null;
     $request = new CakeRequest(null, false);
     $request->webroot = '';
     $view = new View($controller);
     $view->request = $request;
     $this->Helper = new AssetCompressHelper($view, array('noconfig' => true));
     $Config = AssetConfig::buildFromIniFile($testFile);
     $this->Helper->config($Config);
     $this->Helper->Html = new HtmlHelper($view);
     Router::reload();
     Configure::write('debug', 2);
 }
	public function testRawAssetsPlugin() {
		App::build(array(
			'Plugin' => array($this->_testFiles . 'Plugin' . DS)
		));
		CakePlugin::load('TestAsset');
		$config = AssetConfig::buildFromIniFile($this->_testFiles . 'Config/plugins.ini');
		$this->Helper->config($config);

		$result = $this->Helper->css('plugins.css', array('raw' => true));
		$expected = array(
			array(
				'link' => array(
					'type' => 'text/css',
					'rel' => 'stylesheet',
					'href' => 'css/nav.css'
				)
			),
			array(
				'link' => array(
					'type' => 'text/css',
					'rel' => 'stylesheet',
					'href' => '/test_asset/plugin.css'
				)
			),
		);
		$this->assertTags($result, $expected);
	}
    function testCompilePluginFiles()
    {
        App::build(array('Plugin' => array($this->_testFiles . 'Plugin' . DS)));
        CakePlugin::load('TestAsset');
        $Config = AssetConfig::buildFromIniFile($this->_pluginConfig);
        $Config->paths('css', array($this->_pluginPath . 'Test' . DS . 'test_files' . DS . 'css' . DS . '**'));
        $Compiler = new AssetCompiler($Config);
        $result = $Compiler->generate('plugins.css');
        $expected = <<<TEXT
@import url("reset/reset.css");
#nav {
\twidth:100%;
}.plugin-box {
\tcolor: orange;
}
TEXT;
        $this->assertEqual($result, $expected);
    }
 public function testCompileRemoteFiles()
 {
     $Config = AssetConfig::buildFromIniFile($this->_testFiles . 'Config' . DS . 'remote_file.ini');
     $Compiler = new AssetCompiler($Config);
     $result = $Compiler->generate('remote_file.js');
     $this->assertContains('jQuery', $result);
 }
 public function testIsThemed()
 {
     $this->assertFalse($this->config->isThemed('libs.js'));
     $config = AssetConfig::buildFromIniFile($this->_themeConfig);
     $this->assertTrue($config->isThemed('themed.css'));
 }