Skip to content

Commit a172a81

Browse files
committed
merged branch pborreli/browserkit (PR #5097)
Commits ------- 910b60d [BrowserKit] Added some tests, removed dead code Discussion ---------- [BrowserKit] Added some tests Code coverage : 99.68%
2 parents cbd03ec + 910b60d commit a172a81

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,25 @@ public function testClick()
224224
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() clicks on links');
225225
}
226226

227+
public function testClickForm()
228+
{
229+
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
230+
$this->markTestSkipped('The "DomCrawler" component is not available');
231+
}
232+
233+
if (!class_exists('Symfony\Component\CssSelector\CssSelector')) {
234+
$this->markTestSkipped('The "CssSelector" component is not available');
235+
}
236+
237+
$client = new TestClient();
238+
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
239+
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
240+
241+
$client->click($crawler->filter('input')->form());
242+
243+
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() Form submit forms');
244+
}
245+
227246
public function testSubmit()
228247
{
229248
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {

src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,29 @@ public function testEncodedValues()
144144
$this->assertEquals(array('foo' => 'bar%3Dbaz'), $cookieJar->allRawValues('/'));
145145
}
146146

147+
public function testCookieExpireWithSameNameButDifferentPaths()
148+
{
149+
$cookieJar = new CookieJar();
150+
$cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo'));
151+
$cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/bar'));
152+
$cookieJar->expire('foo', '/foo');
153+
154+
$this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
155+
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/')));
156+
$this->assertEquals(array(), $cookieJar->allValues('http://example.com/foo'));
157+
$this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://example.com/bar'));
158+
}
159+
160+
public function testCookieExpireWithNullPaths()
161+
{
162+
$cookieJar = new CookieJar();
163+
$cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/'));
164+
$cookieJar->expire('foo', null);
165+
166+
$this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
167+
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/')));
168+
}
169+
147170
public function testCookieWithSameNameButDifferentPaths()
148171
{
149172
$cookieJar = new CookieJar();

src/Symfony/Component/BrowserKit/Tests/CookieTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function getExpireCookieStrings()
5858
array('foo=bar; expires=Fri, 31 Jul 2020 08:49:37 GMT'),
5959
array('foo=bar; expires=Friday, 31-Jul-20 08:49:37 GMT'),
6060
array('foo=bar; expires=Fri Jul 31 08:49:37 2020'),
61+
array('foo=bar; expires=\'Fri Jul 31 08:49:37 2020\''),
6162
);
6263
}
6364

0 commit comments

Comments
 (0)