Example: add.php (source file) (present in the src directory)
Expand|Select|Wrap|Line Numbers
- <?php
- function add_two_numbers()
- {
- global $a,$b; /* defined in test file*/
- return ($a + $b);
- }
- ?>
// add_Test (Test File) (present in the test directory)
Expand|Select|Wrap|Line Numbers
- <?php
- $a = 5;
- $b = 3;
- require_once ("__DIR__./../src/add.php");
- class add_Test extends PHPUnit_Framework_TestCase{
- function testadd()
- {
- $act = 8;
- $res = add_two_numbers();
- $this -> assertTrue($res === $act);
- }
- }
- ?>