public function testConstraintPCREMatch2() { $constraint = new PHPUnit_Framework_Constraint_PCREMatch('/foo/'); try { $constraint->fail('barbazbar', 'custom message'); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals("custom message\nFailed asserting that <string:barbazbar> matches PCRE pattern \"/foo/\".", $e->getDescription()); return; } $this->fail(); }
public function testConstraintPCREMatch() { $constraint = new PHPUnit_Framework_Constraint_PCREMatch('/foo/'); $this->assertFalse($constraint->evaluate('barbazbar')); $this->assertTrue($constraint->evaluate('barfoobar')); $this->assertEquals('matches PCRE pattern "/foo/"', $constraint->toString()); try { $constraint->fail('barbazbar', ''); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals('Failed asserting that <string:barbazbar> matches PCRE pattern "/foo/".', $e->getDescription()); return; } $this->fail(); }