ParagraphEntityReferenceTest.php in Entity Share 8.2
File
modules/entity_share_client/tests/src/Functional/ParagraphEntityReferenceTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\entity_share_client\Functional;
use Drupal\Core\Entity\ContentEntityInterface;
class ParagraphEntityReferenceTest extends EntityShareClientFunctionalTestBase {
protected static $entityTypeId = 'node';
protected static $entityBundleId = 'es_test';
protected static $entityLangcode = 'en';
protected function setUp() {
parent::setUp();
$this
->postSetupFixture();
}
protected function getEntitiesDataArray() {
return [
'paragraph' => [
'en' => [
'es_test_paragraph' => $this
->getCompleteParagraphInfos([
'field_es_test_text_plain' => [
'value' => $this->faker
->text(255),
'checker_callback' => 'getValue',
],
]),
],
],
'node' => [
'en' => [
'es_test_paragraph_reference' => $this
->getCompleteNodeInfos([
'field_es_test_paragraphs' => [
'value_callback' => function () {
return [
[
'target_id' => $this
->getEntityId('paragraph', 'es_test_paragraph'),
'target_revision_id' => $this
->getEntityRevisionId('paragraph', 'es_test_paragraph'),
],
];
},
'checker_callback' => 'getExpectedParagraphReferenceValue',
],
]),
],
],
];
}
public function testReferenceEntityValue() {
$this
->pullEveryChannels();
$this
->checkCreatedEntities();
}
protected function getExpectedParagraphReferenceValue(ContentEntityInterface $entity, string $field_name) {
return [
[
'target_id' => $this
->getEntityId('paragraph', 'es_test_paragraph'),
'target_revision_id' => $this
->getEntityRevisionId('paragraph', 'es_test_paragraph'),
],
];
}
}