diff --git a/src/AnimeClient/Helper/Picture.php b/src/AnimeClient/Helper/Picture.php
index 32334ebd..0c36abd0 100644
--- a/src/AnimeClient/Helper/Picture.php
+++ b/src/AnimeClient/Helper/Picture.php
@@ -25,22 +25,6 @@ final class Picture {
use ContainerAware;
- private const MIME_MAP = [
- 'apng' => 'image/vnd.mozilla.apng',
- 'bmp' => 'image/bmp',
- 'gif' => 'image/gif',
- 'ico' => 'image/x-icon',
- 'jpeg' => 'image/jpeg',
- 'jpf' => 'image/jpx',
- 'jpg' => 'image/jpeg',
- 'jpx' => 'image/jpx',
- 'png' => 'image/png',
- 'svg' => 'image/svg+xml',
- 'tif' => 'image/tiff',
- 'tiff' => 'image/tiff',
- 'webp' => 'image/webp',
- ];
-
private const SIMPLE_IMAGE_TYPES = [
'gif',
'jpeg',
@@ -82,22 +66,34 @@ final class Picture {
$ext = array_pop($urlParts);
$path = implode('.', $urlParts);
- $mime = array_key_exists($ext, static::MIME_MAP)
- ? static::MIME_MAP[$ext]
- : 'image/jpeg';
+ $mime = match ($ext) {
+ 'avif' => 'image/avif',
+ 'apng' => 'image/vnd.mozilla.apng',
+ 'bmp' => 'image/bmp',
+ 'gif' => 'image/gif',
+ 'ico' => 'image/x-icon',
+ 'jpf', 'jpx' => 'image/jpx',
+ 'png' => 'image/png',
+ 'svg' => 'image/svg+xml',
+ 'tif', 'tiff' => 'image/tiff',
+ 'webp' => 'image/webp',
+ default => 'image/jpeg',
+ };
- $fallbackMime = array_key_exists($fallbackExt, static::MIME_MAP)
- ? static::MIME_MAP[$fallbackExt]
- : 'image/jpeg';
+ $fallbackMime = match ($fallbackExt) {
+ 'gif' => 'image/gif',
+ 'png' => 'image/png',
+ default => 'image/jpeg',
+ };
// For image types that are well-established, just return a
// simple element instead
if (
$ext === $fallbackExt ||
- \in_array($ext, static::SIMPLE_IMAGE_TYPES, TRUE)
+ \in_array($ext, Picture::SIMPLE_IMAGE_TYPES, TRUE)
)
{
- $attrs = ( ! empty($imgAttrs))
+ $attrs = (count($imgAttrs) > 1)
? $imgAttrs
: $picAttrs;
diff --git a/tests/AnimeClient/Helper/FormHelperTest.php b/tests/AnimeClient/Helper/FormHelperTest.php
new file mode 100644
index 00000000..7db90484
--- /dev/null
+++ b/tests/AnimeClient/Helper/FormHelperTest.php
@@ -0,0 +1,37 @@
+
+ * @copyright 2015 - 2021 Timothy J. Warren
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @version 5.2
+ * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
+ */
+
+namespace Aviat\AnimeClient\Tests\Helper;
+
+use Aviat\AnimeClient\Helper\Form as FormHelper;
+use Aviat\AnimeClient\Tests\AnimeClientTestCase;
+
+class FormHelperTest extends AnimeClientTestCase {
+ public function testFormHelper(): void
+ {
+ $helper = new FormHelper();
+ $helper->setContainer($this->container);
+
+ $actual = $helper('input', [
+ 'type' => 'text',
+ 'value' => 'foo',
+ 'placeholder' => 'field',
+ 'name' => 'test'
+ ]);
+
+ $this->assertMatchesSnapshot($actual);
+ }
+}
\ No newline at end of file
diff --git a/tests/AnimeClient/Helper/PictureHelperTest.php b/tests/AnimeClient/Helper/PictureHelperTest.php
index 9df0f61c..48a35c4d 100644
--- a/tests/AnimeClient/Helper/PictureHelperTest.php
+++ b/tests/AnimeClient/Helper/PictureHelperTest.php
@@ -22,53 +22,55 @@ use Aviat\AnimeClient\Tests\AnimeClientTestCase;
class PictureHelperTest extends AnimeClientTestCase {
/**
* @dataProvider dataPictureCase
+ * @param array $params
*/
- public function testPictureHelper($params, $expected = NULL)
+ public function testPictureHelper(array $params): void
{
$helper = new PictureHelper();
$helper->setContainer($this->container);
$actual = $helper(...$params);
- if ($expected === NULL)
- {
- $this->assertMatchesSnapshot($actual);
- }
- else
- {
- $this->assertEquals($expected, $actual);
- }
+ $this->assertMatchesSnapshot($actual);
}
/**
* @dataProvider dataSimpleImageCase
+ * @param string $ext
+ * @param bool $isSimple
+ * @param string $fallbackExt
*/
- public function testSimpleImage(string $ext, bool $isSimple)
+ public function testSimpleImage(string $ext, bool $isSimple, string $fallbackExt = 'jpg'): void
{
$helper = new PictureHelper();
$helper->setContainer($this->container);
$url = "https://example.com/image.{$ext}";
- $actual = $helper($url);
+ $actual = $helper($url, $fallbackExt);
- $actuallySimple = strpos($actual, '