Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Minify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions tests/js/JSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down