|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace EcodevTests\Felix\Api\Scalar; |
|
6
|
|
|
|
|
7
|
|
|
use Cake\Chronos\ChronosTime; |
|
|
|
|
|
|
8
|
|
|
use Ecodev\Felix\Api\Scalar\TimeType; |
|
9
|
|
|
use GraphQL\Language\AST\IntValueNode; |
|
10
|
|
|
use GraphQL\Language\AST\StringValueNode; |
|
11
|
|
|
use PHPUnit\Framework\TestCase; |
|
12
|
|
|
|
|
13
|
|
|
final class TimeTypeTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
public function testSerialize(): void |
|
16
|
|
|
{ |
|
17
|
|
|
$type = new TimeType(); |
|
18
|
|
|
$time = new ChronosTime('14:30:25'); |
|
19
|
|
|
$actual = $type->serialize($time); |
|
20
|
|
|
self::assertSame('14:30:25.000000', $actual); |
|
21
|
|
|
|
|
22
|
|
|
// Test serialize with microseconds |
|
23
|
|
|
$time = new ChronosTime('23:59:59.1254'); |
|
24
|
|
|
$actual = $type->serialize($time); |
|
25
|
|
|
self::assertSame('23:59:59.001254', $actual); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @dataProvider providerValues |
|
30
|
|
|
*/ |
|
31
|
|
|
public function testParseLiteral(string $input, ?string $expected): void |
|
32
|
|
|
{ |
|
33
|
|
|
$type = new TimeType(); |
|
34
|
|
|
$ast = new StringValueNode(['value' => $input]); |
|
35
|
|
|
|
|
36
|
|
|
$actual = $type->parseLiteral($ast); |
|
37
|
|
|
self::assertInstanceOf(ChronosTime::class, $actual); |
|
38
|
|
|
self::assertSame($expected, $actual->format('H:i:s.u')); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testParseLiteralAsInt(): void |
|
42
|
|
|
{ |
|
43
|
|
|
$type = new TimeType(); |
|
44
|
|
|
$ast = new IntValueNode(['value' => '123']); |
|
45
|
|
|
|
|
46
|
|
|
$this->expectExceptionMessage('Query error: Can only parse strings got: IntValue'); |
|
47
|
|
|
$type->parseLiteral($ast); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public static function providerValues(): array |
|
51
|
|
|
{ |
|
52
|
|
|
return [ |
|
53
|
|
|
'normal timr' => ['14:30:25', '14:30:25.000000'], |
|
54
|
|
|
'time with milliseconds' => ['23:45:13.300', '23:45:13.000300'], |
|
55
|
|
|
]; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths