1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 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 PHPUnit\Framework\TestCase as StreamIntegrationTest;
//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;
/**
* @group excluded
*/
#[\PHPUnit\Framework\Attributes\Group('excluded')]
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();
}
}
|