Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Coding Style Testing #26

Merged
merged 5 commits into from

1 participant

@tedivm
Owner

Added coding style tests using the "php-cs-fixer" tool. Simply run the "test/runTests.php" script from the project root and it'll run both the phpunit tests and let you know if you need to make any formatting changes. before your code will be accepted back into JShrink's mainline.

@tedivm tedivm merged commit d923875 into master

1 check passed

Details default The Travis CI build passed
@tedivm tedivm deleted the cs_testing branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
3  .travis.yml
@@ -8,4 +8,5 @@ php:
before_script: composer install --dev
-script: phpunit --verbose --coverage-text
+script:
+ - ./tests/runTests.sh
View
3  composer.json
@@ -14,6 +14,9 @@
"require": {
"php": ">=5.3.0"
},
+ "require-dev": {
+ "fabpot/php-cs-fixer": "0.4.0"
+ },
"autoload": {
"psr-0": {"JShrink": "src/"}
}
View
9 src/JShrink/Minifier.php
@@ -103,7 +103,7 @@ public static function minify($js, $options = array())
} catch (\Exception $e) {
- if(isset($jshrink)){
+ if (isset($jshrink)) {
// Since the breakdownScript function probably wasn't finished
// we clean it out before discarding it.
$jshrink->clean();
@@ -252,6 +252,7 @@ protected function getChar()
// Normalize all whitespace except for the newline character into a
// standard space.
if($char !== "\n" && ord($char) < 32)
+
return ' ';
return $char;
@@ -264,7 +265,7 @@ protected function getChar()
* c code) rather than in script php.
*
* @throws \RuntimeException
- * @return string Next 'real' character to be processed.
+ * @return string Next 'real' character to be processed.
*/
protected function getReal()
{
@@ -351,6 +352,7 @@ protected function getNext($string)
// If it's not there return false.
if($pos === false)
+
return false;
// Adjust position of index to jump ahead to the asked for string
@@ -378,7 +380,6 @@ protected function saveString()
return;
}
-
// String type is the quote used, " or '
$stringType = $this->a;
@@ -420,7 +421,7 @@ protected function saveString()
$this->b = $this->getChar();
// If b is a new line we discard a and b and restart the loop.
- if($this->b == "\n") {
+ if ($this->b == "\n") {
break;
}
View
4 tests/JShrink/Test/JShrinkTest.php
@@ -33,7 +33,6 @@ public function testUnclosedStringException()
\JShrink\Minifier::minify('var string = "This string is hanging out.');
}
-
/**
* @expectedException RuntimeException
* @expectedExceptionMessage Unclosed regex pattern at position: 23
@@ -44,7 +43,6 @@ public function testUnclosedRegexException()
var string = "Another Filler"');
}
-
/**
* @dataProvider JShrinkProvider
*/
@@ -61,7 +59,6 @@ public function testUglify($testName, $input, $output)
$this->assertEquals($output, \JShrink\Minifier::minify($input), 'Running Uglify Test: ' . $testName);
}
-
/**
* @group requests
* @dataProvider requestProvider
@@ -71,7 +68,6 @@ public function testRequest($testName, $input, $output)
$this->assertEquals($output, \JShrink\Minifier::minify($input), 'Running Uglify Test: ' . $testName);
}
-
/**
* This function loads all of the test cases from the specified group.
* Groups are created simply by populating the appropriate directories:
View
12 tests/runTests.sh
@@ -0,0 +1,12 @@
+#/usr/bin/env/sh
+set -e
+
+echo 'Running unit tests.'
+phpunit --verbose --coverage-text
+
+echo ''
+echo ''
+echo ''
+echo 'Testing for Coding Styling Compliance.'
+echo 'All code should follow PSR standards.'
+./vendor/fabpot/php-cs-fixer/php-cs-fixer fix ./ --dry-run --level="all" -vv
Something went wrong with that request. Please try again.