-
-
Notifications
You must be signed in to change notification settings - Fork 189
/
Copy pathImageRotatorTest.php
66 lines (51 loc) · 1.38 KB
/
ImageRotatorTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace Rubix\ML\Tests\Transformers;
use Rubix\ML\Datasets\Unlabeled;
use Rubix\ML\Transformers\ImageRotator;
use Rubix\ML\Transformers\Transformer;
use PHPUnit\Framework\TestCase;
/**
* @group Transformers
* @requires extension gd
* @covers \Rubix\ML\Transformers\ImageRotator
*/
class ImageRotatorTest extends TestCase
{
/**
* @var ImageRotator
*/
protected ImageRotator $transformer;
/**
* @before
*/
protected function setUp() : void
{
$this->transformer = new ImageRotator(0.0, 1.0);
}
/**
* @test
*/
public function build() : void
{
$this->assertInstanceOf(ImageRotator::class, $this->transformer);
$this->assertInstanceOf(Transformer::class, $this->transformer);
}
/**
* @test
*/
public function transform() : void
{
$dataset = Unlabeled::quick([
[imagecreatefrompng('./tests/test.png'), 'whatever', 69],
]);
$mock = $this->createPartialMock(ImageRotator::class, ['rotationAngle']);
$mock->method('rotationAngle')->will($this->returnValue(-180.0));
$dataset->apply($mock);
$sample = $dataset->sample(0);
ob_start();
imagepng($sample[0]);
$raw = ob_get_clean();
$expected = file_get_contents('./tests/test_rotated.png');
$this->assertEquals($expected, $raw);
}
}