the middle of the idiots
This commit is contained in:
57
qwen/php/vendor/slim/psr7/tests/Integration/BaseTestFactories.php
vendored
Normal file
57
qwen/php/vendor/slim/psr7/tests/Integration/BaseTestFactories.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Slim Framework (https://slimframework.com)
|
||||
*
|
||||
* @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Slim\Tests\Psr7\Integration;
|
||||
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Slim\Psr7\Factory\UriFactory;
|
||||
use Slim\Psr7\Stream;
|
||||
use Slim\Psr7\UploadedFile;
|
||||
|
||||
use function fopen;
|
||||
use function fwrite;
|
||||
use function is_resource;
|
||||
|
||||
trait BaseTestFactories
|
||||
{
|
||||
/**
|
||||
* @param string $uri
|
||||
* @return UriInterface
|
||||
*/
|
||||
protected function buildUri($uri): UriInterface
|
||||
{
|
||||
return (new UriFactory())->createUri($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return Stream
|
||||
*/
|
||||
protected function buildStream($data): Stream
|
||||
{
|
||||
if (!is_resource($data)) {
|
||||
$h = fopen('php://temp', 'w+');
|
||||
fwrite($h, $data);
|
||||
|
||||
$data = $h;
|
||||
}
|
||||
|
||||
return new Stream($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return UploadedFile
|
||||
*/
|
||||
protected function buildUploadableFile($data): UploadedFile
|
||||
{
|
||||
return new UploadedFile($this->buildStream($data));
|
||||
}
|
||||
}
|
||||
36
qwen/php/vendor/slim/psr7/tests/Integration/RequestTest.php
vendored
Normal file
36
qwen/php/vendor/slim/psr7/tests/Integration/RequestTest.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Slim Framework (https://slimframework.com)
|
||||
*
|
||||
* @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Slim\Tests\Psr7\Integration;
|
||||
|
||||
use Http\Psr7Test\RequestIntegrationTest;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Slim\Psr7\Headers;
|
||||
use Slim\Psr7\Request;
|
||||
|
||||
class RequestTest extends RequestIntegrationTest
|
||||
{
|
||||
use BaseTestFactories;
|
||||
|
||||
/**
|
||||
* @return RequestInterface that is used in the tests
|
||||
*/
|
||||
public function createSubject(): RequestInterface
|
||||
{
|
||||
return new Request(
|
||||
'GET',
|
||||
$this->buildUri('/'),
|
||||
new Headers(),
|
||||
[],
|
||||
[],
|
||||
$this->buildStream('')
|
||||
);
|
||||
}
|
||||
}
|
||||
27
qwen/php/vendor/slim/psr7/tests/Integration/ResponseTest.php
vendored
Normal file
27
qwen/php/vendor/slim/psr7/tests/Integration/ResponseTest.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Slim Framework (https://slimframework.com)
|
||||
*
|
||||
* @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Slim\Tests\Psr7\Integration;
|
||||
|
||||
use Http\Psr7Test\ResponseIntegrationTest;
|
||||
use Slim\Psr7\Response;
|
||||
|
||||
class ResponseTest extends ResponseIntegrationTest
|
||||
{
|
||||
use BaseTestFactories;
|
||||
|
||||
/**
|
||||
* @return Response that is used in the tests
|
||||
*/
|
||||
public function createSubject(): Response
|
||||
{
|
||||
return new Response();
|
||||
}
|
||||
}
|
||||
35
qwen/php/vendor/slim/psr7/tests/Integration/ServerRequestTest.php
vendored
Normal file
35
qwen/php/vendor/slim/psr7/tests/Integration/ServerRequestTest.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Slim Framework (https://slimframework.com)
|
||||
*
|
||||
* @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Slim\Tests\Psr7\Integration;
|
||||
|
||||
use Http\Psr7Test\ServerRequestIntegrationTest;
|
||||
use Slim\Psr7\Headers;
|
||||
use Slim\Psr7\Request;
|
||||
|
||||
class ServerRequestTest extends ServerRequestIntegrationTest
|
||||
{
|
||||
use BaseTestFactories;
|
||||
|
||||
/**
|
||||
* @return Request
|
||||
*/
|
||||
public function createSubject(): Request
|
||||
{
|
||||
return new Request(
|
||||
'GET',
|
||||
$this->buildUri('/'),
|
||||
new Headers(),
|
||||
$_COOKIE,
|
||||
$_SERVER,
|
||||
$this->buildStream('')
|
||||
);
|
||||
}
|
||||
}
|
||||
46
qwen/php/vendor/slim/psr7/tests/Integration/StreamTest.php
vendored
Normal file
46
qwen/php/vendor/slim/psr7/tests/Integration/StreamTest.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Slim Framework (https://slimframework.com)
|
||||
*
|
||||
* @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Slim\Tests\Psr7\Integration;
|
||||
|
||||
use Http\Psr7Test\StreamIntegrationTest;
|
||||
use InvalidArgumentException;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Slim\Psr7\Stream;
|
||||
|
||||
use function fopen;
|
||||
use function fwrite;
|
||||
use function is_resource;
|
||||
use function is_string;
|
||||
|
||||
class StreamTest extends StreamIntegrationTest
|
||||
{
|
||||
use BaseTestFactories;
|
||||
|
||||
/**
|
||||
* @param string|resource|StreamInterface $data
|
||||
*
|
||||
* @return StreamInterface
|
||||
*/
|
||||
public function createStream($data)
|
||||
{
|
||||
if ($data instanceof StreamInterface) {
|
||||
return $data;
|
||||
} elseif (is_resource($data)) {
|
||||
return new Stream($data);
|
||||
} elseif (is_string($data)) {
|
||||
$s = fopen('php://temp', 'w+');
|
||||
fwrite($s, $data);
|
||||
return new Stream($s);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException();
|
||||
}
|
||||
}
|
||||
51
qwen/php/vendor/slim/psr7/tests/Integration/UploadedFileTest.php
vendored
Normal file
51
qwen/php/vendor/slim/psr7/tests/Integration/UploadedFileTest.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Slim Framework (https://slimframework.com)
|
||||
*
|
||||
* @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Slim\Tests\Psr7\Integration;
|
||||
|
||||
use Http\Psr7Test\UploadedFileIntegrationTest;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Slim\Psr7\UploadedFile;
|
||||
|
||||
use function sys_get_temp_dir;
|
||||
use function tempnam;
|
||||
|
||||
class UploadedFileTest extends UploadedFileIntegrationTest
|
||||
{
|
||||
use BaseTestFactories;
|
||||
|
||||
protected string $tempFilename;
|
||||
|
||||
/**
|
||||
* @return UploadedFileInterface
|
||||
*/
|
||||
public function createSubject()
|
||||
{
|
||||
$this->tempFilename = tempnam(sys_get_temp_dir(), 'Slim_Http_UploadedFileTest_');
|
||||
if (!$this->tempFilename) {
|
||||
throw new \RuntimeException("Unable to create temporary file");
|
||||
}
|
||||
file_put_contents($this->tempFilename, '12345');
|
||||
|
||||
return new UploadedFile(
|
||||
$this->tempFilename,
|
||||
basename($this->tempFilename),
|
||||
'text/plain',
|
||||
(int)filesize($this->tempFilename)
|
||||
);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (is_file($this->tempFilename)) {
|
||||
unlink($this->tempFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
qwen/php/vendor/slim/psr7/tests/Integration/UriTest.php
vendored
Normal file
30
qwen/php/vendor/slim/psr7/tests/Integration/UriTest.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Slim Framework (https://slimframework.com)
|
||||
*
|
||||
* @license https://github.com/slimphp/Slim-Psr7/blob/master/LICENSE.md (MIT License)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Slim\Tests\Psr7\Integration;
|
||||
|
||||
use Http\Psr7Test\UriIntegrationTest;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Slim\Psr7\Factory\UriFactory;
|
||||
|
||||
class UriTest extends UriIntegrationTest
|
||||
{
|
||||
use BaseTestFactories;
|
||||
|
||||
/**
|
||||
* @param string $uri
|
||||
*
|
||||
* @return UriInterface
|
||||
*/
|
||||
public function createUri($uri): UriInterface
|
||||
{
|
||||
return (new UriFactory())->createUri($uri);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user