stringStartsWith() public static method

Returns a PHPUnit_Framework_Constraint_StringStartsWith matcher object.
public static stringStartsWith ( mixed $prefix ) : PHPUnit_Framework_Constraint_StringStartsWith
$prefix mixed
return PHPUnit_Framework_Constraint_StringStartsWith
Beispiel #1
0
/**
 * Returns a PHPUnit_Framework_Constraint_StringStartsWith matcher object.
 *
 * @param  mixed $prefix
 * @return PHPUnit_Framework_Constraint_StringStartsWith
 * @since  Method available since Release 3.4.0
 */
function stringStartsWith($prefix)
{
    return PHPUnit_Framework_Assert::stringStartsWith($prefix);
}
 /**
  * @covers PHPUnit_Framework_Constraint_StringStartsWith
  * @covers PHPUnit_Framework_Assert::stringStartsWith
  */
 public function testConstraintStringStartsNotWith2()
 {
     $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::stringStartsWith('prefix'));
     try {
         $constraint->fail('prefixfoo', 'custom message', TRUE);
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that <string:prefixfoo> starts not with \"prefix\".", $e->getDescription());
         return;
     }
     $this->fail();
 }
Beispiel #3
0
 function it_can_be_rendered_automatically_in_views()
 {
     $toolbar = $this->addTool('test');
     \PHPUnit_Framework_Assert::stringStartsWith('<nav class="navbar navbar-default toolbar', $toolbar);
     \PHPUnit_Framework_Assert::stringEndsWith('</nav>', $toolbar);
 }
    /**
     * @covers PHPUnit_Framework_Constraint_StringStartsWith
     * @covers PHPUnit_Framework_Assert::stringStartsWith
     * @covers PHPUnit_Framework_TestFailure::exceptionToString
     */
    public function testConstraintStringStartsNotWith2()
    {
        $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::stringStartsWith('prefix'));
        try {
            $constraint->evaluate('prefixfoo', 'custom message');
        } catch (PHPUnit_Framework_ExpectationFailedException $e) {
            $this->assertEquals(<<<EOF
custom message
Failed asserting that 'prefixfoo' starts not with "prefix".

EOF
, PHPUnit_Framework_TestFailure::exceptionToString($e));
            return;
        }
        $this->fail();
    }
 /**
  * @Then the response should be json/JSON
  * @Then the response is json/JSON
  */
 public function theResponseIsJson()
 {
     Assert::assertThat(static::$response->headers->get('Content-Type'), Assert::logicalOr(Assert::stringStartsWith('application/json'), Assert::stringStartsWith('text/javascript')));
     Assert::assertJson($this->getResponseContent());
 }