Created
June 2, 2011 16:41
-
-
Save maio/1004772 to your computer and use it in GitHub Desktop.
First Test in PHPUnit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run these commands to install PHPUnit | |
# More info @ http://www.phpunit.de/manual/current/en/installation.html | |
pear channel-discover pear.phpunit.de | |
pear channel-discover components.ez.no | |
pear channel-discover pear.symfony-project.com | |
pear install phpunit/PHPUnit | |
# OSX - you may need to upgrade pear before installing PHPUnit | |
sudo pear upgrade pear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
class MyClassTest extends PHPUnit_Framework_TestCase | |
{ | |
function testSumReturnsSumOfTwoNumbers() { | |
$myClass = new MyClass(); | |
$this->assertEquals(2, $myClass->sum(1,1)); | |
} | |
} | |
class MyClass { | |
public function sum($a, $b) { | |
return null; // FIXME: please | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ phpunit web/app/app/models/t/MyClassTest.php | |
F | |
Time: 0 seconds, Memory: 3.75Mb | |
There was 1 failure: | |
1) MyClassTest::testSumShouldReturnSumOfTwoNumbers | |
Failed asserting that <null> matches expected <integer:2>. | |
MyClassTest.php:6 | |
FAILURES! | |
Tests: 1, Assertions: 1, Failures: 1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment