This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Components/HttpKernel/ClientTest.php
Fabien Potencier 9133b9e5e4 moved Request/Response/User classes to a new HttpFoundation component
The HttpFoundation component holds classes that wrap PHP native global arrays.

The following classes has been moved:

 * Symfony\Components\HttpKernel\Response -> Symfony\Components\HttpFoundation\Response
 * Symfony\Components\HttpKernel\Request -> Symfony\Components\HttpFoundation\Request
 * Symfony\Framework\FoundationBundle\User ->  Symfony\Components\HttpFoundation\Session
 * Symfony\Framework\FoundationBundle\Session\* ->  Symfony\Components\HttpFoundation\SessionStorage\*Storage

The web:user DI configuration has been moved to kernel:session.

The user helper has been renamed to session.
2010-07-09 09:26:22 +02:00

58 lines
1.9 KiB
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Tests\Components\HttpKernel;
use Symfony\Components\HttpKernel\Client;
use Symfony\Components\HttpKernel\HttpKernel;
use Symfony\Components\HttpFoundation\Request;
use Symfony\Components\HttpFoundation\Response;
use Symfony\Components\EventDispatcher\EventDispatcher;
use Symfony\Components\EventDispatcher\Event;
require_once __DIR__.'/TestHttpKernel.php';
class TestClient extends Client
{
protected function getScript($request)
{
$script = parent::getScript($request);
$script = preg_replace('/(\->register\(\);)/', "$0\nrequire_once '".__DIR__."/TestHttpKernel.php';", $script);
return $script;
}
}
class ClientTest extends \PHPUnit_Framework_TestCase
{
public function testDoRequest()
{
$client = new Client(new TestHttpKernel());
$client->request('GET', '/');
$this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request');
$client->request('GET', 'http://www.example.com/');
$this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request');
$this->assertEquals('www.example.com', $client->getRequest()->getHost(), '->doRequest() uses the request handler to make the request');
}
public function testGetScript()
{
$client = new TestClient(new TestHttpKernel());
$client->insulate();
$client->request('GET', '/');
$this->assertEquals('Request: /', $client->getResponse()->getContent(), '->getScript() returns a script that uses the request handler to make the request');
}
}