1
1
<?php
2
2
3
- /*
4
- * By adding type hints and enabling strict type checking, code can become
5
- * easier to read, self-documenting and reduce the number of potential bugs.
6
- * By default, type declarations are non-strict, which means they will attempt
7
- * to change the original type to match the type specified by the
8
- * type-declaration.
9
- *
10
- * In other words, if you pass a string to a function requiring a float,
11
- * it will attempt to convert the string value to a float.
12
- *
13
- * To enable strict mode, a single declare directive must be placed at the top
14
- * of the file.
15
- * This means that the strictness of typing is configured on a per-file basis.
16
- * This directive not only affects the type declarations of parameters, but also
17
- * a function's return type.
18
- *
19
- * For more info review the Concept on strict type checking in the PHP track
20
- * <link>.
21
- *
22
- * To disable strict typing, comment out the directive below.
23
- */
24
-
25
3
declare (strict_types=1 );
26
4
27
5
class EtlTest extends PHPUnit \Framework \TestCase
@@ -31,37 +9,53 @@ public static function setUpBeforeClass(): void
31
9
require_once 'Etl.php ' ;
32
10
}
33
11
12
+ /**
13
+ * uuid 78a7a9f9-4490-4a47-8ee9-5a38bb47d28f
14
+ * @testdox single letter
15
+ */
34
16
public function testTransformOneValue (): void
35
17
{
36
18
$ old = ['1 ' => ['A ' ]];
37
19
$ expected = ['a ' => 1 ];
38
20
$ this ->assertEquals ($ expected , transform ($ old ));
39
21
}
40
22
23
+ /**
24
+ * uuid 60dbd000-451d-44c7-bdbb-97c73ac1f497
25
+ * @testdox single score with multiple letters
26
+ */
41
27
public function testTransformMoreValues (): void
42
28
{
43
- $ old = [' 1 ' => str_split ( ' AEIOU ' ) ];
29
+ $ old = [1 => [ ' A ' , ' E ' , ' I ' , ' O ' , ' U ' ] ];
44
30
$ expected = ['a ' => 1 , 'e ' => 1 , 'i ' => 1 , 'o ' => 1 , 'u ' => 1 ];
45
31
$ this ->assertEquals ($ expected , transform ($ old ));
46
32
}
47
33
34
+ /**
35
+ * uuid f5c5de0c-301f-4fdd-a0e5-df97d4214f54
36
+ * @testdox multiple scores with multiple letters
37
+ */
48
38
public function testTransformMoreKeys (): void
49
39
{
50
- $ old = [' 1 ' => str_split ( ' AE ' ) , '2 ' => str_split ( ' DG ' ) ];
40
+ $ old = [1 => [ ' A ' , 'E ' ], 2 => [ ' D ' , ' G ' ] ];
51
41
$ expected = ['a ' => 1 , 'e ' => 1 , 'd ' => 2 , 'g ' => 2 ];
52
42
$ this ->assertEquals ($ expected , transform ($ old ));
53
43
}
54
44
45
+ /**
46
+ * uuid 5db8ea89-ecb4-4dcd-902f-2b418cc87b9d
47
+ * @testdox multiple scores with differing numbers of letters
48
+ */
55
49
public function testTransformFullDataset (): void
56
50
{
57
51
$ old = [
58
- ' 1 ' => str_split ( ' AEIOULNRST ' ) ,
59
- ' 2 ' => str_split ( ' DG ' ) ,
60
- ' 3 ' => str_split ( ' BCMP ' ) ,
61
- ' 4 ' => str_split ( ' FHVWY ' ) ,
62
- ' 5 ' => str_split ( 'K ' ) ,
63
- ' 8 ' => str_split ( ' JX ' ) ,
64
- ' 10 ' => str_split ( ' QZ ' ) ,
52
+ 1 => [ ' A ' , ' E ' , ' I ' , ' O ' , ' U ' , ' L ' , ' N ' , ' R ' , ' S ' , ' T ' ] ,
53
+ 2 => [ ' D ' , ' G ' ] ,
54
+ 3 => [ ' B ' , ' C ' , ' M ' , ' P ' ] ,
55
+ 4 => [ ' F ' , ' H ' , ' V ' , ' W ' , ' Y ' ] ,
56
+ 5 => [ 'K ' ] ,
57
+ 8 => [ ' J ' , ' X ' ] ,
58
+ 10 => [ ' Q ' , ' Z ' ] ,
65
59
];
66
60
$ expected = [
67
61
'a ' => 1 , 'b ' => 3 , 'c ' => 3 , 'd ' => 2 , 'e ' => 1 ,
0 commit comments