1 | <?php |
||
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() |
||
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 | new UnderscoredClassNamespacePrefix(array( |
||
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() |
||
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() |
||
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 |