Skip to content

Commit d85db02

Browse files
author
Phil Sturgeon
committed
Added some notes on Testing. These are by no means extensive or complete.
1 parent dcde093 commit d85db02

4 files changed

+51
-9
lines changed

_posts/01-04-01-Mac-Setup.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ isChild: true
44

55
## Mac Setup
66

7-
OS X comes prepackaged with PHP. As of Mountain Lion, it is _not_ the current stable version of PHP, though.
8-
You can get the PHP executable through a number of Mac [package managers][mac-package-managers] or [compile it yourself][mac-compile] (if compiling, be sure to have Xcode installed, or Apple's substitute ["Command Line Tools for Xcode" downloadable from Apple's Mac Developer Center][apple-developer]).
9-
For a complete LAMP package with GUI try [MAMP2][mamp-downloads], otherwise consider [Entropy 5.4 package][entropy-downloads].
7+
OSX comes prepackaged with PHP but it is normally a little behind the latest stable. Lion comes with PHP 5.3.6 and Mountain Lion has 5.3.10.
8+
9+
To update PHP on OSX you can get the PHP executable through a number of Mac [package managers][mac-package-managers] or [compile it yourself][mac-compile] (if compiling, be sure to have installed either Xcode or Apple's substitute ["Command Line Tools for Xcode" downloadable from Apple's Mac Developer Center][apple-developer]).
10+
11+
For a complete LAMP package with GUI try [MAMP][mamp-downloads], otherwise consider the [Entropy 5.4][entropy-downloads] package.
1012

1113
[mac-package-managers]: http://www.php.net/manual/en/install.macosx.packages.php
1214
[mac-compile]: http://www.php.net/manual/en/install.macosx.compile.php

_posts/07-01-01-Testing.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
Writing automated tests for your PHP code is considered a best practice and can lead to well-built
44
applications. Automated tests are a great tool for making sure your application
5-
does not break when you are making changes or adding new functionality.
5+
does not break when you are making changes or adding new functionality and should not be ignored.
66

7-
Some common tools are:
8-
9-
* [PHPUnit](http://phpunit.de)
10-
* [Behat](http://behat.org)
11-
* [Selenium](http://seleniumhq.org/)
7+
There are several different types of testing tools (or frameworks) available for PHP, which use
8+
different approaches - all of which are trying to avoid manual testing and the need for large
9+
Quality Assurance teams, just to make sure recent changes didn't break existing functionality.
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
isChild: true
3+
---
4+
5+
## Test Driven Development
6+
7+
Unit Testing is a programatical approach to ensure functions, classes and methods are working as
8+
expected, from the point you build them all the way through to the development cycle. By checking
9+
values going in and out of various functions and methods, you can make sure the internal logic is
10+
working correctly. By using Dependecy Injection and building "mock" classes you can check internal
11+
parameter values for even better test coverage.
12+
13+
When you create a class or function you should create a unit test for it. At a very basic level you should
14+
make sure it errors if you send it bad arguments and make sure it works if you send it valid arguments.
15+
This will help ensure that when you make changes to this class or function later on in the development
16+
cycle that the old functionality continues to work as expected. The only alternative to this would be
17+
var_dump() in a test.php, which is no way to build an application - large or small.
18+
19+
The other use for unit tests is contributing to open source. If you can write a test that shows broken
20+
functionality, then fix it, and show the test working, patches are much more likely to be accepted. If
21+
you run a project who accepts pull requests, you should suggest this as a requirement for pull requests.
22+
23+
PHPUnit is the most popular and has become a de facto standard with its popular adoption amongst [PHP
24+
frameworks][phpfws] and [Composer][composer] component developers, but there are a few alternatives around.
25+
26+
* [PHPUnit](http://phpunit.de/)
27+
* [Enhance PHP](http://www.enhance-php.com/)
28+
* [PUnit](http://punit.smf.me.uk/)
29+
30+
[phpfws]: /#libraries_and_frameworks
31+
[composer]: /#composer_and_packagist
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
isChild: true
3+
---
4+
5+
## Behaviour Driven Development
6+
7+
With BDD, you write human-readable stories that describe the behavior of your application. These stories
8+
can then be run as actual tests against your application.
9+
10+
* [Behat](http://behat.org/) is inspired by Ruby's [Cucumber](http://cukes.info/) project
11+
* [Selenium](http://seleniumhq.org/) is a browser automation tool, which automates the "clicking around the site" method of testing. It can also be [combined with PHPUnit](http://www.phpunit.de/manual/3.1/en/selenium.html)

0 commit comments

Comments
 (0)