Adjust tests to bit boot kernel
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Pcm\IconBundle\Tests\Twig\Functions;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Pcm\IconBundle\DependencyInjection\PcmIconExtension;
|
||||
use Pcm\IconBundle\Tests\TestKernel;
|
||||
use Pcm\IconBundle\Twig\Functions\IconExtension;
|
||||
@@ -21,9 +22,7 @@ class IconExtensionTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$kernel = new TestKernel('test', true);
|
||||
$kernel->boot();
|
||||
$this->icon = $kernel->getContainer()->get('pcm_icon.icon_extension');
|
||||
$this->icon = new IconExtension(['tests/icons']);
|
||||
}
|
||||
|
||||
public function testInstanceOf(): void
|
||||
@@ -31,14 +30,23 @@ class IconExtensionTest extends TestCase
|
||||
$this->assertInstanceOf(IconExtension::class, $this->icon);
|
||||
}
|
||||
|
||||
public function testDirectoriesArrayGetsInjected(): void
|
||||
public function testThrowsIfDirectoriesIsEmpty(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass($this->icon);
|
||||
$property = $reflection->getProperty('directories');
|
||||
$directories = $property->getValue($this->icon);
|
||||
$this->assertIsArray($directories);
|
||||
$this->assertCount(1, $directories);
|
||||
$this->assertStringContainsString('tests/icons', $directories[0]);
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
new IconExtension([]);
|
||||
}
|
||||
|
||||
public function testThrowsIfDirectoriesContainsNonString(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
new IconExtension([99]);
|
||||
}
|
||||
|
||||
|
||||
public function testThrowsIfDirectoriesContainsNonStringAmongStrings(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
new IconExtension(['string', 99, 'string']);
|
||||
}
|
||||
|
||||
public function testThrowsWhenPassedAnInvalidIconName(): void
|
||||
|
||||
Reference in New Issue
Block a user