1 | <?php |
||
13 | class ObjectUtilitiesTest extends \PHPUnit_Framework_TestCase |
||
14 | { |
||
15 | /** |
||
16 | * {@inheritDoc} |
||
17 | */ |
||
18 | public function setUp() |
||
27 | |||
28 | /** |
||
29 | * Test that a ReflectionClass is returned when a valid class name is provided |
||
30 | */ |
||
31 | public function testGetReflectionClass() |
||
35 | |||
36 | /** |
||
37 | * Test that ReflectionExceptions are handled gracefully for non existent classes |
||
38 | */ |
||
39 | public function testGetReflectionHandlesMissingClassesGracefully() |
||
43 | |||
44 | /** |
||
45 | * Test that a composer configured module name is returned for a valid SilverStripe module |
||
46 | */ |
||
47 | public function testGetModuleNameForValidClass() |
||
51 | |||
52 | /** |
||
53 | * Test that an empty string is returned gracefully if a module cannot be found |
||
54 | */ |
||
55 | public function testReturnEmptyStringWhenModuleNameCantBeFound() |
||
59 | |||
60 | /** |
||
61 | * Ensure that the project name can be retrieved from its composer configuration, and if it's the $project (mysite) |
||
62 | * then use the root directory composer.json |
||
63 | * |
||
64 | * @dataProvider composerConfigurationProvider |
||
65 | */ |
||
66 | public function testGetModuleNameFromComposerConfiguration($projectName, $folderName, $expected) |
||
72 | |||
73 | /** |
||
74 | * @return array[] |
||
75 | */ |
||
76 | public function composerConfigurationProvider() |
||
83 | |||
84 | /** |
||
85 | * Test that when an invalid class is passed to getModuleName it will return a blank string |
||
86 | */ |
||
87 | public function testGetModuleNameFromInvalidClassReturnsEmptyString() |
||
91 | |||
92 | /** |
||
93 | * Test that when the module's folder name is empty or missing, a blank string is returned |
||
94 | */ |
||
95 | public function testEmptyFolderNameInPathReturnsEmptyString() |
||
120 | |||
121 | /** |
||
122 | * Test that an unreadable composer file will return an empty array |
||
123 | */ |
||
124 | public function testHandleUnreadableComposerFile() |
||
131 | |||
132 | /** |
||
133 | * Test that when composer.json is empty an empty array is returned |
||
134 | */ |
||
135 | public function testEmptyComposerFile() |
||
143 | |||
144 | /** |
||
145 | * Test that if no composer.json file exists, an empty array is returned |
||
146 | */ |
||
147 | public function testHandleMissingComposerFile() |
||
151 | } |
||
152 |
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