diff --git a/src/Minify.php b/src/Minify.php index 736ff11..8031806 100644 --- a/src/Minify.php +++ b/src/Minify.php @@ -137,7 +137,21 @@ public function addFile($data /* $data = null, ... */) return $this; } - /** + /** + * Add data with path and content without doing any check. + * + * @param string $path File path to be minified. + * @param string $content Content to be minified. + * + * @return static + */ + public function addData( $path, $content ) { + $this->data[ $path ] = $content; + + return $this; + } + + /** * Minify the data & (optionally) saves it to a file. * * @param string[optional] $path Path to write the data to diff --git a/tests/js/JSTest.php b/tests/js/JSTest.php index db43308..c58fbaa 100644 --- a/tests/js/JSTest.php +++ b/tests/js/JSTest.php @@ -41,6 +41,19 @@ public function testAddFile() $this->assertEquals('var test=1', $result); } + /** + * Test minifier addFile method. + */ + public function testAddData() + { + $minifier = $this->mockMinifier(); + $minifier->addData(__DIR__.'/sample/source/script1.js', 'var test_from_addData=1'); + + $result = $minifier->minify(); + + $this->assertEquals('var test_from_addData=1', $result); + } + /** * Test JS minifier rules, provided by dataProvider. *