Skip to content

Instantly share code, notes, and snippets.

@nickclasener
Last active September 30, 2019 20:27
Show Gist options
  • Save nickclasener/19a029015ba27d23aef93c4d9e7bd134 to your computer and use it in GitHub Desktop.
Save nickclasener/19a029015ba27d23aef93c4d9e7bd134 to your computer and use it in GitHub Desktop.
Adds Godlike quake sound after tests passed.
<!-- Location vendor/spatie/phpunit-watcher/src/Notification.php -->
<?php
namespace Spatie\PhpUnitWatcher;
use Joli\JoliNotif\NotifierFactory;
use Joli\JoliNotif\Notification as JoliNotification;
class Notification
{
/** @var \Joli\JoliNotif\Notification */
protected $joliNotification;
public static function create()
{
$joliNotification = (new JoliNotification)
->setTitle('PHPUnit Watcher')
->setIcon(__DIR__.'/../images/notificationIcon.png');
return new static($joliNotification);
}
protected function __construct(JoliNotification $joliNotification)
{
$this->joliNotification = $joliNotification;
}
public function passingTests()
{
$this->joliNotification->setBody('✅ Tests passed!');
$this->send();
shell_exec('play ~/Music/godlike.mp3 -q </dev/null &>/dev/null &');
}
public function failingTests()
{
$this->joliNotification->setBody('❌ Tests failed!');
$this->send();
}
protected function send()
{
return NotifierFactory::create()->send($this->joliNotification);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment