[TESTS] Raise App\Util\HTML test coverage to 100%

This commit is contained in:
2021-05-02 21:02:43 +00:00
parent fbea08ca9b
commit a49ee453ab
2 changed files with 16 additions and 7 deletions

View File

@@ -20,15 +20,22 @@
namespace App\Tests\Util;
use App\Util\HTML;
use Jchook\AssertThrows\AssertThrows;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class HTMLTest extends WebTestCase
{
use AssertThrows;
public function testHTML()
{
static::assertSame('', HTML::html(''));
static::assertSame("<a>\n\n</a>\n", HTML::html(['a' => '']));
static::assertSame("<a>\n <p>\n </p>\n</a>\n", HTML::html(['a' => ['p' => '']]));
static::assertSame("<a href=\"test\">\n <p>\n </p>\n</a>\n", HTML::html(['a' => ['attrs' => ['href' => 'test'], 'p' => '']]));
static::assertSame("<a>\n <p>\n foo\n </p>\n <br/>\n</a>\n", HTML::html(['a' => ['p' => 'foo', 'br' => 'empty']]));
static::assertThrows(\InvalidArgumentException::class, fn () => HTML::html(1));
static::assertSame("<a href=\"test\">\n foo\n</a>", implode("\n", HTML::tag('a', ['href' => 'test'], content: 'foo', empty_tag: false)));
static::assertSame('<br/>', implode("\n", HTML::tag('br', attrs: null, content: null, empty_tag: true)));
}
}