You are here

IndexerTestBase.php in Drupal 7 to 8/9 Module Upgrader 8

File

tests/src/Unit/Plugin/DMU/Indexer/IndexerTestBase.php
View source
<?php

namespace Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Indexer;

use Drupal\Tests\drupalmoduleupgrader\Unit\TestBase;

/**
 * Base class for tests of DMU's indexer plugins. Because the indexers'
 * behavior is so standard, this class reflects that by implementing a lot
 * of standard assertions.
 */
abstract class IndexerTestBase extends TestBase {

  /**
   * @var \Drupal\drupalmoduleupgrader\IndexerInterface
   */
  protected $indexer;
  public function testClear() {
    $this->indexer
      ->clear();
    $this
      ->assertCount(0, $this->indexer
      ->getAll());
  }
  public function testHas() {
    $this
      ->assertTrue($this->indexer
      ->has($this->info['class']['expectID'][0]));
    $this
      ->assertFalse($this->indexer
      ->has(uniqid()));
  }
  public function testGet() {
    $node = $this->indexer
      ->get($this->info['class']['expectID'][0]);
    $this
      ->assertFalse($node
      ->isEmpty());
    $this
      ->assertInstanceOf($this->info['class']['expectType'][0], $node);
  }

  /**
   * @depends testHas
   */
  public function testDelete() {
    $id = $this->info['class']['expectID'][0];
    $this->indexer
      ->delete($id);
    $this
      ->assertFalse($this->indexer
      ->has($id));
  }

}

Classes

Namesort descending Description
IndexerTestBase Base class for tests of DMU's indexer plugins. Because the indexers' behavior is so standard, this class reflects that by implementing a lot of standard assertions.