Skip to content

Commit

Permalink
Switch test data providers to generators
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Nov 12, 2024
1 parent f26e439 commit a5b1645
Show file tree
Hide file tree
Showing 17 changed files with 655 additions and 637 deletions.
43 changes: 21 additions & 22 deletions tests/Unit/Colors/Hsl/Decoders/StringColorDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Intervention\Image\Tests\Unit\Colors\Hsl\Decoders;

use Generator;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Colors\Hsl\Color;
Expand All @@ -24,29 +25,27 @@ public function testDecode(string $input, string $classname, array $channelValue
$this->assertEquals($channelValues, $result->toArray());
}

public static function decodeDataProvier(): array
public static function decodeDataProvier(): Generator
{
return [
[
'hsl(0,0,0)',
Color::class,
[0, 0, 0],
],
[
'hsl(0, 100, 50)',
Color::class,
[0, 100, 50],
],
[
'hsl(360, 100, 50)',
Color::class,
[360, 100, 50],
],
[
'hsl(180, 100%, 50%)',
Color::class,
[180, 100, 50],
]
yield [
'hsl(0,0,0)',
Color::class,
[0, 0, 0],
];
yield [
'hsl(0, 100, 50)',
Color::class,
[0, 100, 50],
];
yield [
'hsl(360, 100, 50)',
Color::class,
[360, 100, 50],
];
yield [
'hsl(180, 100%, 50%)',
Color::class,
[180, 100, 50],
];
}
}
83 changes: 41 additions & 42 deletions tests/Unit/Colors/Hsv/Decoders/StringColorDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Intervention\Image\Tests\Unit\Colors\Hsv\Decoders;

use Generator;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Colors\Hsv\Color;
Expand All @@ -24,49 +25,47 @@ public function testDecodeHsv(string $input, string $classname, array $channelVa
$this->assertEquals($channelValues, $result->toArray());
}

public static function decodeDataProvier(): array
public static function decodeDataProvier(): Generator
{
return [
[
'hsv(0,0,0)',
Color::class,
[0, 0, 0],
],
[
'hsv(0, 100, 100)',
Color::class,
[0, 100, 100],
],
[
'hsv(360, 100, 100)',
Color::class,
[360, 100, 100],
],
[
'hsv(180, 100%, 100%)',
Color::class,
[180, 100, 100],
],
[
'hsb(0,0,0)',
Color::class,
[0, 0, 0],
],
[
'hsb(0, 100, 100)',
Color::class,
[0, 100, 100],
],
[
'hsb(360, 100, 100)',
Color::class,
[360, 100, 100],
],
[
'hsb(180, 100%, 100%)',
Color::class,
[180, 100, 100],
],
yield [
'hsv(0,0,0)',
Color::class,
[0, 0, 0],
];
yield [
'hsv(0, 100, 100)',
Color::class,
[0, 100, 100],
];
yield [
'hsv(360, 100, 100)',
Color::class,
[360, 100, 100],
];
yield [
'hsv(180, 100%, 100%)',
Color::class,
[180, 100, 100],
];
yield [
'hsb(0,0,0)',
Color::class,
[0, 0, 0],
];
yield [
'hsb(0, 100, 100)',
Color::class,
[0, 100, 100],
];
yield [
'hsb(360, 100, 100)',
Color::class,
[360, 100, 100],
];
yield [
'hsb(180, 100%, 100%)',
Color::class,
[180, 100, 100],
];
}
}
103 changes: 51 additions & 52 deletions tests/Unit/Colors/Rgb/Decoders/HexColorDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Intervention\Image\Tests\Unit\Colors\Rgb\Decoders;

use Generator;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Colors\Rgb\Color;
Expand All @@ -24,59 +25,57 @@ public function testDecode(string $input, string $classname, array $channelValue
$this->assertEquals($channelValues, $result->toArray());
}

public static function decodeDataProvier(): array
public static function decodeDataProvier(): Generator
{
return [
[
'ccc',
Color::class,
[204, 204, 204, 255]
],
[
'ccff33',
Color::class,
[204, 255, 51, 255],
],
[
'#ccc',
Color::class,
[204, 204, 204, 255],
],
[
'cccccc',
Color::class,
[204, 204, 204, 255],
],
[
'#cccccc',
Color::class,
[204, 204, 204, 255],
],
[
'#ccccccff',
Color::class,
[204, 204, 204, 255],
],
[
'#cccf',
Color::class,
[204, 204, 204, 255],
],
[
'ccccccff',
Color::class,
[204, 204, 204, 255],
],
[
'cccf',
Color::class,
[204, 204, 204, 255],
],
[
'#b53717aa',
Color::class,
[181, 55, 23, 170],
],
yield [
'ccc',
Color::class,
[204, 204, 204, 255]
];
yield [
'ccff33',
Color::class,
[204, 255, 51, 255],
];
yield [
'#ccc',
Color::class,
[204, 204, 204, 255],
];
yield [
'cccccc',
Color::class,
[204, 204, 204, 255],
];
yield [
'#cccccc',
Color::class,
[204, 204, 204, 255],
];
yield [
'#ccccccff',
Color::class,
[204, 204, 204, 255],
];
yield [
'#cccf',
Color::class,
[204, 204, 204, 255],
];
yield [
'ccccccff',
Color::class,
[204, 204, 204, 255],
];
yield [
'cccf',
Color::class,
[204, 204, 204, 255],
];
yield [
'#b53717aa',
Color::class,
[181, 55, 23, 170],
];
}
}
33 changes: 16 additions & 17 deletions tests/Unit/Colors/Rgb/Decoders/HtmlColornameDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Intervention\Image\Tests\Unit\Colors\Rgb\Decoders;

use Generator;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Colors\Rgb\Color;
Expand All @@ -24,24 +25,22 @@ public function testDecode(string $input, string $classname, array $channelValue
$this->assertEquals($channelValues, $result->toArray());
}

public static function decodeDataProvier(): array
public static function decodeDataProvier(): Generator
{
return [
[
'salmon',
Color::class,
[250, 128, 114, 255],
],
[
'khaki',
Color::class,
[240, 230, 140, 255],
],
[
'peachpuff',
Color::class,
[255, 218, 185, 255],
]
yield [
'salmon',
Color::class,
[250, 128, 114, 255],
];
yield [
'khaki',
Color::class,
[240, 230, 140, 255],
];
yield [
'peachpuff',
Color::class,
[255, 218, 185, 255],
];
}
}
Loading

0 comments on commit a5b1645

Please sign in to comment.