-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
James Cryer
committed
Feb 24, 2013
1 parent
bd1686f
commit fe58a02
Showing
4 changed files
with
170 additions
and
81 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
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,47 @@ | ||
<?php | ||
/** | ||
* Sample class for tests of grunt-phpcs runner | ||
* | ||
* @package Grunt\PhpCs | ||
*/ | ||
namespace Grunt\PhpCs; | ||
|
||
class World | ||
{ | ||
|
||
/** | ||
* | ||
* @var string | ||
*/ | ||
private $name = ''; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param string $name | ||
*/ | ||
public function __construct($name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
/** | ||
* Sets the world's name | ||
* | ||
* @param string $name | ||
*/ | ||
public function setName($name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
/** | ||
* Returns world's name | ||
* | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
} |
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,110 @@ | ||
/* | ||
* grunt-phpunit | ||
* https://github.com/SaschaGalley/grunt-phpunit | ||
* | ||
* Copyright (c) 2013 Sascha Galley | ||
* http://xash.at | ||
* Licensed under the MIT license. | ||
*/ | ||
'use strict'; | ||
|
||
// External libs. | ||
var path = require('path'); | ||
var exec = require('child_process').exec; | ||
|
||
exports.init = function(grunt) { | ||
|
||
var exports = {}, | ||
defaults = { | ||
// Default options | ||
bin: 'phpcs', | ||
debug: false, | ||
extensions: false, | ||
ignore: false, | ||
severity: false, | ||
standard: false, | ||
verbose: false | ||
}, | ||
cmd = null, | ||
done = null, | ||
config = {}; | ||
|
||
/** | ||
* Builds phpunit command | ||
* | ||
* @return string | ||
*/ | ||
var buildCommand = function(dir) { | ||
|
||
var cmd = path.normalize(config.bin); | ||
|
||
if (grunt.option('debug') || config.debug === true) { | ||
// Display debbuging information during test execution. | ||
cmd += ' --debug'; | ||
} | ||
|
||
if (grunt.option('extensions') || config.extensions) { | ||
// A comma separated list of file extensions to check | ||
cmd += ' --extensions=' + config.extensions; | ||
} | ||
|
||
if (grunt.option('ignore') || config.ignore) { | ||
// A comma separated list of patterns to ignore files and directories. | ||
cmd += ' --ignore=' + config.ignore; | ||
} | ||
|
||
if (grunt.option('severity') || config.severity) { | ||
// The minimum severity required to display an error or warning | ||
cmd += ' --severity=' + config.severity; | ||
} | ||
|
||
if (grunt.option('verbose') || config.standard) { | ||
// Define the code sniffer standard. | ||
cmd += ' --standard=' + config.standard; | ||
} | ||
|
||
if (grunt.option('verbose') || config.verbose === true) { | ||
// Output more verbose information. | ||
cmd += ' -v'; | ||
} | ||
return cmd; | ||
}; | ||
|
||
/** | ||
* Setup task before running it | ||
* | ||
* @param Object runner | ||
*/ | ||
exports.setup = function(runner) { | ||
|
||
var dir = path.normalize(runner.data.dir); | ||
config = runner.options(defaults); | ||
cmd = buildCommand(dir) + ' ' + dir; | ||
|
||
grunt.log.writeln('Starting phpcs (target: ' + runner.target.cyan + ') in ' + dir.cyan); | ||
grunt.verbose.writeln('Exec: ' + cmd); | ||
|
||
done = runner.async(); | ||
}; | ||
|
||
/** | ||
* Runs phpunit command with options | ||
* | ||
*/ | ||
exports.run = function() { | ||
|
||
exec(cmd, function(err, stdout, stderr) { | ||
|
||
if (stdout) { | ||
grunt.log.write(stdout); | ||
} | ||
|
||
if (err) { | ||
grunt.fatal(err); | ||
} | ||
done(); | ||
}); | ||
}; | ||
|
||
return exports; | ||
}; |
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