I am very new to PHPUnit and unit-testing, so I have a questing: Can I test a function outside a class like:
    function odd_or_even( $num ) {
    return $num%2; // Returns 0 for odd and 1 for even
}
class test extends PHPUnit_Framework_TestCase {
    public function odd_or_even_to_true() {
        $this->assetTrue( odd_or_even( 4 ) == true );
    }
}
Right now it just returns:
No tests found in class "test".
                You need to prefix your function names with 'test' in order for them to be recognized as a test.
From the documentation:
- The tests are public methods that are named test*.
 Alternatively, you can use the @test annotation in a method's docblock to mark it as a test method.
There should be no problem calling odd_or_even().
For example:
class test extends PHPUnit_Framework_TestCase {
    public function test_odd_or_even_to_true() {
        $this->assertTrue( odd_or_even( 4 ) == true );
    }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With