-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix, test coverage improved and ready for v1 :D
- Loading branch information
Ricardo Fiorani
committed
Sep 28, 2018
1 parent
9ea557f
commit e52f7c5
Showing
4 changed files
with
66 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tests\RicardoFiorani\Unit\Palette; | ||
|
||
use Intervention\Image\Gd\Color; | ||
use PHPUnit\Framework\TestCase; | ||
use RicardoFiorani\Legofy\Pallete\ColorPalette; | ||
|
||
class ColorPaletteTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider colorProvider | ||
*/ | ||
public function testGetsRightColor(array $colors, array $input, $expected) | ||
{ | ||
$colorPalette = new ColorPalette($colors); | ||
|
||
$outputColor = $colorPalette->pickClosestColor(new Color($input)); | ||
$outputColorArray = $outputColor->getArray(); | ||
|
||
$this->assertEquals($expected[0], $outputColorArray[0]); | ||
$this->assertEquals($expected[1], $outputColorArray[1]); | ||
$this->assertEquals($expected[2], $outputColorArray[2]); | ||
} | ||
|
||
public function colorProvider() | ||
{ | ||
return [ | ||
//Whole set | ||
[ | ||
//Palette | ||
[ | ||
'024' => [254, 196, 1,], | ||
'106' => [231, 100, 25,], | ||
'021' => [222, 1, 14,], | ||
], | ||
//input color | ||
[253, 194, 2], | ||
//expected color | ||
[254, 196, 1,] | ||
], | ||
//Whole set | ||
[ | ||
//Palette | ||
[ | ||
'024' => [254, 196, 1,], | ||
'106' => [231, 100, 25,], | ||
'021' => [222, 1, 14,], | ||
], | ||
//input color | ||
[224, 5, 22], | ||
//expected color | ||
[222, 1, 14,] | ||
], | ||
]; | ||
} | ||
} |