WebformViewsRelationshipTestBase.php in Webform Views Integration 8.5
File
tests/src/Kernel/relationship/WebformViewsRelationshipTestBase.php
View source
<?php
namespace Drupal\Tests\webform_views\Kernel\relationship;
use Drupal\Tests\webform_views\Kernel\WebformViewsTestBase;
abstract class WebformViewsRelationshipTestBase extends WebformViewsTestBase {
protected $target_entity_type;
public function testRelationship($expected) {
$this->webform = $this
->createWebform($this->webform_elements);
$this
->createWebformSubmissions($this->webform_submissions_data, $this->webform);
$this->view = $this
->initView($this->webform, $this->view_handlers);
$rendered_cells = $this
->renderView($this->view);
$this
->assertSame($expected, $rendered_cells, 'Relationship works.');
}
public function providerRelationship() {
$tests = [];
$expected = [];
foreach ($this->webform_submissions_data as $webform_submission) {
$target_id = reset($webform_submission);
$expected[] = [
'entity_id' => (string) $target_id,
];
}
$tests[] = [
$expected,
];
return $tests;
}
public function testReverseRelationship($expected) {
$this->webform = $this
->createWebform($this->webform_elements);
$this
->createWebformSubmissions($this->webform_submissions_data, $this->webform);
$this->view = $this
->initView($this->webform, [], 'webform_views_reverse_entity_reference_test');
$rendered_cells = $this
->renderView($this->view, [], []);
$this
->assertSame($expected, $rendered_cells, 'Reverse relationship works.');
}
public function providerReverseRelationship() {
$tests = [];
$expected = [];
foreach ($this->webform_submissions_data as $webform_submission) {
$target_id = reset($webform_submission);
$expected[] = [
'entity_id' => (string) $target_id,
'sid' => '1',
];
}
$tests[] = [
$expected,
];
return $tests;
}
}