fix: validate icons to be images (#1167)

This commit is contained in:
Attila Kerekes
2023-06-05 18:27:30 +02:00
committed by GitHub
parent 7d016cdaa6
commit 5d67f570a9
8 changed files with 74 additions and 1 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace Tests\Unit\helpers;
use Tests\TestCase;
class IsImageTest extends TestCase
{
/**
* @return void
*/
public function test_isImage_returns_false_when_file_is_not_image()
{
$actual = isImage("<?php ?>");
$this->assertFalse($actual);
}
/**
* @return void
*/
public function test_isImage_returns_true_when_file_is_image()
{
$file = file_get_contents(__DIR__ . '/fixtures/heimdall-icon-small.png');
$actual = isImage($file);
$this->assertTrue($actual);
}
/**
* @return void
*/
public function test_isImage_returns_false_when_file_is_php_but_png()
{
$file = file_get_contents(__DIR__ . '/fixtures/heimdall-icon-small-php.php');
$actual = isImage($file);
$this->assertTrue($actual);
}
}