Skip to content

Commit

Permalink
Remove Prophecy
Browse files Browse the repository at this point in the history
Signed-off-by: Tamás András Horváth <[email protected]>
  • Loading branch information
icetee committed Sep 9, 2021
1 parent 4428cea commit e469faa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/File/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ public function addFile($file)
}
}

if ($file instanceof UploadedFileInterface) {
$this->files[$file->getClientFilename()] = $file->getClientFilename();
if ($file instanceof UploadedFileInterface && is_string($file->getClientFilename())) {
$this->files[(string) $file->getClientFilename()] = $file->getClientFilename();
}

return $this;
Expand Down
27 changes: 6 additions & 21 deletions test/File/CountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,16 @@
use Laminas\Validator\Exception\InvalidArgumentException;
use Laminas\Validator\File;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileInterface;
use ReflectionClass;

use function basename;

/**
* @group Laminas_Validator
*/
class CountTest extends TestCase
{
/** @var ObjectProphecy|StreamInterface */
public $stream;

/** @var ObjectProphecy */
public $upload;

protected function setUp(): void
{
$this->stream = $this->prophesize(StreamInterface::class);
$this->upload = $this->prophesize(UploadedFileInterface::class);
}

/**
* Ensures that the validator follows expected behavior
*
Expand Down Expand Up @@ -254,14 +241,12 @@ public function testPsr7FileTypes(): void
{
$testFile = __DIR__ . '/_files/testsize.mo';

$this->stream->getMetadata('uri')->willReturn($testFile);
$this->upload->getClientFilename()->willReturn(basename($testFile));
$this->upload->getClientMediaType()->willReturn(mime_content_type($testFile));
$this->upload->getStream()->willReturn($this->stream->reveal());
$upload = $this->createMock(UploadedFileInterface::class);
$upload->method('getClientFilename')->willReturn(basename($testFile));

$validator = new File\Count(['min' => 1]);

$this->assertSame(true, $validator->isValid($this->upload->reveal()));
$this->assertSame(true, $validator->isValid($this->upload->reveal(), []));
$this->assertSame(true, $validator->isValid($upload));
$this->assertSame(true, $validator->isValid($upload, []));
}
}

0 comments on commit e469faa

Please sign in to comment.