mirror of
https://github.com/Intervention/image.git
synced 2025-08-17 19:26:25 +02:00
Add channel tests
This commit is contained in:
48
tests/Colors/Cmyk/ChannelTest.php
Normal file
48
tests/Colors/Cmyk/ChannelTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Tests\Colors\Cmyk;
|
||||
|
||||
use Intervention\Image\Colors\Cmyk\Channels\Cyan as Channel;
|
||||
use Intervention\Image\Exceptions\ColorException;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @requires extension gd
|
||||
* @covers \Intervention\Image\Colors\Cmyk\Channels\Cyan
|
||||
* @covers \Intervention\Image\Colors\Cmyk\Channels\Magenta
|
||||
* @covers \Intervention\Image\Colors\Cmyk\Channels\Yellow
|
||||
* @covers \Intervention\Image\Colors\Cmyk\Channels\Key
|
||||
*/
|
||||
class ChannelTest extends TestCase
|
||||
{
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$channel = new Channel(0);
|
||||
$this->assertInstanceOf(Channel::class, $channel);
|
||||
}
|
||||
|
||||
public function testValue(): void
|
||||
{
|
||||
$channel = new Channel(10);
|
||||
$this->assertEquals(10, $channel->value());
|
||||
}
|
||||
|
||||
public function testNormalize(): void
|
||||
{
|
||||
$channel = new Channel(100);
|
||||
$this->assertEquals(1, $channel->normalize());
|
||||
$channel = new Channel(0);
|
||||
$this->assertEquals(0, $channel->normalize());
|
||||
$channel = new Channel(20);
|
||||
$this->assertEquals(.2, $channel->normalize());
|
||||
}
|
||||
|
||||
public function testValidate(): void
|
||||
{
|
||||
$this->expectException(ColorException::class);
|
||||
new Channel(101);
|
||||
|
||||
$this->expectException(ColorException::class);
|
||||
new Channel(-1);
|
||||
}
|
||||
}
|
47
tests/Colors/Rgb/ChannelTest.php
Normal file
47
tests/Colors/Rgb/ChannelTest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Tests\Colors\Rgb;
|
||||
|
||||
use Intervention\Image\Colors\Rgb\Channels\Red as Channel;
|
||||
use Intervention\Image\Exceptions\ColorException;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @requires extension gd
|
||||
* @covers \Intervention\Image\Colors\Rgb\Channels\Red
|
||||
* @covers \Intervention\Image\Colors\Rgb\Channels\Green
|
||||
* @covers \Intervention\Image\Colors\Rgb\Channels\Blue
|
||||
*/
|
||||
class ChannelTest extends TestCase
|
||||
{
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$channel = new Channel(0);
|
||||
$this->assertInstanceOf(Channel::class, $channel);
|
||||
}
|
||||
|
||||
public function testValue(): void
|
||||
{
|
||||
$channel = new Channel(10);
|
||||
$this->assertEquals(10, $channel->value());
|
||||
}
|
||||
|
||||
public function testNormalize(): void
|
||||
{
|
||||
$channel = new Channel(255);
|
||||
$this->assertEquals(1, $channel->normalize());
|
||||
$channel = new Channel(0);
|
||||
$this->assertEquals(0, $channel->normalize());
|
||||
$channel = new Channel(51);
|
||||
$this->assertEquals(.2, $channel->normalize());
|
||||
}
|
||||
|
||||
public function testValidate(): void
|
||||
{
|
||||
$this->expectException(ColorException::class);
|
||||
new Channel(256);
|
||||
|
||||
$this->expectException(ColorException::class);
|
||||
new Channel(-1);
|
||||
}
|
||||
}
|
48
tests/Colors/Rgba/ChannelTest.php
Normal file
48
tests/Colors/Rgba/ChannelTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Tests\Colors\Rgba;
|
||||
|
||||
use Intervention\Image\Colors\Rgba\Channels\Red as Channel;
|
||||
use Intervention\Image\Exceptions\ColorException;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @requires extension gd
|
||||
* @covers \Intervention\Image\Colors\Rgba\Channels\Red
|
||||
* @covers \Intervention\Image\Colors\Rgba\Channels\Green
|
||||
* @covers \Intervention\Image\Colors\Rgba\Channels\Blue
|
||||
* @covers \Intervention\Image\Colors\Rgba\Channels\Alpha
|
||||
*/
|
||||
class ChannelTest extends TestCase
|
||||
{
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$channel = new Channel(0);
|
||||
$this->assertInstanceOf(Channel::class, $channel);
|
||||
}
|
||||
|
||||
public function testValue(): void
|
||||
{
|
||||
$channel = new Channel(10);
|
||||
$this->assertEquals(10, $channel->value());
|
||||
}
|
||||
|
||||
public function testNormalize(): void
|
||||
{
|
||||
$channel = new Channel(255);
|
||||
$this->assertEquals(1, $channel->normalize());
|
||||
$channel = new Channel(0);
|
||||
$this->assertEquals(0, $channel->normalize());
|
||||
$channel = new Channel(51);
|
||||
$this->assertEquals(.2, $channel->normalize());
|
||||
}
|
||||
|
||||
public function testValidate(): void
|
||||
{
|
||||
$this->expectException(ColorException::class);
|
||||
new Channel(256);
|
||||
|
||||
$this->expectException(ColorException::class);
|
||||
new Channel(-1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user