Skip to content

Commit

Permalink
minor #17069 improve BrowserKit test coverage p1 (eventhorizonpl)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Tobion committed Dec 24, 2015
2 parents 2f08b28 + 0261b48 commit 45a0060
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Symfony/Component/BrowserKit/Tests/ClientTest.php
Expand Up @@ -624,4 +624,24 @@ public function testSetServerParameterInRequest()
$this->assertArrayHasKey('HTTPS', $server);
$this->assertFalse($server['HTTPS']);
}

public function testInternalRequest()
{
$client = new TestClient();

$client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array(
'HTTP_HOST' => 'testhost',
'HTTP_USER_AGENT' => 'testua',
'HTTPS' => false,
'NEW_SERVER_KEY' => 'new-server-key-value',
));

$this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest());
}

public function testInternalRequestNull()
{
$client = new TestClient();
$this->assertNull($client->getInternalRequest());
}
}
18 changes: 18 additions & 0 deletions src/Symfony/Component/BrowserKit/Tests/CookieJarTest.php
Expand Up @@ -174,6 +174,16 @@ public function testCookieExpireWithNullPaths()
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/')));
}

public function testCookieExpireWithDomain()
{
$cookieJar = new CookieJar();
$cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo', 'http://example2.com/'));
$cookieJar->expire('foo', '/foo', 'http://example2.com/');

$this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired');
$this->assertEquals(array(), array_keys($cookieJar->allValues('http://example2.com/')));
}

public function testCookieWithSameNameButDifferentPaths()
{
$cookieJar = new CookieJar();
Expand Down Expand Up @@ -207,6 +217,14 @@ public function testCookieGetWithSubdomain()
$this->assertEquals($cookie2, $cookieJar->get('foo1', '/', 'test.example.com'));
}

public function testCookieGetWithWrongSubdomain()
{
$cookieJar = new CookieJar();
$cookieJar->set($cookie1 = new Cookie('foo1', 'bar', null, '/', 'test.example.com'));

$this->assertNull($cookieJar->get('foo1', '/', 'foo.example.com'));
}

public function testCookieGetWithSubdirectory()
{
$cookieJar = new CookieJar();
Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Component/BrowserKit/Tests/CookieTest.php
Expand Up @@ -176,4 +176,13 @@ public function testIsExpired()
$cookie = new Cookie('foo', 'bar', 0);
$this->assertFalse($cookie->isExpired());
}

/**
* @expectedException UnexpectedValueException
* @expectedExceptionMessage The cookie expiration time "string" is not valid.
*/
public function testConstructException()
{
$cookie = new Cookie('foo', 'bar', 'string');
}
}

0 comments on commit 45a0060

Please sign in to comment.