Skip to content
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
1 change: 1 addition & 0 deletions bin/auto-sync.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ proverb
queen-attack
rail-fence-cipher
raindrops
resistor-color
resistor-color-duo
reverse-string
rna-transcription
Expand Down
3 changes: 2 additions & 1 deletion exercises/practice/resistor-color/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"camilopayan"
],
"contributors": [
"MichaelBunker"
"MichaelBunker",
"manupereiraduarte"
],
"files": {
"solution": [
Expand Down
22 changes: 0 additions & 22 deletions exercises/practice/resistor-color/.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 getAllColors(): array
Expand Down
22 changes: 22 additions & 0 deletions exercises/practice/resistor-color/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[49eb31c5-10a8-4180-9f7f-fea632ab87ef]
description = "Color codes -> Black"

[0a4df94b-92da-4579-a907-65040ce0b3fc]
description = "Color codes -> White"

[5f81608d-f36f-4190-8084-f45116b6f380]
description = "Color codes -> Orange"

[581d68fa-f968-4be2-9f9d-880f2fb73cf7]
description = "Colors"
39 changes: 17 additions & 22 deletions exercises/practice/resistor-color/ResistorColorTest.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
<?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);

use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
Comment thread
mk-mxp marked this conversation as resolved.

class ResistorColorTest extends TestCase
Expand All @@ -33,6 +12,10 @@ public static function setUpBeforeClass(): void
require_once 'ResistorColor.php';
}

/**
* uuid: 581d68fa-f968-4be2-9f9d-880f2fb73cf7
*/
#[TestDox('Colors')]
Comment thread
mk-mxp marked this conversation as resolved.
public function testColors(): void
{
$this->assertEquals([
Expand All @@ -49,16 +32,28 @@ public function testColors(): void
], getAllColors());
}

/**
* uuid: 49eb31c5-10a8-4180-9f7f-fea632ab87ef
*/
#[TestDox('Black')]
Comment thread
mk-mxp marked this conversation as resolved.
public function testBlackColorCode(): void
{
$this->assertEquals(0, colorCode("black"));
}

/**
* uuid: 5f81608d-f36f-4190-8084-f45116b6f380
*/
#[TestDox('Orange')]
Comment thread
mk-mxp marked this conversation as resolved.
public function testOrangeColorCode(): void
{
$this->assertEquals(3, colorCode("orange"));
}

/**
* uuid: 0a4df94b-92da-4579-a907-65040ce0b3fc
*/
#[TestDox('White')]
Comment thread
mk-mxp marked this conversation as resolved.
public function testWhiteColorCode(): void
{
$this->assertEquals(9, colorCode("white"));
Expand Down