10000 improve BrowserKit test coverage p1 · symfony/symfony@0261b48 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0261b48

Browse files
author
Michal Piotrowski
committed
improve BrowserKit test coverage p1
improve BrowserKit test coverage p2 improve BrowserKit test coverage p3 improve BrowserKit test coverage p4 improve BrowserKit test coverage p5
1 parent 0c2f1d9 commit 0261b48

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,4 +624,24 @@ public function testSetServerParameterInRequest()
624624
$this->assertArrayHasKey('HTTPS', $server);
625625
$this->assertFalse($server['HTTPS']);
626626
}
627+
628+
public function testInternalRequest()
629+
{
630+
$client = new TestClient();
631+
632+
$client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array(
633+
'HTTP_HOST' => 'testhost',
634+
'HTTP_USER_AGENT' => 'testua',
635+
'HTTPS' => false,
636+
'NEW_SERVER_KEY' => 'new-server-key-value',
637+
));
638+
639+
$this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest());
640+
}
641+
642+
public function testInternalRequestNull()
643+
{
644+
$client = new TestClient();
645+
$this->assertNull($client->getInternalRequest());
646+
}
627647
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ public function testCookieExpireWithNullPaths()
174174
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/')));
175175
}
176176

177+
public function testCookieExpireWithDomain()
178+
{
179+
$cookieJar = new CookieJar();
180+
$cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo', 'http://example2.com/'));
181+
$cookieJar->expire('foo', '/foo', 'http://example2.com/');
182+
183+
$this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
184+
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example2.com/')));
185+
}
186+
177187
public function testCookieWithSameNameButDifferentPaths()
178188
{
179189
$cookieJar = new CookieJar();
@@ -207,6 +217,14 @@ public function testCookieGetWithSubdomain()
207217
$this->assertEquals($cookie2, $cookieJar->get('foo1', '/', 'test.example.com'));
208218
}
209219

220+
public function testCookieGetWithWrongSubdomain()
221+
{
222+
$cookieJar = new CookieJar();
223+
$cookieJar->set($cookie1 = new Cookie('foo1', 'bar', null, '/', 'test.example.com'));
224+
225+
$this->assertNull($cookieJar->get('foo1', '/', 'foo.example.com'));
226+
}
227+
210228
public function testCookieGetWithSubdirectory()
211229
{
212230
$cookieJar = new CookieJar();

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,13 @@ public function testIsExpired()
176176
$cookie = new Cookie('foo', 'bar', 0);
177177
$this->assertFalse($cookie->isExpired());
178178
}
179+
180+
/**
181+
* @expectedException UnexpectedValueException
182+
* @expectedExceptionMessage The cookie expiration time "string" is not valid.
183+
*/
184+
public function testConstructException()
185+
{
186+
$cookie = new Cookie('foo', 'bar', 'string');
187+
}
179188
}

0 commit comments

Comments
 (0)
0