Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync etl #868

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace all the str_split() runtime created arrays with literal arrays like we have in canonical data. Also canonical data asks for integer keys into the array, so make all the keys integers:

Suggested change
$old = ['1' => str_split('AEIOU')];
$old = [1 => ["A", "E", "I", "O", "U"]];

This shows the actual input to the students and is as requested by canonical data. It also should not break any existing solutions.

$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