Skip to content

Instantly share code, notes, and snippets.

@jamband
Last active April 6, 2019 08:50
Show Gist options
  • Save jamband/4554414 to your computer and use it in GitHub Desktop.
Save jamband/4554414 to your computer and use it in GitHub Desktop.
Yii + PHPUnit + watchr + terminal-notifier
watch('./(.*).php') { |m| changed(m[0]) }
def changed(file)
run "clear && cd tests && phpunit unit"
end
def run(cmd)
result = `#{cmd}`
puts result
notify result
end
def notify(result)
message = result.split("\n").last(3)
title = message.find { |e| /FAILURES/ =~ e } ? "FAILURES" : "PASS"
if title == "FAILURES"
info = /\x1b\[37;41m\x1b\[2K(.*)/.match(message[1])[1]
else
if result.index("Call Stack:")
title = "ERROR"
info = "Please check the error message ..."
else
info = /\x1b\[30;42m\x1b\[2K(.*)/.match(message[1])[1]
end
end
require 'rubygems'
require 'terminal-notifier'
TerminalNotifier.notify(info, :title => title, :group => "phpunit")
end
sudo gem install watchr
sudo gem install terminal-notifier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment