Created
November 15, 2010 19:14
-
-
Save edthix/700800 to your computer and use it in GitHub Desktop.
Testing via simpletest
This file contains hidden or 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
<?php | |
require_once 'simpletest/autorun.php'; | |
function add($a, $b){ | |
return $a + $b; | |
} | |
function sayHi($name){ | |
return "Hello $name"; | |
} | |
function wrapTextInHtmlH1($txt){ | |
$uppercase = ucwords($txt); | |
return "<h1>$uppercase</h1>"; | |
} | |
class TestFunction extends UnitTestCase{ | |
function testAddTwoNumbers(){ | |
$this->assertEqual(add(5, 5), '10'); | |
} | |
function testSayHiToTheWorld(){ | |
$this->assertEqual(sayHi('Ahmad'), 'Hello Ahmad'); | |
} | |
function testWrapTextInHtmlH1(){ | |
$this->assertEqual(wrapTextInHtmlH1('title of this article'), '<h1>Title Of This Article</h1>'); | |
} | |
function testNameIsNull(){ | |
$name = NULL; | |
$this->assertNull($name); | |
// $this->assertNotNull($name); | |
} | |
function testFail(){ | |
$this->fail('Do this later'); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment