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

VG Tech:
Using PHP's Built-in Web Server in Behat Tests
Aug 19, 2013 @ 15:13:16

On the VG Tech blog there's a recent post showing you how you can use the built-in PHP web server to help with running your Behat (a behavior-driven development tool) tests.

Behat is a tool for running acceptance tests for your application. If your application is a web application you will need a web server to execute your tests. [...] Some weeks back I wrote a post showing you how to use PHP’s built in web server in PHPUnit. This post will show you how to do the same for Behat when running your acceptance tests.

His example (here on github) shows you how to set up Behat via Composer, run it and start in on your first test. In the test's "setUp" method, it calls out to the command line and starts up the built-in web server if it's not already running. It also checks to see if it can connect to the server to make sure it's accessible. Then, in the "tearDown" method, there's a call to kill off the PHP process based on the PID stored on startup.

tagged: builtin webserver bdd tests behat setup teardown

Link: http://tech.vg.no/2013/08/16/using-phps-built-in-web-server-in-behat-tests

AjaxRay.com:
Setting up Database testing with Kohana UnitTest module
Oct 12, 2010 @ 18:29:38

On the AjaxRay.com blog there's a new post showing you how to set up unit testing for your Kohana v3-based application through PHPUnit.

Kohana Unittest module has made testing in Kohana v3 easy and fun. Lysender wrote a cool, straight forward post about how to set it up and running. I’ll just talk here about how I have set up database testing with Kohana Unittest for my personal use. Not saying “How to set up”. Because it’s obviously not the best way to do this.

They walk you through the creation of the testing process - making "setup" and "tear down" SQL files, creating a "runSchema" method in a test case class and the code needed to run those setup/tear down files to refresh the database so there's no side effects of multiple tests using the same database.

tagged: kohana unittest phpunit tutorial database setup teardown

Link:

Jeff Moore's Blog:
Closures (& Lambda Functions) are coming to PHP
Mar 23, 2009 @ 16:14:18

Jeff Moore has a new post showing an example of a feature that will be included in the upcoming PHP 5.3 release - closures/lambda functions.

Dagfinn has a post looking at using the new closure feature of PHP 5.3. He compares using foreach for iteration versus array_map. "Interesting," he concludes, "but not necessarily better than conventional alternatives." I agree for that case. Consider instead, a more complicated operation that requires a setup and a tear down after.

Jeff's example proposes that, instead of duplicating code, you use a lambda function to handle the custom parsing of the data as needed and pass that into the "doIt" function in his example.

tagged: closure lambda example php5 setup teardown

Link:


Trending Topics: