Completed
Push — master ( 5669fc...001759 )
by Matt
02:09
created

testConfigurationTemplateDir()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 30
rs 8.8571
cc 1
eloc 20
nc 1
nop 0
1
<?php
2
3
/**
4
 * Class RealMeSetupTaskTest
5
 * Setup to unit test the Setup task to make sure metadata is being generated correctly.
6
 */
7
class RealMeSetupTaskTest extends SapphireTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    /**
10
     * Valid entity id's tobe used for context.
11
     * @var array
12
     */
13
    private static $validEntityIDs = array(
14
        RealMeService::ENV_MTS => "https://dev.your-website.govt.nz/p-realm/s-name",
15
        RealMeService::ENV_ITE => 'https://uat.your-website.govt.nz/p-realm/s-name',
16
        RealMeService::ENV_PROD => 'https://www.your-website.govt.nz/p-realm/s-name'
17
    );
18
19
    private static $authnEnvContexts = array(
20
        RealMeService::ENV_MTS => 'urn:nzl:govt:ict:stds:authn:deployment:GLS:SAML:2.0:ac:classes:LowStrength',
21
        RealMeService::ENV_ITE => 'urn:nzl:govt:ict:stds:authn:deployment:GLS:SAML:2.0:ac:classes:LowStrength',
22
        RealMeService::ENV_PROD => 'urn:nzl:govt:ict:stds:authn:deployment:GLS:SAML:2.0:ac:classes:LowStrength'
23
    );
24
25
    private static $metadata_assertion_urls = array(
26
        RealMeService::ENV_MTS => "https://dev.your-website.govt.nz/",
27
        RealMeService::ENV_ITE => "https://staging.your-website.govt.nz/",
28
        RealMeService::ENV_PROD => "https://www.your-website.govt.nz/"
29
    );
30
31
    /**
32
     * We need to make sure that if an invalid environment, it raises the correct errors for correction.
33
     * - invalid environment
34
     * - no environment
35
     *
36
     * We must also not raise an error if we pass a correctly configured environment.
37
     */
38
    public function testEnvironmentValidation()
39
    {
40
        // Setup our objects for testing through reflection
41
        $realMeService = new RealMeService();
42
        $realMeSetupTask = new RealMeSetupTask();
43
44
        $errors = new ReflectionProperty($realMeSetupTask, 'errors');
45
        $errors->setAccessible(true);
46
47
        $service = new ReflectionProperty($realMeSetupTask, 'service');
48
        $service->setAccessible(true);
49
        $service->setValue($realMeSetupTask, $realMeService);
50
51
        // Make sure there's no errors to begin.
52
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
53
54
        // Test: Make an error
55
        $invalidEnv = "wrong-environment";
56
        $validateEnvironments = new ReflectionMethod($realMeSetupTask, 'validateRealMeEnvironments');
57
        $validateEnvironments->setAccessible(true);
58
        $validateEnvironments->invoke($realMeSetupTask, $invalidEnv);
59
        $this->assertCount(1, $errors->getValue($realMeSetupTask), "An invalid environment should raise an error");
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
61
        // reset errors & Make sure there's no errors to begin.
62
        $errors->setValue($realMeSetupTask, array());
63
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
64
65
        // Test: No environment passed
66
        $noEnvironment = null;
67
        $validateEnvironments = new ReflectionMethod($realMeSetupTask, 'validateRealMeEnvironments');
68
        $validateEnvironments->setAccessible(true);
69
        $validateEnvironments->invoke($realMeSetupTask, $noEnvironment);
70
        $this->assertCount(1, $errors->getValue($realMeSetupTask), "Missing environment should raise an error");
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
71
72
        // reset errors &&  Make sure there's no errors to begin.
73
        $errors->setValue($realMeSetupTask, array());
74
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
75
76
        // Test: allowed environments pass without error.
77
        $reflectionMethod = new ReflectionMethod($realMeService, 'getAllowedRealMeEnvironments');
78
        $reflectionMethod->setAccessible(true);
79
        foreach ($reflectionMethod->invoke($realMeService) as $validEnvironment) {
80
            $validateEnvironments->invoke($realMeSetupTask, $validEnvironment);
81
        }
82
83
        // Make sure there's no errors, they should all be valid
84
        $this->assertCount(0, $errors->getValue($realMeSetupTask), "valid environments should not raise an error");
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
85
    }
