Skip to content
Browse files

Added tests, custom routes, and tweaked drivers

  • Loading branch information...
1 parent 3d13d14 commit bb00e0f7268780fa4b4cf51179c4ef73b2ce5503 Gabriel Evans committed Dec 8, 2010
View
27 classes/kohana/controller/kollapse.php
@@ -12,9 +12,36 @@
class Kohana_Controller_Kollapse extends Controller
{
+ /**
+ * Instantiate Kollapse.
+ */
+ public function before()
+ {
+ $kollapse = new Kollapse;
+ }
+
+ /**
+ * Build and cache all configured asset groups.
+ */
public function action_index()
{
}
+ /**
+ * Return requested scripts.
+ */
+ public function action_scripts()
+ {
+
+ }
+
+ /**
+ * Return requested styles.
+ */
+ public function action_styles()
+ {
+
+ }
+
}
View
13 classes/kohana/kollapse.php
@@ -27,7 +27,7 @@
* Stores configuration locally and instantiates compression driver.
* @return void
*/
- protected static function init(array $config = NULL)
+ protected static function init(array $config = NULL, $driver_instance = TRUE, $filter_instance = TRUE)
{
if ($config === NULL)
{
@@ -81,9 +81,16 @@ protected static function init(array $config = NULL)
/**
* Stores configuration and makes class publicly uninstantiable.
*/
- protected function __construct(array $config)
+ protected function __construct(array $config = NULL)
{
- self::$config = $config;
+ if ($config === NULL)
+ {
+ self::__construct($config, FALSE, FALSE);
+ }
+ else
+ {
+ self::$config = $config;
+ }
}
/**
View
2 classes/kohana/kollapse/filter.php
@@ -21,7 +21,7 @@
*
* @var array asset types handled
*/
- abstract public $filterable = array();
+ public $filterable = array();
/**
* Filter and return data.
View
4 classes/kohana/kollapse/minify.php
@@ -1,8 +1,8 @@
<?php defined('SYSPATH') or die('No direct script access.');
/**
- * CSSMin & JSMin driver for Krush.
+ * CSSMin & JSMin driver for Kollapse.
*
- * @package Krush
+ * @package Kollapse
* @category Driver
* @author Gabriel Evans <gabriel@codeconcoction.com>
* @copyright (c) 2010 Gabriel Evans
View
9 classes/kohana/kollapse/yui.php
@@ -1,8 +1,8 @@
<?php defined('SYSPATH') or die('No direct script access.');
/**
- * YUI Compressor driver for Krush.
+ * YUI Compressor driver for Kollapse.
*
- * @package Krush
+ * @package Kollapse
* @category Driver
* @author Gabriel Evans <gabriel@codeconcoction.com>
* @copyright (c) 2010 Gabriel Evans
@@ -41,4 +41,9 @@ protected function __construct($config)
self::$bin = $bin;
}
+ protected function optimize($data, $package, $type)
+ {
+ return $data;
+ }
+
}
View
12 init.php
@@ -0,0 +1,12 @@
+<?php defined('SYSPATH') or die('No direct script access.');
+
+Route::set('kollapse', 'kollapse')
+ ->defaults(array(
+ 'controller' => 'kollapse',
+ 'action' => 'index',
+ ));
+
+Route::set('assets', '<action>/(<group>)', array('action' => '(scripts|styles)'))
+ ->defaults(array(
+ 'controller' => 'kollapse',
+ ));
View
0 tests/krush/ConfigTest.php
No changes.
View
0 tests/krush/DriverTest.php
No changes.
View
0 tests/krush/ScriptsTest.php
No changes.
View
0 tests/krush/StylesTest.php
No changes.
View
48 tests/krush/driver/MinifyTest.php
@@ -0,0 +1,48 @@
+<?php defined('SYSPATH') OR die('Kohana bootstrap needs to be included before tests run');
+
+/**
+ * Tests Krush minify driver
+ *
+ * @group krush
+ *
+ * @package Unittest
+ * @author Gabriel Evans <gabriel@codeconcoction.com>
+ * @copyright (c) 2010 Gabriel Evans
+ * @license http://www.opensource.org/licenses/mit-license.php MIT license
+ */
+class DriverMinifyTest extends Kohana_Unittest_TestCase {
+
+ public $config = array(
+ 'driver' => 'minify',
+ );
+
+ /**
+ * @provider scripts_provider
+ */
+ public function test_script_compress($compressed, $uncompressed)
+ {
+ Krush::init($this->config);
+ $this->assertSame($compressed, Krush::compress_script($uncompressed));
+ }
+
+ /**
+ * @provider styles_provider
+ */
+ public function test_style_compress($compressed, $uncompressed)
+ {
+ Krush::init($this->config);
+ $this->assertSame($compressed, Krush::compress_style($uncompressed));
+ }
+
+ public function scripts_provider()
+ {
+
+ }
+
+ public function styles_provider()
+ {
+ return array(
+ );
+ }
+
+}
View
26 tests/krush/driver/YUITest.php
@@ -0,0 +1,26 @@
+<?php defined('SYSPATH') OR die('Kohana bootstrap needs to be included before tests run');
+
+/**
+ * Tests Krush YUI Compressor driver
+ *
+ * @group krush
+ *
+ * @package Unittest
+ * @author Gabriel Evans <gabriel@codeconcoction.com>
+ * @copyright (c) 2010 Gabriel Evans
+ * @license http://www.opensource.org/licenses/mit-license.php MIT license
+ */
+class YUITest extends Kohana_Unittest_TestCase
+{
+
+ public function test_binary_exists()
+ {
+ $this->assertFileExists(Kohana::find_file('vendor', 'yuicompressor-'.Krush_YUI::YUI_VERSION, 'jar'));
+ }
+
+ public function test_binary_executable()
+ {
+ $this->assertEquals(is_executable(Kohana::find_file('vendor', 'yuicompressor-'.Krush_YUI::YUI_VERSION, 'jar')), TRUE);
+ }
+
+}

0 comments on commit bb00e0f

Please sign in to comment.
Something went wrong with that request. Please try again.