Gajus\Vlad\Test::assertion PHP Method

assertion() public method

public assertion ( string $selector_name, mixed $value ) : string
$selector_name string
$value mixed
return string Error.
    public function assertion($selector_name, $value)
    {
        if (!isset($this->test[$selector_name])) {
            return;
        }
        $selector = new \Gajus\Vlad\Selector($selector_name);
        foreach ($this->test[$selector_name] as $assertion) {
            $assertion = $assertion->assess($value);
            if ($assertion) {
                if (isset($assertion['options']['message'])) {
                    return $assertion['options']['message'];
                } else {
                    return $this->translator->translateMessage($assertion['validator'], $selector);
                }
            }
        }
    }

Usage Example

Beispiel #1
0
 /**
  * @depends testBuildTest
  */
 public function testAssessFailingAssertion(\Gajus\Vlad\Test $test)
 {
     $test->assert('foo')->is('String');
     $assessment = $test->assertion('foo', []);
     $this->assertSame('Foo is not a string.', $assessment);
 }