86
87
    /**
88
     * We need to make sure that there is an entity ID and that it's in the correct format for realme consumption
89
     * - It's present in the config
90
     * - it's not localhost
91
     * - it's not http (must be https)
92
     * - service name and privacy realm < 10 char.
93
     */
94
    public function testValidateEntityID()
95
    {
96
        $realMeService = new RealMeService();
97
        $realMeSetupTask = new RealMeSetupTask();
98
99
        $errors = new ReflectionProperty($realMeSetupTask, 'errors');
100
        $errors->setAccessible(true);
101
102
        $service = new ReflectionProperty($realMeSetupTask, 'service');
103
        $service->setAccessible(true);
104
        $service->setValue($realMeSetupTask, $realMeService);
105
106
        // Make sure there's no errors to begin.
107
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
108
109
        // Test valid entityIds just in case they're different in this configuration.
110
        $config = Config::inst();
111
        $config->update('RealMeService', 'entity_ids', self::$validEntityIDs);
112
113
        // validate our list of valid entity IDs;
114
        $validateEntityId = new ReflectionMethod($realMeSetupTask, 'validateEntityID');
115
        $validateEntityId->setAccessible(true);
116
        $validateEntityId->invoke($realMeSetupTask);
117
118
        // valid entityID's shouldn't have any issues
119
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
120
121
        // TEST entityId missing.
122
        $entityIdList = self::$validEntityIDs;
123
        $entityIdList[RealMeService::ENV_MTS] = 'destroy-humans-with-incorrect-entity-ids';
124
        $config->update('RealMeService', 'entity_ids', $entityIdList);
125
        $validateEntityId->invoke($realMeSetupTask);
126
        $this->assertCount(1, $errors->getValue($realMeSetupTask), 'validate entity id should fail for an invalid url');
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
127
128
        // reset errors &&  Make sure there's no errors to begin.
129
        $errors->setValue($realMeSetupTask, array());
130
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
131
132
        // TEST entityId localhost.
133
        $entityIdList = self::$validEntityIDs;
134
        $entityIdList[RealMeService::ENV_MTS] = 'https://localhost/';
135
        $config->update('RealMeService', 'entity_ids', $entityIdList);
136
        $validateEntityId->invoke($realMeSetupTask);
137
        $this->assertCount(1, $errors->getValue($realMeSetupTask), 'validate entity id should fail for localhost');
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
138
139
        $errors->setValue($realMeSetupTask, array());
140
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
141
142
        // TEST entityId not http
143
        $entityIdList = self::$validEntityIDs;
144
        $entityIdList[RealMeService::ENV_MTS] = 'http://dev.realme-integration.govt.nz/p-realm/s-name';
145
        $config->update('RealMeService', 'entity_ids', $entityIdList);
146
        $validateEntityId->invoke($realMeSetupTask);
147
        $this->assertCount(1, $errors->getValue($realMeSetupTask), 'validate entity id should fail for http');
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
148
149
        $errors->setValue($realMeSetupTask, array());
150
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
151
152
        // TEST privacy realm /service name  missing
153
        $entityIdList = self::$validEntityIDs;
154
        $entityIdList[RealMeService::ENV_MTS] = 'https://dev.realme-integration.govt.nz/';
155
        $config->update('RealMeService', 'entity_ids', $entityIdList);
156
        $validateEntityId->invoke($realMeSetupTask);
157
        $this->assertCount(2,
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
158
            $errors->getValue($realMeSetupTask),
159
            'validate entity id should fail for missing service name and privacy realm'
160
        );
161
162
        $errors->setValue($realMeSetupTask, array());
163
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
164
165
        // TEST privacy realm
166
        // "https://www.domain.govt.nz/<privacy-realm>/<service-name>"
167
        $entityIdList = self::$validEntityIDs;
168
        $entityIdList[RealMeService::ENV_MTS] = 'https://dev.realme-integration.govt.nz/s-name/privacy-realm-is-too-big';
169
        $config->update('RealMeService', 'entity_ids', $entityIdList);
170
        $validateEntityId->invoke($realMeSetupTask);
171
        $this->assertCount(1, $errors->getValue($realMeSetupTask), 'validate entity id should fail for privacy-realm-is-too-big');
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
172
173
        $errors->setValue($realMeSetupTask, array());
174
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
175
176
        // "https://www.domain.govt.nz/<privacy-realm>/<service-name>"
177
        $entityIdList = self::$validEntityIDs;
178
        $entityIdList[RealMeService::ENV_MTS] = 'https://dev.realme-integration.govt.nz/s-name';
179
        $config->update('RealMeService', 'entity_ids', $entityIdList);
180
        $validateEntityId->invoke($realMeSetupTask);
181
        $this->assertCount(1, $errors->getValue($realMeSetupTask), 'validate entity id should fail if privacy realm is missing');
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
182
183
        $errors->setValue($realMeSetupTask, array());
184
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
185
    }
