Skip to content

Instantly share code, notes, and snippets.

@edthix
Created November 15, 2010 19:14
Show Gist options
  • Save edthix/700800 to your computer and use it in GitHub Desktop.
Save edthix/700800 to your computer and use it in GitHub Desktop.
Testing via simpletest
<?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