Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / tests / src / Unit / Plugin / DMU / Indexer / IndexerTestBase.php
diff --git a/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Indexer/IndexerTestBase.php b/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Indexer/IndexerTestBase.php
new file mode 100644 (file)
index 0000000..97c6956
--- /dev/null
@@ -0,0 +1,46 @@
+<?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);
+  }
+
+  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($collection->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));
+  }
+
+}