Over a million developers have joined DZone.

Running VisualPHPUnit in Windows Azure

· Cloud Zone

Build fast, scale big with MongoDB Atlas, a hosted service for the leading NoSQL database on AWS. Try it now! Brought to you in partnership with MongoDB.

Last month, I wrote a post that outlined 3 ways to test PHP applications in Windows Azure, and since then I’ve covered two of those approaches: Running PHPUnit in Windows Azure (uses RDP) and Automating PHPUnit Tests in Windows Azure. In this post I’ll cover how to use a web-front end (VisualPHPUnit specifically) to run tests in Azure.

If you have PHPUnit installed locally (and I’m assuming you have it installed as a PEAR package), then running VisualPHPUnit locally is a breeze – simply follow the directions in the README:       

1.Download and extract the project to a web-accessible directory.
2. Open config.php with your favorite editor.
    1.Change PEAR_PATH so that it points to the directory where PEAR is located.
    2.Update TEST_DIRECTORY so that it points to the root directory where your tests are stored.
3.Point your browser to the location where you installed VisualPHPUnit!

Note: I put VisualPHPUnit in my application root directory, which seemed to cause one problem: My tests are in the ‘tests” directory (which is in my application root). Each test has a require_once “.\ClassName.php” statement (as required by PHPUnit). However, when I browse to the VisualPHPUnit directory, the working directory is one directory “down”. So, I needed to change the require statements to require_once “..\ClassName.php” in order for the referenced files to be found. This is unfortunate if you have lots of tests, but I haven’t found a workaround yet (I’m certainly open to suggestions).

Once VisualPHPUnit is installed, continue developing/testing your application locally. When all your tests are passing and you are ready to move your application to Windows Azure, you’ll need to make two changes to the VisualPHPUnit configuration. Here’s what you need to do:

1. Edit VisualPHPUnit config.php file like so:

// The directory where PEAR is located
define('PEAR_PATH', dirname(getcwd()).'\bin\PHP\PEAR');

// The directory where the tests reside
define('TEST_DIRECTORY', dirname(getcwd()).'\tests');

Note: This assumes your tests directory is in your application root directory.

2. (Optional, but suggested): Password protect the VisualPHPUnit directory. Instructions for doing this are in this post: How to Password Protect a PHP Website Directory in Windows Azure.

3. Follow the steps for packaging and deploying a custom PHP installation in this post: Packaging a Custom PHP Installation for Windows Azure.

After you have deployed your app, you should be able to browse to the VisualPHPUnit directory, select and run your tests, and see the results:

image

That’s it!

Hope that’s helpful.

-Brian

 

Source: http://blogs.msdn.com/b/silverlining/archive/2012/01/10/running-visualphpunit-in-windows-azure.aspx

Now it's easier than ever to get started with MongoDB, the database that allows startups and enterprises alike to rapidly build planet-scale apps. Introducing MongoDB Atlas, the official hosted service for the database on AWS. Try it now! Brought to you in partnership with MongoDB.

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}