Skip to content

Commit

Permalink
Merge pull request #22 from tedivm/testing
Browse files Browse the repository at this point in the history
Refactoring the Test Suite
  • Loading branch information
tedivm committed Jan 14, 2014
2 parents 86cd69c + ac6d652 commit 4b48e3d
Show file tree
Hide file tree
Showing 40 changed files with 121 additions and 85 deletions.
12 changes: 9 additions & 3 deletions .travis.yml
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
15 changes: 15 additions & 0 deletions phpunit.xml.dist
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>
82 changes: 0 additions & 82 deletions tests/JShrink.php

This file was deleted.

69 changes: 69 additions & 0 deletions tests/JShrink/Test/JShrinkTest.php
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.
28 changes: 28 additions & 0 deletions tests/bootstrap.php
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__);

0 comments on commit 4b48e3d

Please sign in to comment.