1 | <?php |
||
14 | class ObjectUtilitiesTest extends \PHPUnit_Framework_TestCase |
||
15 | { |
||
16 | /** |
||
17 | * {@inheritDoc} |
||
18 | */ |
||
19 | public function setUp() |
||
31 | |||
32 | /** |
||
33 | * Test that a ReflectionClass is returned when a valid class name is provided |
||
34 | */ |
||
35 | public function testGetReflectionClass() |
||
39 | |||
40 | /** |
||
41 | * Test that ReflectionExceptions are handled gracefully for non existent classes |
||
42 | */ |
||
43 | public function testGetReflectionHandlesMissingClassesGracefully() |
||
47 | |||
48 | /** |
||
49 | * Test that a composer configured module name is returned for a valid SilverStripe module |
||
50 | */ |
||
51 | public function testGetModuleNameForValidClass() |
||
55 | |||
56 | /** |
||
57 | * Test that an empty string is returned gracefully if a module cannot be found |
||
58 | */ |
||
59 | public function testReturnEmptyStringWhenModuleNameCantBeFound() |
||
63 | |||
64 | /** |
||
65 | * Ensure that the project name can be retrieved from its composer configuration, and if it's the $project (mysite) |
||
66 | * then use the root directory composer.json |
||
67 | * |
||
68 | * @dataProvider composerConfigurationProvider |
||
69 | */ |
||
70 | public function testGetModuleNameFromComposerConfiguration($projectName, $folderName, $expected) |
||
76 | |||
77 | /** |
||
78 | * @return array[] |
||
79 | */ |
||
80 | public function composerConfigurationProvider() |
||
87 | |||
88 | /** |
||
89 | * Test that when an invalid class is passed to getModuleName it will return a blank string |
||
90 | */ |
||
91 | public function testGetModuleNameFromInvalidClassReturnsEmptyString() |
||
95 | |||
96 | /** |
||
97 | * Test that when the module's folder name is empty or missing, a blank string is returned |
||
98 | */ |
||
99 | public function testEmptyFolderNameInPathReturnsEmptyString() |
||
124 | |||
125 | /** |
||
126 | * Test that an unreadable composer file will return an empty array |
||
127 | */ |
||
128 | public function testHandleUnreadableComposerFile() |
||
135 | |||
136 | /** |
||
137 | * Test that when composer.json is empty an empty array is returned |
||
138 | */ |
||
139 | public function testEmptyComposerFile() |
||
147 | |||
148 | /** |
||
149 | * Test that if no composer.json file exists, an empty array is returned |
||
150 | */ |
||
151 | public function testHandleMissingComposerFile() |
||
155 | } |
||
156 |
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state