respect-validation/tests/unit/Rules/FileTest.php
Henrique Moody 9a13c9fb03
Update coding standards
This change will bring many breaking changes. The good thing is that we
can finally use more modern resources available in PHP.

I can imagine that's not a popular change since it will bring many
breaking changes to users, but we shouldn't be stuck in time because of
that. Using some of those features will make it easier to contribute to
the project. At least, I hope so.

There are still some useless doc-blocks, and we're not using "readonly"
properties when we could. I aim to send those changes soon.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-28 00:22:41 +01:00

57 lines
1.3 KiB
PHP

<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use Respect\Validation\Test\RuleTestCase;
use SplFileInfo;
use SplFileObject;
use stdClass;
use const PHP_INT_MAX;
/**
* @group rule
* @covers \Respect\Validation\Rules\File
*/
final class FileTest extends RuleTestCase
{
/**
* @return array<array{File, mixed}>
*/
public static function providerForValidInput(): array
{
$sut = new File();
return [
'filename' => [$sut, __FILE__],
'SplFileInfo' => [$sut, new SplFileInfo(self::fixture('valid-image.png'))],
'SplFileObject' => [$sut, new SplFileObject(self::fixture('invalid-image.png'))],
];
}
/**
* @return array<array{File, mixed}>
*/
public static function providerForInvalidInput(): array
{
$sut = new File();
return [
'directory' => [$sut, __DIR__],
'object' => [$sut, new stdClass()],
'array' => [$sut, []],
'invalid filename' => [$sut, 'not-a-file-at-all'],
'integer' => [$sut, PHP_INT_MAX],
'float' => [$sut, 1.222],
'boolean true' => [$sut, true],
'boolean false' => [$sut, false],
];
}
}