Skip to content

Commit

Permalink
Merge pull request #34 from chemix/tests
Browse files Browse the repository at this point in the history
tests for color mix and color complementary
  • Loading branch information
mexitek authored Mar 26, 2018
2 parents 3d429c4 + 6d9c365 commit edf1342
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/colorComplementary.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

require __DIR__ . '/bootstrap.php';

use Mexitek\PHPColors\Color;
use Tester\Assert;


$expected = array(
"ff0000" => "00ffff",
"0000ff" => "ffff00",
"00ff00" => "ff00ff",
"ffff00" => "0000ff",
"00ffff" => "ff0000",
"ffff00" => "0000ff",

"49cbaf" => "cb4965",
"003eb2" => "b27400",
"b27400" => "003eb2",
"ffff99" => "9999ff",
"ccff00" => "3300ff",
"3300ff" => "ccff00",
"fb4a2c" => "2cddfb",
"9cebff" => "ffb09c",
);

foreach ($expected as $original => $complementary) {
$color = new Color($original);
Assert::same($complementary, $color->complementary(), 'Incorrect complementary color returned.');
}
24 changes: 24 additions & 0 deletions tests/colorMix.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

require __DIR__ . '/bootstrap.php';

use Mexitek\PHPColors\Color;
use Tester\Assert;


$expected = array(
"ffffff" => array("ff0000","ff7f7f"), // ffffff + ff0000 = ff7f7f
"00ff00" => array("ff0000","7f7f00"),
"000000" => array("ff0000","7f0000"),
"002fff" => array("000000","00177f"),
"00ffed" => array("000000","007f76"),
"ff9a00" => array("000000","7f4d00"),
"ff9a00" => array("ffffff","ffcc7f"),
"00ff2d" => array("ffffff","7fff96"),
"8D43B4" => array("35CF64","61898c"),
);

foreach ($expected as $original => $complementary) {
$color = new Color($original);
Assert::same($complementary[1], $color->mix($complementary[0]), 'Incorrect mix color returned.');
}

0 comments on commit edf1342

Please sign in to comment.