From cbb3e69b36a46c13590bb89c29b3b3f60f7e73b5 Mon Sep 17 00:00:00 2001 From: Drak Date: Tue, 14 Feb 2012 21:10:15 +0545 Subject: [PATCH] [HttpFoundation] Increase test coverage. --- .../Session/Attribute/AttributeBagTest.php | 7 +++++++ .../HttpFoundation/Session/SessionTest.php | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/tests/Symfony/Tests/Component/HttpFoundation/Session/Attribute/AttributeBagTest.php b/tests/Symfony/Tests/Component/HttpFoundation/Session/Attribute/AttributeBagTest.php index a5c921254c..5bf62110d9 100644 --- a/tests/Symfony/Tests/Component/HttpFoundation/Session/Attribute/AttributeBagTest.php +++ b/tests/Symfony/Tests/Component/HttpFoundation/Session/Attribute/AttributeBagTest.php @@ -64,6 +64,13 @@ class AttributeBagTest extends \PHPUnit_Framework_TestCase $this->assertEquals('test', $attributeBag->getStorageKey()); } + public function testGetSetName() + { + $this->assertEquals('attributes', $this->bag->getName()); + $this->bag->setName('foo'); + $this->assertEquals('foo', $this->bag->getName()); + } + /** * @dataProvider attributesProvider */ diff --git a/tests/Symfony/Tests/Component/HttpFoundation/Session/SessionTest.php b/tests/Symfony/Tests/Component/HttpFoundation/Session/SessionTest.php index 20f5079150..9141c79fb9 100644 --- a/tests/Symfony/Tests/Component/HttpFoundation/Session/SessionTest.php +++ b/tests/Symfony/Tests/Component/HttpFoundation/Session/SessionTest.php @@ -70,6 +70,16 @@ class SessionTest extends \PHPUnit_Framework_TestCase $this->assertEquals($value, $this->session->get($key)); } + /** + * @dataProvider setProvider + */ + public function testHas($key, $value) + { + $this->session->set($key, $value); + $this->assertTrue($this->session->has($key)); + $this->assertFalse($this->session->has($key.'non_value')); + } + public function testReplace() { $this->session->replace(array('happiness' => 'be good', 'symfony' => 'awesome')); @@ -139,6 +149,11 @@ class SessionTest extends \PHPUnit_Framework_TestCase $this->assertEquals(333, $this->session->get('migrate')); } + public function testSave() + { + $this->session->save(); + } + public function testGetId() { $this->assertEquals('', $this->session->getId()); @@ -146,6 +161,11 @@ class SessionTest extends \PHPUnit_Framework_TestCase $this->assertNotEquals('', $this->session->getId()); } + public function testGetFlashBag() + { + $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface', $this->session->getFlashBag()); + } + // deprecated since 2.1, will be removed from 2.3 public function testGetSetFlashes()