Completed
Branch master (ffbd82)
by Nikola
14:42 queued 12:20
created

UnderscoredClassNamespacePrefixTest::blacklisted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
rs 9.4286
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of the Doctrine Naming Strategy Bundle, an RunOpenCode project.
4
 *
5
 * (c) 2015 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace RunOpenCode\Bundle\DoctrineNamingStrategy\Tests\NamingStrategy;
11
12
use RunOpenCode\Bundle\DoctrineNamingStrategy\NamingStrategy\UnderscoredClassNamespacePrefix;
13
14
class UnderscoredClassNamespacePrefixTest extends \PHPUnit_Framework_TestCase
15
{
16
    /**
17
     * @test
18
     */
19
    public function classToTableNameLowercase()
20
    {
21
        $strategy = new UnderscoredClassNamespacePrefix(array(
22
            'map' => array(
23
                'RunOpenCode\\Bundle\\TestNamespace\\Entity' => 'my_prefix'
24
            )
25
        ));
26
27
        $this->assertSame('my_prefix_some_entity', $strategy->classToTableName('RunOpenCode\\Bundle\\TestNamespace\\Entity\\SomeEntity'));
28
    }
29
30
    /**
31
     * @test
32
     */
33
    public function classToTableNameUppercase()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        $strategy = new UnderscoredClassNamespacePrefix(array(
36
            'map' => array(
37
                'RunOpenCode\\Bundle\\TestNamespace\\Entity' => 'my_prefix'
38
            ),
39
            'case' => CASE_UPPER
40
        ));
41
42
        $this->assertSame('MY_PREFIX_SOME_ENTITY', $strategy->classToTableName('RunOpenCode\\Bundle\\TestNamespace\\Entity\\SomeEntity'));
43
    }
44
45
    /**
46
     * @test
47
     *
48
     * @expectedException \RuntimeException
49
     */
50
    public function invalidConfiguration()
51
    {
52
        $strategy = new UnderscoredClassNamespacePrefix(array(
0 ignored issues
show
Unused Code introduced by
$strategy is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
53
            'map' => array(
54
                'RunOpenCode\\Bundle\\TestNamespace\\Entity' => 'my_prefix'
55
            ),
56
            'blacklist' => array(
57
                'Test\\Bundle'
58
            ),
59
            'whitelist' => array(
60
                'Test\\Bundle2'
61
            )
62
        ));
63
    }
64
65
    /**
66
     * @test
67
     */
68
    public function blacklisted()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
    {
70
        $strategy = new UnderscoredClassNamespacePrefix(array(
71
            'map' => array(
72
                'RunOpenCode\\Bundle\\TestNamespace\\Entity' => 'my_prefix'
73
            ),
74
            'blacklist' => array(
75
                'RunOpenCode\\Bundle'
76
            )
77
        ));
78
79
        $this->assertSame('some_entity', $strategy->classToTableName('RunOpenCode\\Bundle\\DoctrineNamingStrategy\\Entity\\SomeEntity'));
80
    }
81
82
    /**
83
     * @test
84
     */
85
    public function whitelisted()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
86
    {
87
        $strategy = new UnderscoredClassNamespacePrefix(array(
88
            'map' => array(
89
                'RunOpenCode\\Bundle\\TestNamespace\\Entity' => 'my_prefix'
90
            ),
91
            'whitelist' => array(
92
                'Test\\Bundle2'
93
            )
94
        ));
95
96
        $this->assertSame('some_entity', $strategy->classToTableName('RunOpenCode\\Bundle\\DoctrineNamingStrategy\\Entity\\SomeEntity'));
97
    }
98
}
99