Skip to content

Commit 45a0060

Browse files
committed
minor #17069 improve BrowserKit test coverage p1 (eventhorizonpl)
This PR was merged into the 2.3 branch. Discussion ---------- improve BrowserKit test coverage p1 Hi, This PR improves BrowserKit test coverage. | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT I rebased previous PR #16549 to 2.3 Commits ------- 0261b48 improve BrowserKit test coverage p1
2 parents 2f08b28 + 0261b48 commit 45a0060

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy