AbstractWriterConfigTest::testGetClassPrefix()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Janisbiz\LightOrm\Tests\Unit\Generator\Writer;
4
5
use Janisbiz\LightOrm\Generator\Writer\AbstractWriterConfig;
6
use PHPUnit\Framework\TestCase;
7
8
class AbstractWriterConfigTest extends TestCase
9
{
10
    const DIRECTORY_VALUE = JANISBIZ_LIGHT_ORM_ROOT_DIR
11
        . 'var'
12
        . DIRECTORY_SEPARATOR
13
        . 'light-orm'
14
        . DIRECTORY_SEPARATOR
15
        . 'phpunit'
16
        . DIRECTORY_SEPARATOR
17
    ;
18
    const DIRECTORY_VALUE_EXPECTED = JANISBIZ_LIGHT_ORM_ROOT_DIR
19
        . 'var'
20
        . DIRECTORY_SEPARATOR
21
        . 'light-orm'
22
        . DIRECTORY_SEPARATOR
23
        . 'phpunit'
24
    ;
25
26
    const NAMESPACE_VALUE = 'This\Is\A\Namespace\\';
27
    const NAMESPACE_VALUE_EXPECTED = 'This\Is\A\Namespace';
28
29
    const CLASS_PREFIX_VALUE = ' classPrefix ';
30
    const CLASS_PREFIX_VALUE_EXPECTED = 'Classprefix';
31
32
    const CLASS_SUFFIX_VALUE = ' classSuffix ';
33
    const CLASS_SUFFIX_VALUE_EXPECTED = 'Classsuffix';
34
35
    /**
36
     * @var AbstractWriterConfig
37
     */
38
    private $abstractWriterConfig;
39
40
    public function setUp()
41
    {
42
        $this->abstractWriterConfig = $this->getMockForAbstractClass(AbstractWriterConfig::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockForAbstrac...actWriterConfig::class) of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type Janisbiz\LightOrm\Genera...er\AbstractWriterConfig of property $abstractWriterConfig.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
43
        $abstractWriterConfigReflection = new \ReflectionClass($this->abstractWriterConfig);
44
45
        $directoryProperty = $abstractWriterConfigReflection->getProperty('directory');
46
        $directoryProperty->setAccessible(true);
47
        $directoryProperty->setValue($this->abstractWriterConfig, static::DIRECTORY_VALUE);
48
49
        $namespaceProperty = $abstractWriterConfigReflection->getProperty('namespace');
50
        $namespaceProperty->setAccessible(true);
51
        $namespaceProperty->setValue($this->abstractWriterConfig, static::NAMESPACE_VALUE);
52
53
        $classPrefixProperty = $abstractWriterConfigReflection->getProperty('classPrefix');
54
        $classPrefixProperty->setAccessible(true);
55
        $classPrefixProperty->setValue($this->abstractWriterConfig, static::CLASS_PREFIX_VALUE);
56
57
        $classSuffixProperty = $abstractWriterConfigReflection->getProperty('classSuffix');
58
        $classSuffixProperty->setAccessible(true);
59
        $classSuffixProperty->setValue($this->abstractWriterConfig, static::CLASS_SUFFIX_VALUE);
60
    }
61
62
    public function testGetDirectory()
63
    {
64
        $this->assertEquals($this->abstractWriterConfig->getDirectory(), static::DIRECTORY_VALUE_EXPECTED);
65
    }
66
67
    public function testGetNamespace()
68
    {
69
        $this->assertEquals($this->abstractWriterConfig->getNamespace(), static::NAMESPACE_VALUE_EXPECTED);
70
    }
71
72
    public function testGetClassPrefix()
73
    {
74
        $this->assertEquals($this->abstractWriterConfig->getClassPrefix(), static::CLASS_PREFIX_VALUE_EXPECTED);
75
    }
76
77
    public function testGetClassSuffix()
78
    {
79
        $this->assertEquals($this->abstractWriterConfig->getClassSuffix(), static::CLASS_SUFFIX_VALUE_EXPECTED);
80
    }
81
}
82