You are here

protected function ParagraphSetBasicFunctionality::setUp in Paragraphs Sets 8.2

Overrides BrowserTestBase::setUp

File

tests/src/Functional/ParagraphSetBasicFunctionality.php, line 78

Class

ParagraphSetBasicFunctionality
Tests the basic functionality of Paragraphs Sets.

Namespace

Drupal\Tests\paragraphs_sets\Functional

Code

protected function setUp() : void {
  parent::setUp();

  // Create a paragraph. Add a text field to that paragraph.
  $this->sutParagraphType = mb_strtolower($this
    ->randomMachineName());
  $this
    ->addParagraphsType($this->sutParagraphType);
  $this->sutParagraphTextField = mb_strtolower($this
    ->randomMachineName());
  $this
    ->addTextFieldInParagraphType($this->sutParagraphTextField, $this->sutParagraphType);

  // Add a first paragraph set.
  $this->sutParagraphSetFirst = $this
    ->randomMachineName();
  $configFirst = <<<EOF
paragraphs:
  - type: {<span class="php-variable">$this</span>-&gt;<span class="php-function-or-constant property member-of-self">sutParagraphType</span>}
    data:
      {<span class="php-variable">$this</span>-&gt;<span class="php-function-or-constant property member-of-self">sutParagraphTextField</span>}: One
  - type: {<span class="php-variable">$this</span>-&gt;<span class="php-function-or-constant property member-of-self">sutParagraphType</span>}
    data:
      {<span class="php-variable">$this</span>-&gt;<span class="php-function-or-constant property member-of-self">sutParagraphTextField</span>}: Two
  - type: {<span class="php-variable">$this</span>-&gt;<span class="php-function-or-constant property member-of-self">sutParagraphType</span>}
    data:
      {<span class="php-variable">$this</span>-&gt;<span class="php-function-or-constant property member-of-self">sutParagraphTextField</span>}: Three
EOF;
  $this
    ->addParagraphSet($this->sutParagraphSetFirst, $configFirst);

  // Add a second paragraph set.
  $this->sutParagraphSetSecond = $this
    ->randomMachineName();
  $configSecond = <<<EOF
paragraphs:
  - type: {<span class="php-variable">$this</span>-&gt;<span class="php-function-or-constant property member-of-self">sutParagraphType</span>}
    data:
      {<span class="php-variable">$this</span>-&gt;<span class="php-function-or-constant property member-of-self">sutParagraphTextField</span>}: Four
  - type: {<span class="php-variable">$this</span>-&gt;<span class="php-function-or-constant property member-of-self">sutParagraphType</span>}
    data:
      {<span class="php-variable">$this</span>-&gt;<span class="php-function-or-constant property member-of-self">sutParagraphTextField</span>}: Five
EOF;
  $this
    ->addParagraphSet($this->sutParagraphSetSecond, $configSecond);

  // Add a node. Add a paragraph reference field to that node.
  $this->sutNodeType = mb_strtolower($this
    ->randomMachineName());
  $this
    ->addNodeType($this->sutNodeType);
  $this->sutNodeParagraphField = mb_strtolower($this
    ->randomMachineName());
  $this
    ->addParagraphRefFieldInNodeType($this->sutNodeParagraphField, $this->sutNodeType);
}