186
187
188
    /**
189
     * We require an authn context for each environment to determine how secure to ask realme to validate.
190
     * - it should be present for each environment, and one of four pre-determined authncontexts.
191
     */
192
    public function testValidateAuthNContext()
193
    {
194
        $realMeService = new RealMeService();
195
        $realMeSetupTask = new RealMeSetupTask();
196
197
        $errors = new ReflectionProperty($realMeSetupTask, 'errors');
198
        $errors->setAccessible(true);
199
200
        $service = new ReflectionProperty($realMeSetupTask, 'service');
201
        $service->setAccessible(true);
202
        $service->setValue($realMeSetupTask, $realMeService);
203
204
        // Make sure there's no errors to begin.
205
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
206
207
        // Test valid authnContexts just in case they're different in this configuration.
208
        $config = Config::inst();
209
        $config->update('RealMeService', 'authn_contexts', self::$authnEnvContexts);
210
211
        // validate our list of valid entity IDs;
212
        $validateAuthNContext = new ReflectionMethod($realMeSetupTask, 'validateAuthNContext');
213
        $validateAuthNContext->setAccessible(true);
214
        $validateAuthNContext->invoke($realMeSetupTask);
215
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
216
217
        $invalidAuthNContextList = self::$authnEnvContexts;
218
        $invalidAuthNContextList[RealMeService::ENV_MTS] = 'im-an-invalid-context';
219
        $config->update('RealMeService', 'authn_contexts', $invalidAuthNContextList);
220
221
        $validateAuthNContext->invoke($realMeSetupTask);
222
        $this->assertCount(1, $errors->getValue($realMeSetupTask), "The authncontext validation should fail if invalid.");
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
223
    }
224
225
    /**
226
     * Check the consumer assertion url is being validated from config correctly.
227
     * - ensure it's present
228
     * - ensure it's https
229
     * - ensure it's a valid URL
230
     * - ensure it's not localhost.
231
     */
232
    public function testValidateConsumerAssertionURL()
