/**
  * Tests getHandler() without an override.
  */
 public function testGetHandlerNoOverride()
 {
     $this->setupMockedFactory();
     $item = [];
     $item['table'] = 'test_table';
     $item['field'] = 'test_field';
     $views_data = [];
     $views_data['test_field']['test']['id'] = 'test_id';
     $this->viewsData->expects($this->once())->method('get')->with('test_table')->willReturn($views_data);
     $plugin = $this->getMock('Drupal\\views\\Plugin\\views\\ViewsHandlerInterface');
     $this->factory->expects($this->once())->method('createInstance')->with('test_id')->willReturn($plugin);
     $result = $this->handlerManager->getHandler($item);
     $this->assertSame($plugin, $result);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function query()
 {
     // The table doesn't exist until a moderated node has been saved at least
     // once. Just in case, disable this filter until then. Note that this means
     // the view will still show all revisions, not just latest, but this is
     // sufficiently edge-case-y that it's probably not worth the time to
     // handle more robustly.
     if (!$this->connection->schema()->tableExists('content_revision_tracker')) {
         return;
     }
     $table = $this->ensureMyTable();
     /** @var \Drupal\views\Plugin\views\query\Sql $query */
     $query = $this->query;
     $definition = $this->entityTypeManager->getDefinition($this->getEntityType());
     $keys = $definition->getKeys();
     $definition = ['table' => 'content_revision_tracker', 'type' => 'INNER', 'field' => 'entity_id', 'left_table' => $table, 'left_field' => $keys['id'], 'extra' => [['left_field' => $keys['langcode'], 'field' => 'langcode'], ['left_field' => $keys['revision'], 'field' => 'revision_id'], ['field' => 'entity_type', 'value' => $this->getEntityType()]]];
     $join = $this->joinHandler->createInstance('standard', $definition);
     $query->ensureTable('content_revision_tracker', $this->relationship, $join);
 }
 /**
  * Tests that hook_views_plugins_TYPE_alter() is invoked for a handler type.
  *
  * @covers ::__construct
  * @covers ::getDefinitions
  */
 public function testAlterHookInvocation()
 {
     $this->moduleHandler->expects($this->once())->method('alter')->with('views_plugins_test', array());
     $this->handlerManager->getDefinitions();
 }