Das RGB-Farbmodell ist vorhanden.
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
<?php /** @noinspection PhpArrayShapeAttributeCanBeAddedInspection */
|
||||
|
||||
namespace TorstenHettstedtUnitTests\Colors\ColorModels;
|
||||
|
||||
use Codeception\Test\Unit;
|
||||
use InvalidArgumentException;
|
||||
use TorstenHettstedt\Colors\ColorModels\RedGreenBlue;
|
||||
|
||||
class RedGreenBlueTest extends Unit
|
||||
{
|
||||
|
||||
public function testConstruct()
|
||||
{
|
||||
$color = new RedGreenBlue();
|
||||
|
||||
$this->assertEquals(1.0, $color->getRed());
|
||||
$this->assertEquals(1.0, $color->getGreen());
|
||||
$this->assertEquals(1.0, $color->getBlue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float[][]
|
||||
*/
|
||||
public function invalidValueProvider(): array
|
||||
{
|
||||
return [
|
||||
'zu klein' => [-0.1],
|
||||
'zu gross' => [1.1],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float[][]
|
||||
*/
|
||||
public function validValueProvider(): array
|
||||
{
|
||||
return [
|
||||
'niedrigster Wert' => [0.0],
|
||||
'mittlerer Wert' => [0.45],
|
||||
'maximaler Wert' => [1.0],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $value
|
||||
*
|
||||
* @dataProvider validValueProvider
|
||||
*/
|
||||
public function testSetRedWithValidValue(float $value)
|
||||
{
|
||||
$color = new RedGreenBlue();
|
||||
|
||||
$color->setRed($value);
|
||||
$this->assertEquals($value, $color->getRed());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $value
|
||||
*
|
||||
* @dataProvider invalidValueProvider
|
||||
*/
|
||||
public function testSetRedWithInvalidValue(float $value)
|
||||
{
|
||||
$color = new RedGreenBlue();
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$color->setRed($value);
|
||||
}
|
||||
/**
|
||||
* @param float $value
|
||||
*
|
||||
* @dataProvider validValueProvider
|
||||
*/
|
||||
public function testSetGreenWithValidValue(float $value)
|
||||
{
|
||||
$color = new RedGreenBlue();
|
||||
|
||||
$color->setGreen($value);
|
||||
$this->assertEquals($value, $color->getGreen());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $value
|
||||
*
|
||||
* @dataProvider invalidValueProvider
|
||||
*/
|
||||
public function testSetGreenWithInvalidValue(float $value)
|
||||
{
|
||||
$color = new RedGreenBlue();
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$color->setGreen($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $value
|
||||
*
|
||||
* @dataProvider validValueProvider
|
||||
*/
|
||||
public function testSetBlueWithValidValue(float $value)
|
||||
{
|
||||
$color = new RedGreenBlue();
|
||||
|
||||
$color->setBlue($value);
|
||||
$this->assertEquals($value, $color->getBlue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $value
|
||||
*
|
||||
* @dataProvider invalidValueProvider
|
||||
*/
|
||||
public function testSetBlueWithInvalidValue(float $value)
|
||||
{
|
||||
$color = new RedGreenBlue();
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$color->setBlue($value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user