Hi All,
I have written some PHPUnit test code by using classes.
test.php
hello.php
Here I am able to test whether the function is returning the expected value for the given input paramaters or not.
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.
I have written some PHPUnit test code by using classes.
test.php
Code:
<?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);
}
}
?>
Code:
<?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.