[HttpFoundation] added unit test

This commit is contained in:
Johannes Schmitt 2011-05-05 09:14:48 +02:00
parent 362b7264d1
commit 4d5db59e1e

View File

@ -11,6 +11,12 @@
namespace Symfony\Tests\Component\HttpFoundation;
use Symfony\Component\HttpFoundation\HeaderBag;
use Symfony\Component\HttpFoundation\SessionStorage\ArraySessionStorage;
use Symfony\Component\HttpFoundation\Session;
use Symfony\Component\HttpFoundation\Request;
class RequestTest extends \PHPUnit_Framework_TestCase
@ -721,4 +727,24 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($request->isSecure());
$this->assertEquals(443, $request->getPort());
}
public function testHasSession()
{
$request = new Request;
$this->assertFalse($request->hasSession());
$request->setSession(new Session(new ArraySessionStorage()));
$this->assertTrue($request->hasSession());
}
public function testHasPreviousSession()
{
$request = new Request;
$this->assertFalse($request->hasPreviousSession());
$request->cookies->set(session_name(), 'foo');
$this->assertFalse($request->hasPreviousSession());
$request->setSession(new Session(new ArraySessionStorage()));
$this->assertTrue($request->hasPreviousSession());
}
}