GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#93)
by joseph
71:13 queued 68:42
created

NamespaceHelperTest   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 12
eloc 48
dl 0
loc 97
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testCropSuffixWhereSuffixNotInThere() 0 7 1
A testGetObjectShortName() 0 12 2
A testGetObjectFqn() 0 12 2
A setupBeforeClass() 0 3 1
A testSwapSuffix() 0 8 1
A testGetFakerProviderFqnFromFieldFqn() 0 13 2
A testCropSuffix() 0 7 1
A testGetClassShortName() 0 11 2
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\FakerData\String\BusinessIdentifierCodeFakerData;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\FakerData\String\CountryCodeFakerData;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String\BusinessIdentifierCodeFieldTrait;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String\CountryCodeFieldTrait;
9
use PHPUnit\Framework\TestCase;
10
11
class NamespaceHelperTest extends TestCase
12
{
13
    /**
14
     * @var NamespaceHelper
15
     */
16
    private static $helper;
17
18
    public static function setupBeforeClass()
19
    {
20
        self::$helper = new NamespaceHelper();
21
    }
22
23
    public function testCropSuffix(): void
24
    {
25
        $fqn      = 'FooBar';
26
        $suffix   = 'Bar';
27
        $expected = 'Foo';
28
        $actual   = self::$helper->cropSuffix($fqn, $suffix);
29
        self::assertSame($expected, $actual);
30
    }
31
32
    public function testSwapSuffix(): void
33
    {
34
        $fqn           = 'FooBar';
35
        $currentSuffix = 'Bar';
36
        $newSuffix     = 'Baz';
37
        $expected      = 'FooBaz';
38
        $actual        = self::$helper->swapSuffix($fqn, $currentSuffix, $newSuffix);
39
        self::assertSame($expected, $actual);
40
    }
41
42
    public function testCropSuffixWhereSuffixNotInThere(): void
43
    {
44
        $fqn      = 'FooBar';
45
        $suffix   = 'Cheese';
46
        $expected = 'FooBar';
47
        $actual   = self::$helper->cropSuffix($fqn, $suffix);
48
        self::assertSame($expected, $actual);
49
    }
50
51
    public function testGetObjectShortName(): void
52
    {
53
54
        $expectedToObjects = [
55
            'NamespaceHelperTest' => $this,
56
            'NamespaceHelper'     => self::$helper,
57
        ];
58
        $actual            = [];
59
        foreach ($expectedToObjects as $object) {
60
            $actual[self::$helper->getObjectShortName($object)] = $object;
61
        }
62
        self::assertSame($expectedToObjects, $actual);
63
    }
64
65
    public function testGetObjectFqn(): void
66
    {
67
68
        $expectedToObjects = [
69
            \get_class($this)         => $this,
70
            \get_class(self::$helper) => self::$helper,
71
        ];
72
        $actual            = [];
73
        foreach ($expectedToObjects as $object) {
74
            $actual[self::$helper->getObjectFqn($object)] = $object;
75
        }
76
        self::assertSame($expectedToObjects, $actual);
77
    }
78
79
    public function testGetClassShortName(): void
80
    {
81
        $expectedToFqns = [
82
            'NamespaceHelperTest' => \get_class($this),
83
            'Cheese'              => '\\Super\\Cheese',
84
        ];
85
        $actual         = [];
86
        foreach ($expectedToFqns as $fqn) {
87
            $actual[self::$helper->getClassShortName($fqn)] = $fqn;
88
        }
89
        self::assertSame($expectedToFqns, $actual);
90
    }
91
92
    /**
93
     * @throws \ReflectionException
94
     */
95
    public function testGetFakerProviderFqnFromFieldFqn(): void
96
    {
97
        $expected = [
98
            BusinessIdentifierCodeFieldTrait::class => BusinessIdentifierCodeFakerData::class,
99
            CountryCodeFieldTrait::class            => CountryCodeFakerData::class,
100
        ];
101
        $actual   = [];
102
        foreach (array_keys($expected) as $fieldFqn) {
103
            $actual[$fieldFqn] = self::$helper->getFakerProviderFqnFromFieldTraitReflection(
104
                new \ts\Reflection\ReflectionClass($fieldFqn)
105
            );
106
        }
107
        self::assertSame($expected, $actual);
108
    }
109
}
110