stringEndsWith() public static method

Returns a PHPUnit_Framework_Constraint_StringEndsWith matcher object.
public static stringEndsWith ( mixed $suffix ) : PHPUnit_Framework_Constraint_StringEndsWith
$suffix mixed
return PHPUnit_Framework_Constraint_StringEndsWith
Example #1
0
 /**
  * @Then /^the console output should have lines ending in:$/
  */
 public function theConsoleOutputShouldHaveLinesEndingIn(PyStringNode $string)
 {
     $stdOutLines = explode(PHP_EOL, $this->lastBehatStdOut);
     $expectedLines = $string->getLines();
     \PHPUnit_Framework_Assert::assertCount(count($expectedLines), $stdOutLines);
     foreach ($stdOutLines as $idx => $stdOutLine) {
         $suffix = isset($expectedLines[$idx]) ? $expectedLines[$idx] : '(NONE)';
         $constraint = \PHPUnit_Framework_Assert::stringEndsWith($suffix);
         $constraint->evaluate($stdOutLine);
     }
 }
Example #2
0
/**
 * Returns a PHPUnit_Framework_Constraint_StringEndsWith matcher object.
 *
 * @param  mixed $suffix
 * @return PHPUnit_Framework_Constraint_StringEndsWith
 * @since  Method available since Release 3.4.0
 */
function stringEndsWith($suffix)
{
    return PHPUnit_Framework_Assert::stringEndsWith($suffix);
}
 /**
  * @covers PHPUnit_Framework_Constraint_StringEndsWith
  * @covers PHPUnit_Framework_Assert::stringEndsWith
  */
 public function testConstraintStringEndsNotWith2()
 {
     $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::stringEndsWith('suffix'));
     try {
         $constraint->fail('foosuffix', 'custom message', TRUE);
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that <string:foosuffix> ends not with \"suffix\".", $e->getDescription());
         return;
     }
     $this->fail();
 }
    /**
     * @covers PHPUnit_Framework_Constraint_StringEndsWith
     * @covers PHPUnit_Framework_Assert::stringEndsWith
     * @covers PHPUnit_Framework_TestFailure::exceptionToString
     */
    public function testConstraintStringEndsNotWith2()
    {
        $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::stringEndsWith('suffix'));
        try {
            $constraint->evaluate('foosuffix', 'custom message');
        } catch (PHPUnit_Framework_ExpectationFailedException $e) {
            $this->assertEquals(<<<EOF
custom message
Failed asserting that 'foosuffix' ends not with "suffix".

EOF
, PHPUnit_Framework_TestFailure::exceptionToString($e));
            return;
        }
        $this->fail();
    }
Example #5
0
 /**
  * Expect that a string ends with a given suffix.
  *
  * @param string $suffix
  * @param string $message
  *
  * @return Expect
  */
 public function toEndWith($suffix, $message = '')
 {
     Assert::stringEndsWith($suffix, $this->value, $message);
     return $this;
 }
Example #6
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);
 }