Skip to content

Commit

Permalink
sync etl
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasnorre committed Nov 19, 2024
1 parent 4782c2b commit 693fbb5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 47 deletions.
6 changes: 3 additions & 3 deletions exercises/practice/etl/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
".meta/example.php"
]
},
"blurb": "We are going to do the `Transform` step of an Extract-Transform-Load.",
"source": "The Jumpstart Lab team",
"source_url": "https://jumpstartlab.com"
"blurb": "Change the data format for scoring a game to more easily add other languages.",
"source": "Based on an exercise by the JumpstartLab team for students at The Turing School of Software and Design.",
"source_url": "https://turing.edu"
}
22 changes: 0 additions & 22 deletions exercises/practice/etl/.meta/example.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
<?php

/*
* By adding type hints and enabling strict type checking, code can become
* easier to read, self-documenting and reduce the number of potential bugs.
* By default, type declarations are non-strict, which means they will attempt
* to change the original type to match the type specified by the
* type-declaration.
*
* In other words, if you pass a string to a function requiring a float,
* it will attempt to convert the string value to a float.
*
* To enable strict mode, a single declare directive must be placed at the top
* of the file.
* This means that the strictness of typing is configured on a per-file basis.
* This directive not only affects the type declarations of parameters, but also
* a function's return type.
*
* For more info review the Concept on strict type checking in the PHP track
* <link>.
*
* To disable strict typing, comment out the directive below.
*/

declare(strict_types=1);

function transform($old)
Expand Down
38 changes: 16 additions & 22 deletions exercises/practice/etl/EtlTest.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
<?php

/*
* By adding type hints and enabling strict type checking, code can become
* easier to read, self-documenting and reduce the number of potential bugs.
* By default, type declarations are non-strict, which means they will attempt
* to change the original type to match the type specified by the
* type-declaration.
*
* In other words, if you pass a string to a function requiring a float,
* it will attempt to convert the string value to a float.
*
* To enable strict mode, a single declare directive must be placed at the top
* of the file.
* This means that the strictness of typing is configured on a per-file basis.
* This directive not only affects the type declarations of parameters, but also
* a function's return type.
*
* For more info review the Concept on strict type checking in the PHP track
* <link>.
*
* To disable strict typing, comment out the directive below.
*/

declare(strict_types=1);

class EtlTest extends PHPUnit\Framework\TestCase
Expand All @@ -31,27 +9,43 @@ public static function setUpBeforeClass(): void
require_once 'Etl.php';
}

/**
* uuid 78a7a9f9-4490-4a47-8ee9-5a38bb47d28f
* @testdox single letter
*/
public function testTransformOneValue(): void
{
$old = ['1' => ['A']];
$expected = ['a' => 1];
$this->assertEquals($expected, transform($old));
}

/**
* uuid 60dbd000-451d-44c7-bdbb-97c73ac1f497
* @testdox single score with multiple letters
*/
public function testTransformMoreValues(): void
{
$old = ['1' => str_split('AEIOU')];
$expected = ['a' => 1, 'e' => 1, 'i' => 1, 'o' => 1, 'u' => 1];
$this->assertEquals($expected, transform($old));
}

/**
* uuid f5c5de0c-301f-4fdd-a0e5-df97d4214f54
* @testdox multiple scores with multiple letters
*/
public function testTransformMoreKeys(): void
{
$old = ['1' => str_split('AE'), '2' => str_split('DG')];
$expected = ['a' => 1, 'e' => 1, 'd' => 2, 'g' => 2];
$this->assertEquals($expected, transform($old));
}

/**
* uuid 5db8ea89-ecb4-4dcd-902f-2b418cc87b9d
* @testdox multiple scores with differing numbers of letters
*/
public function testTransformFullDataset(): void
{
$old = [
Expand Down

0 comments on commit 693fbb5

Please sign in to comment.