I have written some PHPUnit test code by using classes.
test.php
Expand|Select|Wrap|Line Numbers
- <?php
- require_once('PHPUnit/Framework.php');
- include("hello.php");
- class Test1 extends PHPUnit_Framework_TestCase
- {
- function testAdd() {
- $a=3;
- $b=6;
- $r=add($a,$b);
- $this->assertNotNull($r);
- $this->assertEquals($r,9);
- $this->assertTrue($r>0);
- }
- }
- ?>
Expand|Select|Wrap|Line Numbers
- <?php
- function add($a,$b)
- {
- return ($a+$b);
- }
- ?>
But, How to test the code inside the function "add()".
I mean, the testing should be done to the php code (for example:- for loops, if conditions etc.) present inside the "add()" function body.
Pl. do reply me.