-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from tedivm/testing
Refactoring the Test Suite
- Loading branch information
Showing
40 changed files
with
121 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
language: php | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
script: phpunit tests/* | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
- hhvm | ||
|
||
before_script: composer install --dev | ||
|
||
script: phpunit --verbose --coverage-text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit bootstrap="./tests/bootstrap.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="JShrink Test Suite"> | ||
<directory suffix="Test.php">./tests/JShrink/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">./src/JShrink/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the JShrink package. | ||
* | ||
* (c) Robert Hafner <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace JShrink\Test; | ||
|
||
use JShrink\Minifier; | ||
|
||
|
||
class JShrinkTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @dataProvider JShrinkProvider | ||
*/ | ||
public function testJShrink($testName, $unminified, $minified) { | ||
$this->assertEquals(\JShrink\Minifier::minify($unminified), $minified, 'Running JShrink Test: ' . $testName); | ||
} | ||
|
||
/** | ||
* @dataProvider uglifyProvider | ||
*/ | ||
public function testUglify($testName, $unminified, $minified) { | ||
$this->assertEquals(\JShrink\Minifier::minify($unminified), $minified, 'Running Uglify Test: ' . $testName); | ||
} | ||
|
||
|
||
public function getExampleFiles($group) | ||
{ | ||
$baseDir = __DIR__ . '/../../Resources/' . $group . '/'; | ||
$testDir = $baseDir . 'test/'; | ||
$expectDir = $baseDir . 'expect/'; | ||
|
||
$returnData = array(); | ||
|
||
|
||
$testFiles = scandir($testDir); | ||
foreach($testFiles as $testFile) | ||
{ | ||
if(!file_exists(($expectDir . $testFile))) | ||
continue; | ||
|
||
$testContents = file_get_contents($testDir . $testFile); | ||
$testResults = file_get_contents($expectDir . $testFile); | ||
|
||
$returnData[] = array($testFile, $testContents, $testResults); | ||
} | ||
|
||
return $returnData; | ||
} | ||
|
||
|
||
public function uglifyProvider() { | ||
return $this->getExampleFiles('uglify'); | ||
} | ||
|
||
public function JShrinkProvider() { | ||
return $this->getExampleFiles('jshrink'); | ||
} | ||
|
||
|
||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the JShrink package. | ||
* | ||
* (c) Robert Hafner <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
define('TESTING', true);// | ||
error_reporting(-1); | ||
|
||
date_default_timezone_set('UTC'); | ||
|
||
$filename = __DIR__ .'/../vendor/autoload.php'; | ||
|
||
if (!file_exists($filename)) { | ||
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" . PHP_EOL; | ||
echo " You need to execute `composer install` before running the tests. " . PHP_EOL; | ||
echo " Vendors are required for complete test execution. " . PHP_EOL; | ||
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" . PHP_EOL . PHP_EOL; | ||
$filename = __DIR__ .'/../autoload.php'; | ||
} | ||
|
||
$loader = require $filename; | ||
$loader->add('JShrink\\Test', __DIR__); |