Passed
Push — master ( 29344f...675168 )
by Paweł
03:21 queued 12s
created

testResolvesPropertyValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gorynych\Tests\Testing;
6
7
use Faker\Factory;
8
use Gorynych\Testing\FakerValueResolver;
9
use Gorynych\Tests\Testing\Resource\TestObject;
10
use PHPUnit\Framework\TestCase;
11
12
class FakerValueResolverTest extends TestCase
13
{
14
    /**
15
     * @dataProvider provideProperties
16
     */
17
    public function testResolvesPropertyValue(\ReflectionProperty $reflectionProperty, string $expectedType): void
18
    {
19
        $value = (new FakerValueResolver(Factory::create()))->resolvePropertyValue($reflectionProperty);
20
21
        $assertionName = 'assertIs' . ucfirst($expectedType);
22
        $this->{$assertionName}($value);
23
    }
24
25
    /**
26
     * @return \Generator<array>
27
     */
28
    public function provideProperties(): \Generator
29
    {
30
        yield 'string' => [
31
            new \ReflectionProperty(TestObject::class, 'foo'),
32
            'string',
33
        ];
34
35
        yield 'int' => [
36
            new \ReflectionProperty(TestObject::class, 'bar'),
37
            'int',
38
        ];
39
40
        yield 'bool' => [
41
            new \ReflectionProperty(TestObject::class, 'baz'),
42
            'bool',
43
        ];
44
45
        yield 'datetime' => [
46
            new \ReflectionProperty(TestObject::class, 'date'),
47
            'string',
48
        ];
49
    }
50
}
51