class EntityReverseJoinTest

Tests the EntityReverse join plugin.

@group views

Hierarchy

Expanded class hierarchy of EntityReverseJoinTest

See also

\Drupal\views\Plugin\views\relationship\EntityReverse

File

core/modules/views/tests/src/Kernel/Plugin/EntityReverseJoinTest.php, line 16

Namespace

Drupal\Tests\views\Kernel\Plugin
View source
class EntityReverseJoinTest extends RelationshipJoinTestBase {
    
    /**
     * {@inheritdoc}
     */
    public static $testViews = [
        'test_view',
    ];
    
    /**
     * Tests that the EntityReverse plugin loads the correct join plugin.
     */
    public function testJoinThroughRelationship() : void {
        $relationship_manager = $this->container
            ->get('plugin.manager.views.relationship');
        // Setup a simple join and test the result sql.
        $view = Views::getView('test_view');
        $view->initDisplay();
        $view->initQuery();
        $configuration = [
            'id' => 'entity_reverse',
            'base' => 'users_field_data',
            'table' => 'users_field_data',
            'field table' => 'users_field_data',
            'field field' => 'uid',
            'base field' => 'uid',
            'field_name' => 'uid',
            'join_id' => 'join_test',
        ];
        $relationship = $relationship_manager->createInstance('entity_reverse', $configuration);
        $relationship->tableAlias = 'users_field_data';
        $relationship->table = 'users_field_data';
        $relationship->query = $view->getQuery();
        $relationship->query();
        $this->assertInstanceOf(JoinTest::class, $relationship->query
            ->getTableQueue()[$relationship->alias]['join']);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
EntityReverseJoinTest::$testViews public static property
EntityReverseJoinTest::testJoinThroughRelationship public function Tests that the EntityReverse plugin loads the correct join plugin.
RelationshipJoinTestBase::$modules protected static property
RelationshipJoinTestBase::$rootUser protected property
RelationshipJoinTestBase::schemaDefinition protected function Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition().
RelationshipJoinTestBase::setUpFixtures protected function
RelationshipJoinTestBase::viewsData protected function Overrides \Drupal\views\Tests\ViewTestBase::viewsData(). 1

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.