Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
vendor/symfony/psr-http-message-bridge/Tests
224
vendor/symfony/psr-http-message-bridge/Tests/Factory/AbstractHttpMessageFactoryTest.php
vendored
Normal file
224
vendor/symfony/psr-http-message-bridge/Tests/Factory/AbstractHttpMessageFactoryTest.php
vendored
Normal file
|
@ -0,0 +1,224 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
* @author Antonio J. García Lagar <aj@garcialagar.es>
|
||||
*/
|
||||
abstract class AbstractHttpMessageFactoryTest extends TestCase
|
||||
{
|
||||
private $factory;
|
||||
private $tmpDir;
|
||||
|
||||
/**
|
||||
* @return HttpMessageFactoryInterface
|
||||
*/
|
||||
abstract protected function buildHttpMessageFactory();
|
||||
|
||||
public function setup()
|
||||
{
|
||||
$this->factory = $this->buildHttpMessageFactory();
|
||||
$this->tmpDir = sys_get_temp_dir();
|
||||
}
|
||||
|
||||
public function testCreateRequest()
|
||||
{
|
||||
$stdClass = new \stdClass();
|
||||
$request = new Request(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'bar' => array('baz' => '42'),
|
||||
),
|
||||
array(
|
||||
'twitter' => array(
|
||||
'@dunglas' => 'Kévin Dunglas',
|
||||
'@coopTilleuls' => 'Les-Tilleuls.coop',
|
||||
),
|
||||
'baz' => '2',
|
||||
),
|
||||
array(
|
||||
'a1' => $stdClass,
|
||||
'a2' => array('foo' => 'bar'),
|
||||
),
|
||||
array(
|
||||
'c1' => 'foo',
|
||||
'c2' => array('c3' => 'bar'),
|
||||
),
|
||||
array(
|
||||
'f1' => $this->createUploadedFile('F1', 'f1.txt', 'text/plain', UPLOAD_ERR_OK),
|
||||
'foo' => array('f2' => $this->createUploadedFile('F2', 'f2.txt', 'text/plain', UPLOAD_ERR_OK)),
|
||||
),
|
||||
array(
|
||||
'REQUEST_METHOD' => 'POST',
|
||||
'HTTP_HOST' => 'dunglas.fr',
|
||||
'HTTP_X_SYMFONY' => '2.8',
|
||||
'REQUEST_URI' => '/testCreateRequest?foo=1&bar[baz]=42',
|
||||
'QUERY_STRING' => 'foo=1&bar[baz]=42',
|
||||
),
|
||||
'Content'
|
||||
);
|
||||
|
||||
$psrRequest = $this->factory->createRequest($request);
|
||||
|
||||
$this->assertEquals('Content', $psrRequest->getBody()->__toString());
|
||||
|
||||
$queryParams = $psrRequest->getQueryParams();
|
||||
$this->assertEquals('1', $queryParams['foo']);
|
||||
$this->assertEquals('42', $queryParams['bar']['baz']);
|
||||
|
||||
$requestTarget = $psrRequest->getRequestTarget();
|
||||
$this->assertEquals('/testCreateRequest?foo=1&bar[baz]=42', urldecode($requestTarget));
|
||||
|
||||
$parsedBody = $psrRequest->getParsedBody();
|
||||
$this->assertEquals('Kévin Dunglas', $parsedBody['twitter']['@dunglas']);
|
||||
$this->assertEquals('Les-Tilleuls.coop', $parsedBody['twitter']['@coopTilleuls']);
|
||||
$this->assertEquals('2', $parsedBody['baz']);
|
||||
|
||||
$attributes = $psrRequest->getAttributes();
|
||||
$this->assertEquals($stdClass, $attributes['a1']);
|
||||
$this->assertEquals('bar', $attributes['a2']['foo']);
|
||||
|
||||
$cookies = $psrRequest->getCookieParams();
|
||||
$this->assertEquals('foo', $cookies['c1']);
|
||||
$this->assertEquals('bar', $cookies['c2']['c3']);
|
||||
|
||||
$uploadedFiles = $psrRequest->getUploadedFiles();
|
||||
$this->assertEquals('F1', $uploadedFiles['f1']->getStream()->__toString());
|
||||
$this->assertEquals('f1.txt', $uploadedFiles['f1']->getClientFilename());
|
||||
$this->assertEquals('text/plain', $uploadedFiles['f1']->getClientMediaType());
|
||||
$this->assertEquals(UPLOAD_ERR_OK, $uploadedFiles['f1']->getError());
|
||||
|
||||
$this->assertEquals('F2', $uploadedFiles['foo']['f2']->getStream()->__toString());
|
||||
$this->assertEquals('f2.txt', $uploadedFiles['foo']['f2']->getClientFilename());
|
||||
$this->assertEquals('text/plain', $uploadedFiles['foo']['f2']->getClientMediaType());
|
||||
$this->assertEquals(UPLOAD_ERR_OK, $uploadedFiles['foo']['f2']->getError());
|
||||
|
||||
$serverParams = $psrRequest->getServerParams();
|
||||
$this->assertEquals('POST', $serverParams['REQUEST_METHOD']);
|
||||
$this->assertEquals('2.8', $serverParams['HTTP_X_SYMFONY']);
|
||||
$this->assertEquals('POST', $psrRequest->getMethod());
|
||||
$this->assertEquals(array('2.8'), $psrRequest->getHeader('X-Symfony'));
|
||||
}
|
||||
|
||||
public function testGetContentCanBeCalledAfterRequestCreation()
|
||||
{
|
||||
$header = array('HTTP_HOST' => 'dunglas.fr');
|
||||
$request = new Request(array(), array(), array(), array(), array(), $header, 'Content');
|
||||
|
||||
$psrRequest = $this->factory->createRequest($request);
|
||||
|
||||
$this->assertEquals('Content', $psrRequest->getBody()->__toString());
|
||||
$this->assertEquals('Content', $request->getContent());
|
||||
}
|
||||
|
||||
private function createUploadedFile($content, $originalName, $mimeType, $error)
|
||||
{
|
||||
$path = tempnam($this->tmpDir, uniqid());
|
||||
file_put_contents($path, $content);
|
||||
|
||||
if (class_exists('Symfony\Component\HttpFoundation\HeaderUtils')) {
|
||||
// Symfony 4.1+
|
||||
return new UploadedFile($path, $originalName, $mimeType, $error, true);
|
||||
}
|
||||
return new UploadedFile($path, $originalName, $mimeType, filesize($path), $error, true);
|
||||
}
|
||||
|
||||
public function testCreateResponse()
|
||||
{
|
||||
$response = new Response(
|
||||
'Response content.',
|
||||
202,
|
||||
array('X-Symfony' => array('3.4'))
|
||||
);
|
||||
$response->headers->setCookie(new Cookie('city', 'Lille', new \DateTime('Wed, 13 Jan 2021 22:23:01 GMT')));
|
||||
|
||||
$psrResponse = $this->factory->createResponse($response);
|
||||
$this->assertEquals('Response content.', $psrResponse->getBody()->__toString());
|
||||
$this->assertEquals(202, $psrResponse->getStatusCode());
|
||||
$this->assertEquals(array('3.4'), $psrResponse->getHeader('X-Symfony'));
|
||||
|
||||
$cookieHeader = $psrResponse->getHeader('Set-Cookie');
|
||||
$this->assertInternalType('array', $cookieHeader);
|
||||
$this->assertCount(1, $cookieHeader);
|
||||
$this->assertRegExp('{city=Lille; expires=Wed, 13-Jan-2021 22:23:01 GMT;( max-age=\d+;)? path=/; httponly}i', $cookieHeader[0]);
|
||||
}
|
||||
|
||||
public function testCreateResponseFromStreamed()
|
||||
{
|
||||
$response = new StreamedResponse(function () {
|
||||
echo "Line 1\n";
|
||||
flush();
|
||||
|
||||
echo "Line 2\n";
|
||||
flush();
|
||||
});
|
||||
|
||||
$psrResponse = $this->factory->createResponse($response);
|
||||
|
||||
$this->assertEquals("Line 1\nLine 2\n", $psrResponse->getBody()->__toString());
|
||||
}
|
||||
|
||||
public function testCreateResponseFromBinaryFile()
|
||||
{
|
||||
$path = tempnam($this->tmpDir, uniqid());
|
||||
file_put_contents($path, 'Binary');
|
||||
|
||||
$response = new BinaryFileResponse($path);
|
||||
|
||||
$psrResponse = $this->factory->createResponse($response);
|
||||
|
||||
$this->assertEquals('Binary', $psrResponse->getBody()->__toString());
|
||||
}
|
||||
|
||||
public function testUploadErrNoFile()
|
||||
{
|
||||
if (class_exists('Symfony\Component\HttpFoundation\HeaderUtils')) {
|
||||
// Symfony 4.1+
|
||||
$file = new UploadedFile('', '', null, UPLOAD_ERR_NO_FILE, true);
|
||||
} else {
|
||||
$file = new UploadedFile('', '', null, 0, UPLOAD_ERR_NO_FILE, true);
|
||||
}
|
||||
$this->assertEquals(0, $file->getSize());
|
||||
$this->assertEquals(UPLOAD_ERR_NO_FILE, $file->getError());
|
||||
$this->assertFalse($file->getSize(), 'SplFile::getSize() returns false on error');
|
||||
|
||||
$request = new Request(array(), array(), array(), array(),
|
||||
array(
|
||||
'f1' => $file,
|
||||
'f2' => array('name' => null, 'type' => null, 'tmp_name' => null, 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0),
|
||||
),
|
||||
array(
|
||||
'REQUEST_METHOD' => 'POST',
|
||||
'HTTP_HOST' => 'dunglas.fr',
|
||||
'HTTP_X_SYMFONY' => '2.8',
|
||||
),
|
||||
'Content'
|
||||
);
|
||||
|
||||
$psrRequest = $this->factory->createRequest($request);
|
||||
|
||||
$uploadedFiles = $psrRequest->getUploadedFiles();
|
||||
|
||||
$this->assertEquals(UPLOAD_ERR_NO_FILE, $uploadedFiles['f1']->getError());
|
||||
$this->assertEquals(UPLOAD_ERR_NO_FILE, $uploadedFiles['f2']->getError());
|
||||
}
|
||||
}
|
30
vendor/symfony/psr-http-message-bridge/Tests/Factory/DiactorosFactoryTest.php
vendored
Normal file
30
vendor/symfony/psr-http-message-bridge/Tests/Factory/DiactorosFactoryTest.php
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory;
|
||||
|
||||
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
* @author Antonio J. García Lagar <aj@garcialagar.es>
|
||||
*/
|
||||
class DiactorosFactoryTest extends AbstractHttpMessageFactoryTest
|
||||
{
|
||||
protected function buildHttpMessageFactory()
|
||||
{
|
||||
if (!class_exists('Zend\Diactoros\ServerRequestFactory')) {
|
||||
$this->markTestSkipped('Zend Diactoros is not installed.');
|
||||
}
|
||||
|
||||
return new DiactorosFactory();
|
||||
}
|
||||
}
|
237
vendor/symfony/psr-http-message-bridge/Tests/Factory/HttpFoundationFactoryTest.php
vendored
Normal file
237
vendor/symfony/psr-http-message-bridge/Tests/Factory/HttpFoundationFactoryTest.php
vendored
Normal file
|
@ -0,0 +1,237 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
|
||||
use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Response;
|
||||
use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\ServerRequest;
|
||||
use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Stream;
|
||||
use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\UploadedFile;
|
||||
use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Uri;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class HttpFoundationFactoryTest extends TestCase
|
||||
{
|
||||
/** @var HttpFoundationFactory */
|
||||
private $factory;
|
||||
|
||||
/** @var string */
|
||||
private $tmpDir;
|
||||
|
||||
public function setup()
|
||||
{
|
||||
$this->factory = new HttpFoundationFactory();
|
||||
$this->tmpDir = sys_get_temp_dir();
|
||||
}
|
||||
|
||||
public function testCreateRequest()
|
||||
{
|
||||
$stdClass = new \stdClass();
|
||||
$serverRequest = new ServerRequest(
|
||||
'1.1',
|
||||
array(
|
||||
'X-Dunglas-API-Platform' => '1.0',
|
||||
'X-data' => array('a', 'b'),
|
||||
),
|
||||
new Stream('The body'),
|
||||
'/about/kevin',
|
||||
'GET',
|
||||
'http://les-tilleuls.coop/about/kevin',
|
||||
array('country' => 'France'),
|
||||
array('city' => 'Lille'),
|
||||
array('url' => 'http://les-tilleuls.coop'),
|
||||
array(
|
||||
'doc1' => $this->createUploadedFile('Doc 1', UPLOAD_ERR_OK, 'doc1.txt', 'text/plain'),
|
||||
'nested' => array(
|
||||
'docs' => array(
|
||||
$this->createUploadedFile('Doc 2', UPLOAD_ERR_OK, 'doc2.txt', 'text/plain'),
|
||||
$this->createUploadedFile('Doc 3', UPLOAD_ERR_OK, 'doc3.txt', 'text/plain'),
|
||||
),
|
||||
),
|
||||
),
|
||||
array('url' => 'http://dunglas.fr'),
|
||||
array('custom' => $stdClass)
|
||||
);
|
||||
|
||||
$symfonyRequest = $this->factory->createRequest($serverRequest);
|
||||
$files = $symfonyRequest->files->all();
|
||||
|
||||
$this->assertEquals('http://les-tilleuls.coop', $symfonyRequest->query->get('url'));
|
||||
$this->assertEquals('doc1.txt', $files['doc1']->getClientOriginalName());
|
||||
$this->assertEquals('doc2.txt', $files['nested']['docs'][0]->getClientOriginalName());
|
||||
$this->assertEquals('doc3.txt', $files['nested']['docs'][1]->getClientOriginalName());
|
||||
$this->assertEquals('http://dunglas.fr', $symfonyRequest->request->get('url'));
|
||||
$this->assertEquals($stdClass, $symfonyRequest->attributes->get('custom'));
|
||||
$this->assertEquals('Lille', $symfonyRequest->cookies->get('city'));
|
||||
$this->assertEquals('France', $symfonyRequest->server->get('country'));
|
||||
$this->assertEquals('The body', $symfonyRequest->getContent());
|
||||
$this->assertEquals('1.0', $symfonyRequest->headers->get('X-Dunglas-API-Platform'));
|
||||
$this->assertEquals(array('a', 'b'), $symfonyRequest->headers->get('X-data', null, false));
|
||||
}
|
||||
|
||||
public function testCreateRequestWithNullParsedBody()
|
||||
{
|
||||
$serverRequest = new ServerRequest(
|
||||
'1.1',
|
||||
array(),
|
||||
new Stream(),
|
||||
'/',
|
||||
'GET',
|
||||
null,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
null,
|
||||
array()
|
||||
);
|
||||
|
||||
$this->assertCount(0, $this->factory->createRequest($serverRequest)->request);
|
||||
}
|
||||
|
||||
public function testCreateRequestWithObjectParsedBody()
|
||||
{
|
||||
$serverRequest = new ServerRequest(
|
||||
'1.1',
|
||||
array(),
|
||||
new Stream(),
|
||||
'/',
|
||||
'GET',
|
||||
null,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
new \stdClass(),
|
||||
array()
|
||||
);
|
||||
|
||||
$this->assertCount(0, $this->factory->createRequest($serverRequest)->request);
|
||||
}
|
||||
|
||||
public function testCreateRequestWithUri()
|
||||
{
|
||||
$serverRequest = new ServerRequest(
|
||||
'1.1',
|
||||
array(),
|
||||
new Stream(),
|
||||
'/',
|
||||
'GET',
|
||||
new Uri('http://les-tilleuls.coop/about/kevin'),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
null,
|
||||
array()
|
||||
);
|
||||
|
||||
$this->assertEquals('/about/kevin', $this->factory->createRequest($serverRequest)->getPathInfo());
|
||||
}
|
||||
|
||||
public function testCreateUploadedFile()
|
||||
{
|
||||
$uploadedFile = $this->createUploadedFile('An uploaded file.', UPLOAD_ERR_OK, 'myfile.txt', 'text/plain');
|
||||
$symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile);
|
||||
$size = $symfonyUploadedFile->getSize();
|
||||
|
||||
$uniqid = uniqid();
|
||||
$symfonyUploadedFile->move($this->tmpDir, $uniqid);
|
||||
|
||||
$this->assertEquals($uploadedFile->getSize(), $size);
|
||||
$this->assertEquals(UPLOAD_ERR_OK, $symfonyUploadedFile->getError());
|
||||
$this->assertEquals('myfile.txt', $symfonyUploadedFile->getClientOriginalName());
|
||||
$this->assertEquals('txt', $symfonyUploadedFile->getClientOriginalExtension());
|
||||
$this->assertEquals('text/plain', $symfonyUploadedFile->getClientMimeType());
|
||||
$this->assertEquals('An uploaded file.', file_get_contents($this->tmpDir.'/'.$uniqid));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpFoundation\File\Exception\FileException
|
||||
* @expectedExceptionMessage The file "e" could not be written on disk.
|
||||
*/
|
||||
public function testCreateUploadedFileWithError()
|
||||
{
|
||||
$uploadedFile = $this->createUploadedFile('Error.', UPLOAD_ERR_CANT_WRITE, 'e', 'text/plain');
|
||||
$symfonyUploadedFile = $this->callCreateUploadedFile($uploadedFile);
|
||||
|
||||
$this->assertEquals(UPLOAD_ERR_CANT_WRITE, $symfonyUploadedFile->getError());
|
||||
|
||||
$symfonyUploadedFile->move($this->tmpDir, 'shouldFail.txt');
|
||||
}
|
||||
|
||||
private function createUploadedFile($content, $error, $clientFileName, $clientMediaType)
|
||||
{
|
||||
$filePath = tempnam($this->tmpDir, uniqid());
|
||||
file_put_contents($filePath, $content);
|
||||
|
||||
return new UploadedFile($filePath, filesize($filePath), $error, $clientFileName, $clientMediaType);
|
||||
}
|
||||
|
||||
private function callCreateUploadedFile(UploadedFileInterface $uploadedFile)
|
||||
{
|
||||
$reflection = new \ReflectionClass($this->factory);
|
||||
$createUploadedFile = $reflection->getMethod('createUploadedFile');
|
||||
$createUploadedFile->setAccessible(true);
|
||||
|
||||
return $createUploadedFile->invokeArgs($this->factory, array($uploadedFile));
|
||||
}
|
||||
|
||||
public function testCreateResponse()
|
||||
{
|
||||
$response = new Response(
|
||||
'1.0',
|
||||
array(
|
||||
'X-Symfony' => array('2.8'),
|
||||
'Set-Cookie' => array(
|
||||
'theme=light',
|
||||
'test',
|
||||
'ABC=AeD; Domain=dunglas.fr; Path=/kevin; Expires=Wed, 13 Jan 2021 22:23:01 GMT; Secure; HttpOnly',
|
||||
),
|
||||
),
|
||||
new Stream('The response body'),
|
||||
200
|
||||
);
|
||||
|
||||
$symfonyResponse = $this->factory->createResponse($response);
|
||||
|
||||
$this->assertEquals('1.0', $symfonyResponse->getProtocolVersion());
|
||||
$this->assertEquals('2.8', $symfonyResponse->headers->get('X-Symfony'));
|
||||
|
||||
$cookies = $symfonyResponse->headers->getCookies();
|
||||
$this->assertEquals('theme', $cookies[0]->getName());
|
||||
$this->assertEquals('light', $cookies[0]->getValue());
|
||||
$this->assertEquals(0, $cookies[0]->getExpiresTime());
|
||||
$this->assertNull($cookies[0]->getDomain());
|
||||
$this->assertEquals('/', $cookies[0]->getPath());
|
||||
$this->assertFalse($cookies[0]->isSecure());
|
||||
$this->assertFalse($cookies[0]->isHttpOnly());
|
||||
|
||||
$this->assertEquals('test', $cookies[1]->getName());
|
||||
$this->assertNull($cookies[1]->getValue());
|
||||
|
||||
$this->assertEquals('ABC', $cookies[2]->getName());
|
||||
$this->assertEquals('AeD', $cookies[2]->getValue());
|
||||
$this->assertEquals(strtotime('Wed, 13 Jan 2021 22:23:01 GMT'), $cookies[2]->getExpiresTime());
|
||||
$this->assertEquals('dunglas.fr', $cookies[2]->getDomain());
|
||||
$this->assertEquals('/kevin', $cookies[2]->getPath());
|
||||
$this->assertTrue($cookies[2]->isSecure());
|
||||
$this->assertTrue($cookies[2]->isHttpOnly());
|
||||
|
||||
$this->assertEquals('The response body', $symfonyResponse->getContent());
|
||||
$this->assertEquals(200, $symfonyResponse->getStatusCode());
|
||||
}
|
||||
}
|
39
vendor/symfony/psr-http-message-bridge/Tests/Factory/PsrHttpFactoryTest.php
vendored
Normal file
39
vendor/symfony/psr-http-message-bridge/Tests/Factory/PsrHttpFactoryTest.php
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Tests\Factory;
|
||||
|
||||
use Http\Factory\Diactoros\ResponseFactory;
|
||||
use Http\Factory\Diactoros\ServerRequestFactory;
|
||||
use Http\Factory\Diactoros\StreamFactory;
|
||||
use Http\Factory\Diactoros\UploadedFileFactory;
|
||||
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
* @author Antonio J. García Lagar <aj@garcialagar.es>
|
||||
*/
|
||||
class PsrHttpFactoryTest extends AbstractHttpMessageFactoryTest
|
||||
{
|
||||
protected function buildHttpMessageFactory()
|
||||
{
|
||||
if (!class_exists('Http\Factory\Diactoros\ServerRequestFactory')) {
|
||||
$this->markTestSkipped('HTTP Factory for Diactoros is not installed.');
|
||||
}
|
||||
|
||||
return new PsrHttpFactory(
|
||||
new ServerRequestFactory(),
|
||||
new StreamFactory(),
|
||||
new UploadedFileFactory(),
|
||||
new ResponseFactory()
|
||||
);
|
||||
}
|
||||
}
|
89
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Message.php
vendored
Normal file
89
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Message.php
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
|
||||
|
||||
use Psr\Http\Message\MessageInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
* Message.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class Message implements MessageInterface
|
||||
{
|
||||
private $version = '1.1';
|
||||
private $headers = array();
|
||||
private $body;
|
||||
|
||||
public function __construct($version = '1.1', array $headers = array(), StreamInterface $body = null)
|
||||
{
|
||||
$this->version = $version;
|
||||
$this->headers = $headers;
|
||||
$this->body = null === $body ? new Stream() : $body;
|
||||
}
|
||||
|
||||
public function getProtocolVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
public function withProtocolVersion($version)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
public function hasHeader($name)
|
||||
{
|
||||
return isset($this->headers[$name]);
|
||||
}
|
||||
|
||||
public function getHeader($name)
|
||||
{
|
||||
return $this->hasHeader($name) ? $this->headers[$name] : array();
|
||||
}
|
||||
|
||||
public function getHeaderLine($name)
|
||||
{
|
||||
return $this->hasHeader($name) ? implode(',', $this->headers[$name]) : '';
|
||||
}
|
||||
|
||||
public function withHeader($name, $value)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function withAddedHeader($name, $value)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function withoutHeader($name)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
public function withBody(StreamInterface $body)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
}
|
45
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Response.php
vendored
Normal file
45
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Response.php
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class Response extends Message implements ResponseInterface
|
||||
{
|
||||
private $statusCode;
|
||||
|
||||
public function __construct($version = '1.1', array $headers = array(), StreamInterface $body = null, $statusCode = 200)
|
||||
{
|
||||
parent::__construct($version, $headers, $body);
|
||||
|
||||
$this->statusCode = $statusCode;
|
||||
}
|
||||
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
public function withStatus($code, $reasonPhrase = '')
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function getReasonPhrase()
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
}
|
141
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/ServerRequest.php
vendored
Normal file
141
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/ServerRequest.php
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class ServerRequest extends Message implements ServerRequestInterface
|
||||
{
|
||||
private $requestTarget;
|
||||
private $method;
|
||||
private $uri;
|
||||
private $server;
|
||||
private $cookies;
|
||||
private $query;
|
||||
private $uploadedFiles;
|
||||
private $data;
|
||||
private $attributes;
|
||||
|
||||
public function __construct($version = '1.1', array $headers = array(), StreamInterface $body = null, $requestTarget = '/', $method = 'GET', $uri = null, array $server = array(), array $cookies = array(), array $query = array(), array $uploadedFiles = array(), $data = null, array $attributes = array())
|
||||
{
|
||||
parent::__construct($version, $headers, $body);
|
||||
|
||||
$this->requestTarget = $requestTarget;
|
||||
$this->method = $method;
|
||||
$this->uri = $uri;
|
||||
$this->server = $server;
|
||||
$this->cookies = $cookies;
|
||||
$this->query = $query;
|
||||
$this->uploadedFiles = $uploadedFiles;
|
||||
$this->data = $data;
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
public function getRequestTarget()
|
||||
{
|
||||
return $this->requestTarget;
|
||||
}
|
||||
|
||||
public function withRequestTarget($requestTarget)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
public function withMethod($method)
|
||||
{
|
||||
}
|
||||
|
||||
public function getUri()
|
||||
{
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
public function withUri(UriInterface $uri, $preserveHost = false)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function getServerParams()
|
||||
{
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
public function getCookieParams()
|
||||
{
|
||||
return $this->cookies;
|
||||
}
|
||||
|
||||
public function withCookieParams(array $cookies)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function getQueryParams()
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
public function withQueryParams(array $query)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function getUploadedFiles()
|
||||
{
|
||||
return $this->uploadedFiles;
|
||||
}
|
||||
|
||||
public function withUploadedFiles(array $uploadedFiles)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function getParsedBody()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function withParsedBody($data)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function getAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
public function getAttribute($name, $default = null)
|
||||
{
|
||||
return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
|
||||
}
|
||||
|
||||
public function withAttribute($name, $value)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function withoutAttribute($name)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
}
|
95
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php
vendored
Normal file
95
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class Stream implements StreamInterface
|
||||
{
|
||||
private $stringContent;
|
||||
|
||||
public function __construct($stringContent = '')
|
||||
{
|
||||
$this->stringContent = $stringContent;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->stringContent;
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
}
|
||||
|
||||
public function detach()
|
||||
{
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
}
|
||||
|
||||
public function tell()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function eof()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isSeekable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function seek($offset, $whence = SEEK_SET)
|
||||
{
|
||||
}
|
||||
|
||||
public function rewind()
|
||||
{
|
||||
}
|
||||
|
||||
public function isWritable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function write($string)
|
||||
{
|
||||
}
|
||||
|
||||
public function isReadable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function read($length)
|
||||
{
|
||||
return $this->stringContent;
|
||||
}
|
||||
|
||||
public function getContents()
|
||||
{
|
||||
return $this->stringContent;
|
||||
}
|
||||
|
||||
public function getMetadata($key = null)
|
||||
{
|
||||
}
|
||||
}
|
65
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/UploadedFile.php
vendored
Normal file
65
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/UploadedFile.php
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
|
||||
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class UploadedFile implements UploadedFileInterface
|
||||
{
|
||||
private $filePath;
|
||||
private $size;
|
||||
private $error;
|
||||
private $clientFileName;
|
||||
private $clientMediaType;
|
||||
|
||||
public function __construct($filePath, $size = null, $error = UPLOAD_ERR_OK, $clientFileName = null, $clientMediaType = null)
|
||||
{
|
||||
$this->filePath = $filePath;
|
||||
$this->size = $size;
|
||||
$this->error = $error;
|
||||
$this->clientFileName = $clientFileName;
|
||||
$this->clientMediaType = $clientMediaType;
|
||||
}
|
||||
|
||||
public function getStream()
|
||||
{
|
||||
throw new \RuntimeException('No stream is available.');
|
||||
}
|
||||
|
||||
public function moveTo($targetPath)
|
||||
{
|
||||
rename($this->filePath, $targetPath);
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getClientFilename()
|
||||
{
|
||||
return $this->clientFileName;
|
||||
}
|
||||
|
||||
public function getClientMediaType()
|
||||
{
|
||||
return $this->clientMediaType;
|
||||
}
|
||||
}
|
135
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Uri.php
vendored
Normal file
135
vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Uri.php
vendored
Normal file
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Tests\Fixtures;
|
||||
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
* @author Rougin Royce Gutib <rougingutib@gmail.com>
|
||||
*/
|
||||
class Uri implements UriInterface
|
||||
{
|
||||
private $scheme = '';
|
||||
private $userInfo = '';
|
||||
private $host = '';
|
||||
private $port;
|
||||
private $path = '';
|
||||
private $query = '';
|
||||
private $fragment = '';
|
||||
private $uriString;
|
||||
|
||||
public function __construct($uri = '')
|
||||
{
|
||||
$parts = parse_url($uri);
|
||||
|
||||
$this->scheme = isset($parts['scheme']) ? $parts['scheme'] : '';
|
||||
$this->userInfo = isset($parts['user']) ? $parts['user'] : '';
|
||||
$this->host = isset($parts['host']) ? $parts['host'] : '';
|
||||
$this->port = isset($parts['port']) ? $parts['port'] : null;
|
||||
$this->path = isset($parts['path']) ? $parts['path'] : '';
|
||||
$this->query = isset($parts['query']) ? $parts['query'] : '';
|
||||
$this->fragment = isset($parts['fragment']) ? $parts['fragment'] : '';
|
||||
$this->uriString = $uri;
|
||||
}
|
||||
|
||||
public function getScheme()
|
||||
{
|
||||
return $this->scheme;
|
||||
}
|
||||
|
||||
public function getAuthority()
|
||||
{
|
||||
if (empty($this->host)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$authority = $this->host;
|
||||
|
||||
if (!empty($this->userInfo)) {
|
||||
$authority = $this->userInfo.'@'.$authority;
|
||||
}
|
||||
|
||||
$authority .= ':'.$this->port;
|
||||
|
||||
return $authority;
|
||||
}
|
||||
|
||||
public function getUserInfo()
|
||||
{
|
||||
return $this->userInfo;
|
||||
}
|
||||
|
||||
public function getHost()
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
public function getPort()
|
||||
{
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function getQuery()
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
public function getFragment()
|
||||
{
|
||||
return $this->fragment;
|
||||
}
|
||||
|
||||
public function withScheme($scheme)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function withUserInfo($user, $password = null)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function withHost($host)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function withPort($port)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function withPath($path)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function withQuery($query)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function withFragment($fragment)
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented.');
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->uriString;
|
||||
}
|
||||
}
|
Reference in a new issue