/** * {@inheritdoc} */ protected function setUp() { $module_handler = $this->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface'); $migration = $this->getMigration(); $migration->expects($this->any())->method('getHighwater')->will($this->returnValue(static::ORIGINAL_HIGHWATER)); // Need the test class, not the original because we need a setDatabase method. This is not pretty :/ $plugin_class = preg_replace('/^(Drupal\\\\\\w+\\\\)Plugin\\\\migrate(\\\\source(\\\\.+)?\\\\)([^\\\\]+)$/', '\\1Tests\\2Test\\4', static::PLUGIN_CLASS); $plugin = new $plugin_class($this->migrationConfiguration['source'], $this->migrationConfiguration['source']['plugin'], array(), $migration); $plugin->setDatabase($this->getDatabase($this->databaseContents + array('test_map' => array()))); $plugin->setModuleHandler($module_handler); $plugin->setStringTranslation($this->getStringTranslationStub()); $migration->expects($this->any())->method('getSourcePlugin')->will($this->returnValue($plugin)); $migrateExecutable = $this->getMockBuilder('Drupal\\migrate\\MigrateExecutable')->disableOriginalConstructor()->getMock(); $this->source = new TestSource($migration, $migrateExecutable); $cache = $this->getMock('Drupal\\Core\\Cache\\CacheBackendInterface'); $this->source->setCache($cache); }
/** * Tests the source defines a valid ID. */ public function testSourceId() { $this->assertNotEmpty($this->source->getIds()); }
/** * Test the source returns the row count expected. */ public function testSourceCount() { $this->assertEquals($this->source->count(), $this->expectedCount); }