reviewer-1.2.x-dev/tests/src/Unit/AttributeTest.php

tests/src/Unit/AttributeTest.php
<?php

declare(strict_types=1);

namespace Drupal\Tests\reviewer\Unit;

use Drupal\reviewer\Attribute\Checklist;
use Drupal\reviewer\Attribute\Task;
use Drupal\reviewer\Reviewer\Task\TaskBase as TaskBase;
use Drupal\Tests\UnitTestCase;

/**
 * Test reviewer attributes.
 */
final class AttributeTest extends UnitTestCase {

  /**
   * Test task attributes.
   */
  public function testTask(): void {
    // Test that the task ID returns correctly.
    self::assertSame('test', (new Task('test'))->getId());
    self::assertSame('', (new Task(''))->getId());
    // Test that a task with no ID set throws an exception.
    self::expectException(\InvalidArgumentException::class);
    (new Task())->getId();
  }

  /**
   * Test checklist attributes.
   *
   * @throws \PHPUnit\Framework\MockObject\Exception
   */
  public function testChecklist(): void {
    $tasks = [$this->createMock(TaskBase::class)::class];
    // Test that the checklist tasks return correctly.
    self::assertSame($tasks, (new Checklist('test', $tasks))->getTasks());
    // Test that the checklist with non-task class task throws an exception.
    self::expectException(\InvalidArgumentException::class);
    // We are deliberately passing an incorrect argument, so ignore the error.
    // @phpstan-ignore argument.type
    (new Checklist('test', array_merge($tasks, [(new \stdClass())::class])))->getTasks();
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc