IsAExpectation::test PHP Method

test() public method

Tests the expectation. True if the type or class matches the string value.
public test ( string $compare ) : boolean
$compare string Comparison value.
return boolean True if correct.
    public function test($compare)
    {
        if (is_object($compare)) {
            return is_a($compare, $this->type);
        } else {
            $function = 'is_' . $this->canonicalType($this->type);
            if (is_callable($function)) {
                return $function($compare);
            }
            return false;
        }
    }

Usage Example

Example #1
0
 function testInt()
 {
     $expectation = new IsAExpectation('int');
     $this->assertTrue($expectation->test(5));
     $this->assertFalse($expectation->test(5.0));
 }
All Usage Examples Of IsAExpectation::test