Umwandlung-Tests für CMYK-Objekte geschrieben.
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<?php /** @noinspection PhpArrayShapeAttributeCanBeAddedInspection */
|
||||
|
||||
namespace TorstenHettstedtUnitTests\Colors\Transformer;
|
||||
|
||||
use Codeception\Test\Unit;
|
||||
use Exception;
|
||||
use TorstenHettstedt\Colors\ColorModels\CyanMagentaYellowKey;
|
||||
use TorstenHettstedt\Colors\Transformer\CyanMagentaYellowKeyTransformer;
|
||||
|
||||
class CyanMagentaYellowKeyTransformerTest extends Unit
|
||||
{
|
||||
|
||||
protected CyanMagentaYellowKey $color;
|
||||
|
||||
/**
|
||||
* @return float[][][]
|
||||
*/
|
||||
public function validRgbValuesProvider(): array
|
||||
{
|
||||
return [
|
||||
'weiß' => [
|
||||
[
|
||||
'cyan' => 0.0,
|
||||
'magenta' => 0.0,
|
||||
'yellow' => 0.0,
|
||||
'key' => 0.0,
|
||||
],
|
||||
[
|
||||
'red' => 1.0,
|
||||
'green' => 1.0,
|
||||
'blue' => 1.0,
|
||||
]
|
||||
],
|
||||
'schwarz' => [
|
||||
[
|
||||
'cyan' => 0.0,
|
||||
'magenta' => 0.0,
|
||||
'yellow' => 0.0,
|
||||
'key' => 1.0,
|
||||
],
|
||||
[
|
||||
'red' => 0.0,
|
||||
'green' => 0.0,
|
||||
'blue' => 0.0,
|
||||
]
|
||||
],
|
||||
'cyan' => [
|
||||
[
|
||||
'cyan' => 1.0,
|
||||
'magenta' => 0.0,
|
||||
'yellow' => 0.0,
|
||||
'key' => 0.0,
|
||||
],
|
||||
[
|
||||
'red' => 0.0,
|
||||
'green' => 1.0,
|
||||
'blue' => 1.0,
|
||||
]
|
||||
],
|
||||
'magenta' => [
|
||||
[
|
||||
'cyan' => 0.0,
|
||||
'magenta' => 1.0,
|
||||
'yellow' => 0.0,
|
||||
'key' => 0.0,
|
||||
],
|
||||
[
|
||||
'red' => 1.0,
|
||||
'green' => 0.0,
|
||||
'blue' => 1.0,
|
||||
]
|
||||
],
|
||||
'gelb' => [
|
||||
[
|
||||
'cyan' => 0.0,
|
||||
'magenta' => 0.0,
|
||||
'yellow' => 1.0,
|
||||
'key' => 0.0,
|
||||
],
|
||||
[
|
||||
'red' => 1.0,
|
||||
'green' => 1.0,
|
||||
'blue' => 0.0,
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $cmyk
|
||||
* @param array $rgb
|
||||
*
|
||||
* @dataProvider validRgbValuesProvider
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testToRedGreenBlue(array $cmyk, array $rgb)
|
||||
{
|
||||
$this->color = $this->make(CyanMagentaYellowKey::class, $cmyk);
|
||||
|
||||
$transformer = new CyanMagentaYellowKeyTransformer($this->color);
|
||||
|
||||
$color = $transformer->toRedGreenBlue();
|
||||
|
||||
$this->assertEquals($rgb['red'], $color->getRed());
|
||||
$this->assertEquals($rgb['green'], $color->getGreen());
|
||||
$this->assertEquals($rgb['blue'], $color->getBlue());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $cmyk
|
||||
* @param array $rgb
|
||||
*
|
||||
* @dataProvider validRgbValuesProvider
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testToCyanMagentaYellowKey(array $cmyk, array $rgb)
|
||||
{
|
||||
|
||||
$this->color = $this->make(CyanMagentaYellowKey::class, $cmyk);
|
||||
|
||||
$transformer = new CyanMagentaYellowKeyTransformer($this->color);
|
||||
|
||||
$color = $transformer->toCyanMagentaYellowKey();
|
||||
|
||||
$this->assertEquals($rgb['cyan'], $color->getCyan());
|
||||
$this->assertEquals($rgb['magenta'], $color->getMagenta());
|
||||
$this->assertEquals($rgb['yellow'], $color->getYellow());
|
||||
$this->assertEquals($rgb['key'], $color->getKey());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user