drupalmoduleupgrader-8.x-1.5/tests/src/Unit/Plugin/DMU/Indexer/IndexerTestBase.php
tests/src/Unit/Plugin/DMU/Indexer/IndexerTestBase.php
<?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));
}
}
