@@ -14,6 +14,7 @@ class EncodeTest extends TestCase
14
14
private $ gif ;
15
15
private $ tif ;
16
16
private $ webp ;
17
+ private $ avif ;
17
18
18
19
public function setUp (): void
19
20
{
@@ -26,6 +27,10 @@ public function setUp(): void
26
27
$ this ->webp = $ manager ->canvas (100 , 100 )->encode ('webp ' );
27
28
}
28
29
30
+ if (function_exists ('imagecreatefromavif ' )) {
31
+ $ this ->avif = $ manager ->canvas (100 , 100 )->encode ('avif ' );
32
+ }
33
+
29
34
$ this ->manipulator = new Encode ();
30
35
}
31
36
@@ -64,6 +69,21 @@ public function testRun()
64
69
$ this ->assertSame ('image/webp ' , $ this ->manipulator ->setParams (['fm ' => 'webp ' ])->run ($ this ->gif )->mime );
65
70
$ this ->assertSame ('image/webp ' , $ this ->manipulator ->setParams (['fm ' => 'webp ' ])->run ($ this ->webp )->mime );
66
71
}
72
+ if (function_exists ('imagecreatefromavif ' )) {
73
+ $ this ->assertSame ('image/jpeg ' , $ this ->manipulator ->setParams (['fm ' => 'jpg ' ])->run ($ this ->avif )->mime );
74
+ $ this ->assertSame ('image/jpeg ' , $ this ->manipulator ->setParams (['fm ' => 'pjpg ' ])->run ($ this ->avif )->mime );
75
+ $ this ->assertSame ('image/png ' , $ this ->manipulator ->setParams (['fm ' => 'png ' ])->run ($ this ->avif )->mime );
76
+ $ this ->assertSame ('image/gif ' , $ this ->manipulator ->setParams (['fm ' => 'gif ' ])->run ($ this ->avif )->mime );
77
+ $ this ->assertSame ('image/avif ' , $ this ->manipulator ->setParams (['fm ' => 'avif ' ])->run ($ this ->jpg )->mime );
78
+ $ this ->assertSame ('image/avif ' , $ this ->manipulator ->setParams (['fm ' => 'avif ' ])->run ($ this ->png )->mime );
79
+ $ this ->assertSame ('image/avif ' , $ this ->manipulator ->setParams (['fm ' => 'avif ' ])->run ($ this ->gif )->mime );
80
+ $ this ->assertSame ('image/avif ' , $ this ->manipulator ->setParams (['fm ' => 'avif ' ])->run ($ this ->avif )->mime );
81
+ }
82
+
83
+ if (function_exists ('imagecreatefromwebp ' ) && function_exists ('imagecreatefromavif ' )) {
84
+ $ this ->assertSame ('image/webp ' , $ this ->manipulator ->setParams (['fm ' => 'webp ' ])->run ($ this ->avif )->mime );
85
+ $ this ->assertSame ('image/avif ' , $ this ->manipulator ->setParams (['fm ' => 'avif ' ])->run ($ this ->webp )->mime );
86
+ }
67
87
}
68
88
69
89
public function testGetFormat ()
@@ -78,6 +98,9 @@ public function testGetFormat()
78
98
if (function_exists ('imagecreatefromwebp ' )) {
79
99
$ mock ->shouldReceive ('mime ' )->andReturn ('image/webp ' )->once ();
80
100
}
101
+ if (function_exists ('imagecreatefromavif ' )) {
102
+ $ mock ->shouldReceive ('mime ' )->andReturn ('image/avif ' )->once ();
103
+ }
81
104
});
82
105
83
106
$ this ->assertSame ('jpg ' , $ this ->manipulator ->setParams (['fm ' => 'jpg ' ])->getFormat ($ image ));
@@ -93,6 +116,10 @@ public function testGetFormat()
93
116
if (function_exists ('imagecreatefromwebp ' )) {
94
117
$ this ->assertSame ('webp ' , $ this ->manipulator ->setParams (['fm ' => null ])->getFormat ($ image ));
95
118
}
119
+
120
+ if (function_exists ('imagecreatefromavif ' )) {
121
+ $ this ->assertSame ('avif ' , $ this ->manipulator ->setParams (['fm ' => null ])->getFormat ($ image ));
122
+ }
96
123
}
97
124
98
125
public function testGetQuality ()
0 commit comments