Thanks to visit codestin.com
Credit goes to github.com

Skip to content

improve BrowserKit test coverage p1 #17069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Symfony/Component/BrowserKit/Tests/ClientTest.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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');
}
}