Skip to content

Commit

Permalink
fix: test factory initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ikkez committed Jan 3, 2025
1 parent 542fba2 commit 6d25776
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Http\Psr7Test;

use F3\Http\Factory\Psr17Factory as FatfreeFactory;
use GuzzleHttp\Psr7\Stream as GuzzleStream;
use GuzzleHttp\Psr7\UploadedFile as GuzzleUploadedFile;
use GuzzleHttp\Psr7\Uri as GuzzleUri;
Expand Down Expand Up @@ -84,6 +85,10 @@ protected function buildUri($uri)
return new RingCentralUri($uri);
}

if (class_exists(FatfreeFactory::class)) {
return (new FatfreeFactory())->createUri($uri);
}

throw new \RuntimeException('Could not create URI. Check your config');
}

Expand Down Expand Up @@ -123,6 +128,9 @@ protected function buildStream($data)
if (class_exists(SlimStreamFactory::class)) {
$factory = new SlimStreamFactory();
}
if (class_exists(FatfreeFactory::class)) {
$factory = new FatfreeFactory();
}
if ($factory) {
if (is_string($data)) {
return $factory->createStream($data);
Expand Down Expand Up @@ -176,6 +184,12 @@ protected function buildUploadableFile($data)
return (new SlimUploadedFileFactory())->createUploadedFile($stream);
}

if (class_exists(FatfreeFactory::class)) {
$stream = $this->buildStream($data);

return (new FatfreeFactory())->createUploadedFile($stream);
}

throw new \RuntimeException('Could not create Stream. Check your config');
}
}

0 comments on commit 6d25776

Please sign in to comment.