コード例 #1
0
 /**
  * {@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);
 }
コード例 #2
0
 /**
  * Tests the source defines a valid ID.
  */
 public function testSourceId()
 {
     $this->assertNotEmpty($this->source->getIds());
 }
コード例 #3
0
 /**
  * Test the source returns the row count expected.
  */
 public function testSourceCount()
 {
     $this->assertEquals($this->source->count(), $this->expectedCount);
 }