Last active
December 20, 2015 23:48
-
-
Save twmbx/e36affb956420ba8d582 to your computer and use it in GitHub Desktop.
Robo PHP: PHPunit & PHPspec with notifications
This file contains hidden or 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
<?php | |
/** | |
* @Author Twaambo Haamucenje | |
* @Email [email protected] | |
* | |
* better phpunit and phpspec tests with linux desktop notifications using Robo PHP | |
* | |
* @see http://robo.li/ | |
*/ | |
class RoboFile extends \Robo\Tasks | |
{ | |
// define public methods as commands | |
private $paths = ['app', 'config', 'tests']; | |
public function tdd(){ | |
$this->taskWatch()->monitor( $paths, function(){ | |
$this->test(); | |
})->run(); | |
} | |
public function test(){ | |
if( $this->taskPHPUnit()->run()->wasSuccessful() ){ | |
$this->notify( 'pass', 'phpunit' ); | |
} else { | |
$this->notify( 'fail', 'phpunit' ); | |
} | |
if( $this->taskPhpspec() | |
->format('pretty') | |
->noInteraction() | |
->run() | |
->wasSuccessful() ){ | |
$this->notify( 'pass', 'phpspec' ); | |
} else { | |
$this->notify( 'fail', 'phpspec' ); | |
} | |
} | |
public function notify( $status, $test ){ | |
$icon = ( $status == 'pass' ) ? '~/bin/icons/pass.png' : '~/bin/icons/fail.png'; | |
$title = ( $test == 'phpunit' ) ? 'PHP Unit' : 'PHP Spec'; | |
$message = ( $status == 'pass' ) ? 'Tests Passed!' : 'Tests Failed!!'; | |
$notification = "notify-send '".$title."' '".$message."' -i '".$icon."'"; | |
$this->_exec( $notification ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment