use PHPUnit\Framework\TestFailure;
use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\BrowserKit\Cookie;
use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\BrowserKit\Test\Constraint\BrowserHasCookie;
class BrowserHasCookieTest extends TestCase
{ public function testConstraint() { $browser =
$this->
getBrowser();
$constraint =
new BrowserHasCookie('foo', '/path'
);
$this->
assertTrue($constraint->
evaluate($browser, '', true
));
$constraint =
new BrowserHasCookie('foo', '/path', 'example.com'
);
$this->
assertTrue($constraint->
evaluate($browser, '', true
));
$constraint =
new BrowserHasCookie('bar'
);
$this->
assertFalse($constraint->
evaluate($browser, '', true
));
try { $constraint->
evaluate($browser);
} catch (ExpectationFailedException
$e) { $this->
assertEquals("Failed asserting that the Browser has cookie \"bar\".\n", TestFailure::
exceptionToString($e));