Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Commit

Permalink
Remove some duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Feb 7, 2016
1 parent f0491ba commit cc5cab9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 50 deletions.
29 changes: 8 additions & 21 deletions tasks/phpspec.js
Expand Up @@ -2,11 +2,12 @@ var gulp = require('gulp');
var Elixir = require('laravel-elixir');

var config = Elixir.config;
var notify = new Elixir.Notification();
var runTests = require('./shared/Tests.js');


/*
|----------------------------------------------------------------
| PHPUnit Testing
| PHPSpec Testing
|----------------------------------------------------------------
|
| This task will trigger your entire PHPUnit test suite and it
Expand All @@ -16,24 +17,10 @@ var notify = new Elixir.Notification();
*/

Elixir.extend('phpSpec', function(src, command) {
src = src || (config.testing.phpSpec.path + '/**/*Spec.php'),
command = command || 'vendor/bin/phpspec run';

new Elixir.Task('phpSpec', function(error) {
Elixir.Log.heading('Triggering PHPSpec: ' + command);

return (
gulp
.src('')
.pipe(Elixir.Plugins.shell(command))
.on('error', function(e) {
notify.forFailedTests(e, 'PHPSpec');

this.emit('end');
})
.pipe(notify.forPassedTests('PHPSpec'))
);
})
.watch(src);
runTests(
'PHPSpec',
src || (config.testing.phpSpec.path + '/**/*Spec.php'),
command || 'vendor/bin/phpspec run'
);
});

27 changes: 7 additions & 20 deletions tasks/phpunit.js
Expand Up @@ -2,7 +2,8 @@ var gulp = require('gulp');
var Elixir = require('laravel-elixir');

var config = Elixir.config;
var notify = new Elixir.Notification();
var runTests = require('./shared/Tests.js');


/*
|----------------------------------------------------------------
Expand All @@ -16,24 +17,10 @@ var notify = new Elixir.Notification();
*/

Elixir.extend('phpUnit', function(src, command) {
src = src || (config.testing.phpUnit.path + '/**/*Test.php');
command = command || 'vendor/bin/phpunit --verbose';

new Elixir.Task('phpUnit', function(error) {
Elixir.Log.heading('Triggering PHPUnit: ' + command);

return (
gulp
.src('')
.pipe(Elixir.Plugins.shell(command))
.on('error', function(e) {
notify.forFailedTests(e, 'PHPUnit');

this.emit('end');
})
.pipe(notify.forPassedTests('PHPUnit'))
);
})
.watch(src);
runTests(
'PHPUnit',
src || (config.testing.phpUnit.path + '/**/*Test.php'),
command || 'vendor/bin/phpunit --verbose'
);
});

19 changes: 10 additions & 9 deletions tasks/shared/Tests.js
Expand Up @@ -3,23 +3,24 @@ var Elixir = require('../../index');

var notify = new Elixir.Notification();

module.exports = function(options) {
new Elixir.Task(options.name, function() {
this.log(options.src);
module.exports = function(name, src, command) {
new Elixir.Task(name, function(error) {
Elixir.Log.heading('Triggering ' + name + ': ' + command);

return (
gulp
.src(options.src)
.pipe(options.plugin('', options.pluginOptions))
.src('')
.pipe(Elixir.Plugins.shell(command))
.on('error', function(e) {
notify.forFailedTests(e, options.name);
notify.forFailedTests(e, name);

this.emit('end');
})
.pipe(notify.forPassedTests(options.name))
.pipe(notify.forPassedTests(name))
);
})
.watch(options.src, 'tdd')
.watch(src)
.watch(Elixir.config.appPath + '/**/*.php', 'tdd')
.watch(Elixir.config.viewPath +'/**/*.php', 'tdd')
.watch(Elixir.config.viewPath +'/**/*.php', 'tdd');
};

0 comments on commit cc5cab9

Please sign in to comment.