News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthias Noback:
Test Symfony2 commands using the Process component and asynchronous assertions
March 24, 2014 @ 10:49:13

Matthias Noback has a new post today showing you how to test Symfony2 commands that use the Process component. More specifically, his tests revolve around the ones that use asynchronous assertions in the testing to remove weird behaviors that could be caused by multiple processes running them simultaneously.

Usually you would test a console command using the ConsoleTester class as described in the official Symfony documentation. But we can not use it in this case. We need to isolate the process in order for pcntl_fork() to work correctly, otherwise the PHPUnit test runner itself will be forked too, which will have the effect of running all the following unit tests twice (which can have very strange effects on the test results).

He shows how to use the Process component to start up a new process (the daemon) and check that the PID file exists. He includes an example of a "probe" to determine what processes are running and preventing them from stepping on each other.

0 comments voice your opinion now!
symfony2 command process component asynchronous assertion unittest phpunit

Link: http://php-and-symfony.matthiasnoback.nl/2014/03/test-symfony2-commands-using-the-process-component-and-asynchronous-assertions/

blog comments powered by Disqus

Similar Posts

Engine Yard: A Conversation About Testing in PHP

Padraic Brady's Blog: PHP Mutation Testing With MutateMe

Sasa Stamenkovic's Blog: Building CLI Apps With Symfony Console Component

Lukas Smith's Blog: Drupal using Symfony2 HttpFoundation is huge

PHP Town Hall Podcast: Episode #3 - The EE Revolt of 2012 and Why You Should Unit-test Your Shit


Community Events





Don't see your event here?
Let us know!


conference opinion threedevsandamaybe list symfony configure podcast language voicesoftheelephpant introduction laravel series api composer community unittest version release framework interview

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework