Accessing variables defined in unit testcase file in src file using phing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sectrait
    New Member
    • Feb 2013
    • 2

    #1

    Accessing variables defined in unit testcase file in src file using phing

    I have defined some variables in my test file then i call a function from my test file to src file and verify the result. While using phing it is not working, but if i use php or phpunit to verify it is working fine.

    Example: add.php (source file) (present in the src directory)
    Code:
    <?php
    function add_two_numbers()
    {
        global $a,$b; /* defined in test file*/
        return ($a + $b);
    }
    ?>
    Other file:

    // add_Test (Test File) (present in the test directory)
    Code:
    <?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);
        }
    }
    
    ?>
    Now, if i use phpunit then it is working file but with phing the global variables are not set. Please tell me a solution to this.
    Last edited by sectrait; Mar 3 '13, 05:42 AM. Reason: corrected errors and using correct format
Working...