merged branch pborreli/browserkit (PR #5097)
Commits
-------
910b60d
[BrowserKit] Added some tests, removed dead code
Discussion
----------
[BrowserKit] Added some tests
Code coverage : 99.68%
This commit is contained in:
commit
a172a81296
@ -224,6 +224,25 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() clicks on links');
|
||||
}
|
||||
|
||||
public function testClickForm()
|
||||
{
|
||||
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
|
||||
$this->markTestSkipped('The "DomCrawler" component is not available');
|
||||
}
|
||||
|
||||
if (!class_exists('Symfony\Component\CssSelector\CssSelector')) {
|
||||
$this->markTestSkipped('The "CssSelector" component is not available');
|
||||
}
|
||||
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
||||
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
|
||||
|
||||
$client->click($crawler->filter('input')->form());
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() Form submit forms');
|
||||
}
|
||||
|
||||
public function testSubmit()
|
||||
{
|
||||
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
|
||||
|
@ -144,6 +144,29 @@ class CookieJarTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array('foo' => 'bar%3Dbaz'), $cookieJar->allRawValues('/'));
|
||||
}
|
||||
|
||||
public function testCookieExpireWithSameNameButDifferentPaths()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo'));
|
||||
$cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/bar'));
|
||||
$cookieJar->expire('foo', '/foo');
|
||||
|
||||
$this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
|
||||
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/')));
|
||||
$this->assertEquals(array(), $cookieJar->allValues('http://example.com/foo'));
|
||||
$this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://example.com/bar'));
|
||||
}
|
||||
|
||||
public function testCookieExpireWithNullPaths()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
$cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/'));
|
||||
$cookieJar->expire('foo', null);
|
||||
|
||||
$this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
|
||||
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/')));
|
||||
}
|
||||
|
||||
public function testCookieWithSameNameButDifferentPaths()
|
||||
{
|
||||
$cookieJar = new CookieJar();
|
||||
|
@ -58,6 +58,7 @@ class CookieTest extends \PHPUnit_Framework_TestCase
|
||||
array('foo=bar; expires=Fri, 31 Jul 2020 08:49:37 GMT'),
|
||||
array('foo=bar; expires=Friday, 31-Jul-20 08:49:37 GMT'),
|
||||
array('foo=bar; expires=Fri Jul 31 08:49:37 2020'),
|
||||
array('foo=bar; expires=\'Fri Jul 31 08:49:37 2020\''),
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user