diff --git a/src/Tests/Views/DynamicEntityReferenceBaseFieldRelationshipTest.php b/src/Tests/Views/DynamicEntityReferenceBaseFieldRelationshipTest.php index 1ba40c7..9af6bf0 100644 --- a/src/Tests/Views/DynamicEntityReferenceBaseFieldRelationshipTest.php +++ b/src/Tests/Views/DynamicEntityReferenceBaseFieldRelationshipTest.php @@ -170,7 +170,8 @@ class DynamicEntityReferenceBaseFieldRelationshipTest extends ViewKernelTestBase $this->assertEqual($views_data_entity_test_mul['reverse__entity_test_mul__dynamic_references']['relationship']['extra'][0]['field'], 'dynamic_references__target_type'); $this->assertEqual($views_data_entity_test_mul['reverse__entity_test_mul__dynamic_references']['relationship']['extra'][0]['value'], 'entity_test_mul'); - // Check an actual test view. + // Check an actual base table entity view with base table entity for + // single value der base field. $view = Views::getView('test_dynamic_entity_reference_entity_test_view'); $this->executeView($view); $ids = [2, 3]; @@ -198,6 +199,8 @@ class DynamicEntityReferenceBaseFieldRelationshipTest extends ViewKernelTestBase } $view->destroy(); + // Check an actual base table entity view with data table entity for + // single value der base field. $view->setDisplay('embed_1'); $this->executeView($view); @@ -225,6 +228,8 @@ class DynamicEntityReferenceBaseFieldRelationshipTest extends ViewKernelTestBase } $view->destroy(); + // Check the backwards reference view of base table entity with base table + // entity for single value der base field. $view->setDisplay('embed_2'); $this->executeView($view); @@ -242,6 +247,8 @@ class DynamicEntityReferenceBaseFieldRelationshipTest extends ViewKernelTestBase $this->assertEqual($row->_relationship_entities['reverse__entity_test__dynamic_references']->bundle(), 'entity_test'); $view->destroy(); + // Check the backwards reference view of base table entity with base table + // entity for single value der base field. $view->setDisplay('embed_3'); $this->executeView($view); @@ -259,7 +266,8 @@ class DynamicEntityReferenceBaseFieldRelationshipTest extends ViewKernelTestBase $this->assertEqual($row->_relationship_entities['reverse__entity_test_mul__dynamic_references']->bundle(), 'entity_test_mul'); $view->destroy(); - // Check an actual test view. + // Check an actual data table entity view with data table entity for + // single value der base field. $view = Views::getView('test_dynamic_entity_reference_entity_test_mul_view'); $this->executeView($view); $ids = [2, 3]; @@ -287,6 +295,8 @@ class DynamicEntityReferenceBaseFieldRelationshipTest extends ViewKernelTestBase } $view->destroy(); + // Check an actual data table entity view with base table entity for + // single value der base field. $view->setDisplay('embed_1'); $this->executeView($view); @@ -314,6 +324,8 @@ class DynamicEntityReferenceBaseFieldRelationshipTest extends ViewKernelTestBase } $view->destroy(); + // Check the backwards reference view of data table entity with data table + // entity for single value der base field. $view->setDisplay('embed_2'); $this->executeView($view); @@ -331,6 +343,8 @@ class DynamicEntityReferenceBaseFieldRelationshipTest extends ViewKernelTestBase $this->assertEqual($row->_relationship_entities['reverse__entity_test_mul__dynamic_references']->bundle(), 'entity_test_mul'); $view->destroy(); + // Check the backwards reference view of data table entity with base table + // entity for single value der base field. $view->setDisplay('embed_3'); $this->executeView($view); @@ -491,7 +505,158 @@ class DynamicEntityReferenceBaseFieldRelationshipTest extends ViewKernelTestBase $this->assertEqual($views_data_entity_test_mul['reverse__entity_test_mul__dynamic_references']['relationship']['field field'], 'dynamic_references_target_id'); $this->assertEqual($views_data_entity_test_mul['reverse__entity_test_mul__dynamic_references']['relationship']['join_extra'][0]['field'], 'dynamic_references_target_type'); $this->assertEqual($views_data_entity_test_mul['reverse__entity_test_mul__dynamic_references']['relationship']['join_extra'][0]['value'], 'entity_test_mul'); - // Check an actual test view. + + // Check an actual base table entity view with base table entity for + // multiple value der base field. + $view = Views::getView('test_dynamic_entity_reference_mul_entity_test_view'); + $this->executeView($view); + $ids = [2, 3]; + foreach ($view->result as $index => $row) { + // Just check that the actual ID of the entity is the expected one. + $this->assertEqual($row->id, $ids[$index]); + // Also check that we have the correct result entity. + $this->assertEqual($row->_entity->id(), $ids[$index]); + $this->assertEqual($row->_entity->bundle(), 'entity_test'); + // Test the relationship. + $this->assertEqual($row->entity_test_entity_test__dynamic_references_id, 1); + + // Test that the correct relationship entity is on the row. + $this->assertEqual($row->_relationship_entities['entity_test__dynamic_references']->id(), 1); + $this->assertEqual($row->_relationship_entities['entity_test__dynamic_references']->bundle(), 'entity_test'); + } + + $view->destroy(); + // Check an actual base table entity view with data table entity for + // multiple value der base field. + $view->setDisplay('embed_1'); + $this->executeView($view); + foreach ($view->result as $index => $row) { + // Just check that the actual ID of the entity is the expected one. + $this->assertEqual($row->id, $ids[$index]); + // Also check that we have the correct result entity. + $this->assertEqual($row->_entity->id(), $ids[$index]); + $this->assertEqual($row->_entity->bundle(), 'entity_test'); + // Test the relationship. + $this->assertEqual($row->entity_test_mul_property_data_entity_test__dynamic_reference, 1); + + // Test that the correct relationship entity is on the row. + $this->assertEqual($row->_relationship_entities['entity_test_mul__dynamic_references']->id(), 1); + $this->assertEqual($row->_relationship_entities['entity_test_mul__dynamic_references']->bundle(), 'entity_test_mul'); + } + + $view->destroy(); + // Check the backwards reference view of base table entity with base table + // entity for multiple value der base field. + $view->setDisplay('embed_2'); + $this->executeView($view); + foreach ($view->result as $index => $row) { + // Just check that the actual ID of the entity is the expected one. + $this->assertEqual($row->id, 1); + // Also check that we have the correct result entity. + $this->assertEqual($row->_entity->id(), 1); + $this->assertEqual($row->_entity->bundle(), 'entity_test'); + // Test the relationship. + $this->assertEqual($row->dynamic_references_entity_test_id, $ids[$index]); + + // Test that the correct relationship entity is on the row. + $this->assertEqual($row->_relationship_entities['reverse__entity_test__dynamic_references']->id(), $ids[$index]); + $this->assertEqual($row->_relationship_entities['reverse__entity_test__dynamic_references']->bundle(), 'entity_test'); + } + + $view->destroy(); + // Check the backwards reference view of base table entity with data table + // entity for multiple value der base field. + $view->setDisplay('embed_3'); + $this->executeView($view); + foreach ($view->result as $index => $row) { + // Just check that the actual ID of the entity is the expected one. + $this->assertEqual($row->id, 1); + // Also check that we have the correct result entity. + $this->assertEqual($row->_entity->id(), 1); + $this->assertEqual($row->_entity->bundle(), 'entity_test'); + // Test the relationship. + $this->assertEqual($row->dynamic_references_entity_test_id, $ids[$index]); + + // Test that the correct relationship entity is on the row. + $this->assertEqual($row->_relationship_entities['reverse__entity_test_mul__dynamic_references']->id(), $ids[$index]); + $this->assertEqual($row->_relationship_entities['reverse__entity_test_mul__dynamic_references']->bundle(), 'entity_test_mul'); + } + + // Check an actual data table entity view with data table entity for + // multiple value der base field. + $view = Views::getView('test_dynamic_entity_reference_mul_entity_test_mul_view'); + $this->executeView($view); + foreach ($view->result as $index => $row) { + // Just check that the actual ID of the entity is the expected one. + $this->assertEqual($row->id, $ids[$index]); + // Also check that we have the correct result entity. + $this->assertEqual($row->_entity->id(), $ids[$index]); + $this->assertEqual($row->_entity->bundle(), 'entity_test_mul'); + // Test the relationship. + $this->assertEqual($row->entity_test_mul_property_data_entity_test_mul__dynamic_refer, 1); + + // Test that the correct relationship entity is on the row. + $this->assertEqual($row->_relationship_entities['entity_test_mul__dynamic_references']->id(), 1); + $this->assertEqual($row->_relationship_entities['entity_test_mul__dynamic_references']->bundle(), 'entity_test_mul'); + } + + $view->destroy(); + // Check an actual data table entity view with base table entity for + // multiple value der base field. + $view->setDisplay('embed_1'); + $this->executeView($view); + foreach ($view->result as $index => $row) { + // Just check that the actual ID of the entity is the expected one. + $this->assertEqual($row->id, $ids[$index]); + // Also check that we have the correct result entity. + $this->assertEqual($row->_entity->id(), $ids[$index]); + $this->assertEqual($row->_entity->bundle(), 'entity_test_mul'); + // Test the relationship. + $this->assertEqual($row->entity_test_entity_test_mul__dynamic_references_id, 1); + + // Test that the correct relationship entity is on the row. + $this->assertEqual($row->_relationship_entities['entity_test__dynamic_references']->id(), 1); + $this->assertEqual($row->_relationship_entities['entity_test__dynamic_references']->bundle(), 'entity_test'); + } + + $view->destroy(); + // Check the backwards reference view of data table entity with data table + // entity for multiple value der base field. + $view->setDisplay('embed_2'); + $this->executeView($view); + foreach ($view->result as $index => $row) { + // Just check that the actual ID of the entity is the expected one. + $this->assertEqual($row->id, 1); + // Also check that we have the correct result entity. + $this->assertEqual($row->_entity->id(), 1); + $this->assertEqual($row->_entity->bundle(), 'entity_test_mul'); + // Test the relationship. + $this->assertEqual($row->dynamic_references_entity_test_mul_property_data_id, $ids[$index]); + + // Test that the correct relationship entity is on the row. + $this->assertEqual($row->_relationship_entities['reverse__entity_test_mul__dynamic_references']->id(), $ids[$index]); + $this->assertEqual($row->_relationship_entities['reverse__entity_test_mul__dynamic_references']->bundle(), 'entity_test_mul'); + } + + $view->destroy(); + // Check the backwards reference view of data table entity with base table + // entity for multiple value der base field. + $view->setDisplay('embed_3'); + $this->executeView($view); + foreach ($view->result as $index => $row) { + // Just check that the actual ID of the entity is the expected one. + $this->assertEqual($row->id, 1); + // Also check that we have the correct result entity. + $this->assertEqual($row->_entity->id(), 1); + $this->assertEqual($row->_entity->bundle(), 'entity_test_mul'); + // Test the relationship. + $this->assertEqual($row->dynamic_references_entity_test_mul_property_data_id, $ids[$index]); + + // Test that the correct relationship entity is on the row. + $this->assertEqual($row->_relationship_entities['reverse__entity_test__dynamic_references']->id(), $ids[$index]); + $this->assertEqual($row->_relationship_entities['reverse__entity_test__dynamic_references']->bundle(), 'entity_test'); + } + } }