Skip to content

Instantly share code, notes, and snippets.

@cognifloyd
Last active August 29, 2015 14:03
Show Gist options
  • Save cognifloyd/cfc8ba37dd7c711342f1 to your computer and use it in GitHub Desktop.
Save cognifloyd/cfc8ba37dd7c711342f1 to your computer and use it in GitHub Desktop.
Guard + Guard-PhpUnit2 + TYPO3.Flow based application
# http://erichogue.ca/2012/09/php/continuous-testing-in-php-with-guard/
#Unit Tests
guard 'phpunit2',
:command => './bin/phpunit',
:cli => '-c Build/BuildEssentials/PhpUnit/UnitTests.xml',
#Important! No trailing slash!
:tests_path => Dir.glob('Packages/{Framework,Applications,Boilerplates}/*/Tests/Unit'),
#realtime uses log-json which emits tons of Notices about "Array to string conversion" when testing TYPO3.Eel/Context
:realtime => true,
:keep_failed => true,
:all_on_start => true,
:all_after_pass => true do
#Tests
watch(%r{^Packages/(Framework|Applications|Boilerplates)/(.+)/Tests/Unit/(.+)Test\.php$})
#PSR-0 Classes
watch(%r{^Packages/(Framework|Applications|Boilerplates)/(.+)/Classes/([^/]+)/([^/]+)/(.+)\.php$}) { |m| "Packages/#{m[1]}/#{m[2]}/Tests/Unit/#{m[5]}Test.php" }
#PSR-4 Classes
watch(%r{^Packages/(Framework|Applications|Boilerplates)/(.+)/Classes/(.+)\.php$}) { |m| "Packages/#{m[1]}/#{m[2]}/Tests/Unit/#{m[3]}Test.php" }
end
#Functional Tests
guard 'phpunit2',
:command => './bin/phpunit',
:cli => '-c Build/BuildEssentials/PhpUnit/FunctionalTests.xml',
:tests_path => Dir.glob('Packages/{Framework,Applications,Boilerplates}/*/Tests/Functional'),
:realtime => true,
:keep_failed => true,
:all_on_start => true,
:all_after_pass => true do
watch(%r{^Packages/(Framework|Applications|Boilerplates)/(.+)/Tests/Functional/(.+)Test\.php$})
end
#Behat Tests
# See http://erichogue.ca/2012/09/php/continuous-testing-in-php-with-guard/ Inline Guard
#Documentation Generation?
@cognifloyd
Copy link
Author

Place this at ~/.Guardfile or at <projectRoot>/Guardfile. Then, open a new terminal that you can leave open during development. In the flow distribution (same directory as ./flow), run guard. Enjoy your growl or inotify notifications.

@cognifloyd
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment