reviewer-1.2.x-dev/tests/src/Kernel/Checklist/ChecklistFactoryTest.php
tests/src/Kernel/Checklist/ChecklistFactoryTest.php
<?php
declare(strict_types=1);
namespace Drupal\Tests\reviewer\Kernel\Checklist;
use Drupal\KernelTests\KernelTestBase;
use Drupal\reviewer\Reviewer\Checklist\ChecklistFactory;
use Drupal\reviewer_test\Plugin\reviewer\Checklist\TestChecklist;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
/**
* Test checklist factory methods.
*/
#[Group('reviewer')]
#[CoversClass(ChecklistFactory::class)]
class ChecklistFactoryTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'reviewer',
];
/**
* Test that passing a non-checklist class throws an exception.
*
* @throws \Exception
*/
public function testCreate(): void {
$factory = $this->container->get('reviewer.factory.checklist');
self::expectException(\InvalidArgumentException::class);
// We are deliberately passing an incorrect argument, so ignore the error.
// @phpstan-ignore argument.type
$factory->create(\stdClass::class);
try {
$factory->create(TestChecklist::class);
}
catch (\InvalidArgumentException) {
self::fail('Exception thrown when creating a valid checklist.');
}
}
}