233
    {
234
        $realMeService = new RealMeService();
235
        $realMeSetupTask = new RealMeSetupTask();
236
237
        $errors = new ReflectionProperty($realMeSetupTask, 'errors');
238
        $errors->setAccessible(true);
239
240
        $service = new ReflectionProperty($realMeSetupTask, 'service');
241
        $service->setAccessible(true);
242
        $service->setValue($realMeSetupTask, $realMeService);
243
244
        // Make sure there's no errors to begin.
245
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
246
247
        // Test valid entityIds just in case they're different in this configuration.
248
        $config = Config::inst();
249
        $config->update('RealMeService', 'metadata_assertion_service_domains', self::$metadata_assertion_urls);
250
251
        // validate our list of valid entity IDs;
252
        $validateAuthNContext = new ReflectionMethod($realMeSetupTask, 'validateConsumerAssertionURL');
253
        $validateAuthNContext->setAccessible(true);
254
        $validateAuthNContext->invoke($realMeSetupTask, RealMeService::ENV_MTS);
255
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
256
257
        // Test an invalid metadata assertion URL.
258
        $metadataAssertionUrls = self::$metadata_assertion_urls;
259
        $metadataAssertionUrls[RealMeService::ENV_MTS] = 'invalid-url';
260
        $config->update('RealMeService', 'metadata_assertion_service_domains', $metadataAssertionUrls);
261
262
        $validateAuthNContext->invoke($realMeSetupTask, RealMeService::ENV_MTS);
263
        $this->assertCount(1, $errors->getValue($realMeSetupTask), "The validation should fail for an invalid URL");
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
264
265
        // Make sure there's no errors to begin.
266
        $errors->setValue($realMeSetupTask, array());
267
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
268
269
        // Test should fail for non HTTPs
270
        $metadataAssertionUrls = self::$metadata_assertion_urls;
271
        $metadataAssertionUrls[RealMeService::ENV_MTS] = 'http://my-broken-url.govt.nz';
272
        $config->update('RealMeService', 'metadata_assertion_service_domains', $metadataAssertionUrls);
273
274
        $validateAuthNContext->invoke($realMeSetupTask, RealMeService::ENV_MTS);
275
        $this->assertCount(1, $errors->getValue($realMeSetupTask), "The validation should fail for non-HTTPs");
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
276
277
        // Make sure there's no errors to begin.
278
        $errors->setValue($realMeSetupTask, array());
279
        $this->assertCount(0, $errors->getValue($realMeSetupTask));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
280
281
        // Test should fail for localhost
282
        $metadataAssertionUrls = self::$metadata_assertion_urls;
283
        $metadataAssertionUrls[RealMeService::ENV_MTS] = 'https://localhost';
284
        $config->update('RealMeService', 'metadata_assertion_service_domains', $metadataAssertionUrls);
285
286
        $validateAuthNContext->invoke($realMeSetupTask, RealMeService::ENV_MTS);
287
        $this->assertCount(1, $errors->getValue($realMeSetupTask), "The validation should fail for non-HTTPs");
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
288
    }
289
290
    /**
291
     * Ensure that setting the RealMeSetupTask template_config_dir config value
292
     * can adjust the path that the task looks in for its templates.
293
     * - ensure the default works
294
     * - ensure configuring a bad directory name falls back to the default
295
     * - ensure that configuring a good value uses the configured directory
296
     */
297
    public function testConfigurationTemplateDir()
298
    {
299
        $realMeSetupTask = new RealMeSetupTask();
300
301
        $getConfigurationTemplateDirMethod = new ReflectionMethod('RealMeSetupTask', 'getConfigurationTemplateDir');
302
        $getConfigurationTemplateDirMethod->setAccessible(true);
303
304
        $config = Config::inst();
305
306
        $config->update('RealMeSetupTask', 'template_config_dir', '');
307
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
308
            BASE_PATH . DIRECTORY_SEPARATOR . REALME_MODULE_PATH . '/templates/simplesaml-configuration',
309
            $getConfigurationTemplateDirMethod->invoke($realMeSetupTask),
310
            'Using no configuration for template_config_dir should use the default template directory.'
311
        );
312
313
        $config->update('RealMeSetupTask', 'template_config_dir', 'xyzzy');
314
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
315
            BASE_PATH . DIRECTORY_SEPARATOR . REALME_MODULE_PATH . '/templates/simplesaml-configuration',
316
            $getConfigurationTemplateDirMethod->invoke($realMeSetupTask),
317
            'Configuring a directory that does not exist should use the default template directory.'
318
        );
319
320
        $config->update('RealMeSetupTask', 'template_config_dir', REALME_MODULE_PATH);
321
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<RealMeSetupTaskTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
322
            BASE_PATH . DIRECTORY_SEPARATOR . REALME_MODULE_PATH, // doesn't contain templates, but does exist
323
            $getConfigurationTemplateDirMethod->invoke($realMeSetupTask),
324
            'Configuring a directory that exists should use the configured template directory.'
325
        );
326
    }
327
}
328