-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathProfileValidatorTest.php
More file actions
69 lines (59 loc) · 2.04 KB
/
Copy pathProfileValidatorTest.php
File metadata and controls
69 lines (59 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Tests\Jobs;
use App\Helper\ProfileValidator;
use Tests\TestCase;
class ProfileValidatorTest extends TestCase {
/**
* @dataProvider validProfileProvider
*/
public function testProfileValidatorWorksWithValidProfile($profile): void {
$validatorFactory = new ProfileValidator();
$validator = $validatorFactory->getValidator($profile);
$this->assertTrue($validator->passes());
}
/**
* @dataProvider invalidProfileProvider
*/
public function testProfileValidatorWorksWithInvalidProfile($profile): void {
$validatorFactory = new ProfileValidator();
$validator = $validatorFactory->getValidator($profile);
$this->assertFalse($validator->passes());
}
public static function validProfileProvider(): iterable {
yield 'boring profile with no other' => [[
'purpose' => 'data_hub',
'audience' => 'narrow',
'temporality' => 'permanent',
]];
yield 'with other values' => [[
'purpose' => 'data_hub',
'audience' => 'other',
'audience_other' => 'my cat',
'temporality' => 'other',
'temporality_other' => 'only in the past',
]];
}
public static function invalidProfileProvider(): iterable {
yield 'missing other keys' => [[
'purpose' => 'data_hub',
'audience' => 'narrow',
'temporality' => 'other',
]];
yield 'audience is empty string' => [[
'purpose' => 'data_hub',
'audience' => '',
'temporality' => 'other',
]];
yield 'audience key present when purpose not data_hub' => [[
'purpose' => 'data_lab',
'audience' => 'narrow',
'temporality' => 'permanent',
]];
yield 'other keys when there should not be' => [[
'purpose' => 'data_hub',
'purpose_other' => 'asdfasdf',
'audience' => 'narrow',
'temporality' => 'permanent',
]];
}
}