You are here

protected function DazzlerTest::getFixture in Formdazzle! 2.x

Returns the specified form element fixture.

Parameters

string $name: The name of the fixture to return.

Return value

array The fixture.

6 calls to DazzlerTest::getFixture()
DazzlerTest::providerAddDefaultThemeProperties in tests/src/Unit/DazzlerTest.php
Data provider for testAddDefaultThemeProperties().
DazzlerTest::providerFormAlter in tests/src/Unit/DazzlerTest.php
Data provider for testFormAlter().
DazzlerTest::providerPreRenderForm in tests/src/Unit/DazzlerTest.php
Data provider for testPreRenderForm().
DazzlerTest::providerRepeatedPreRenderFormCalls in tests/src/Unit/DazzlerTest.php
Data provider for testRepeatedPreRenderFormCalls().
DazzlerTest::providerTraverse in tests/src/Unit/DazzlerTest.php
Data provider for testFormAlter().

... See full list

File

tests/src/Unit/DazzlerTest.php, line 94

Class

DazzlerTest
@coversDefaultClass \Drupal\formdazzle\Dazzler @group formdazzle

Namespace

Drupal\Tests\formdazzle\Unit

Code

protected function getFixture($name) {

  // Setting up fixtures as a class member variable can't be done during
  // Setup() because dataProvider functions are run before Setup().
  if (is_null($this->fixtures)) {

    // Form element fixtures.
    $this->fixtures = [
      'no_theme_defaults' => [
        '#type' => 'no_theme_defaults',
      ],
      'mixed_defaults' => [
        '#type' => 'mixed_defaults',
      ],
      'with_theme_and_wrappers' => [
        '#type' => 'with_theme_and_wrappers',
      ],
      'no_default_overrides' => [
        '#type' => 'with_theme_and_wrappers',
        '#theme' => 'no_default_overrides',
        '#theme_wrappers' => [
          'no_default_overrides',
        ],
      ],
      'no_type' => [
        '#fixture' => TRUE,
      ],
      'with_theme' => [
        '#type' => 'with_theme',
      ],
    ];

    // Form fixtures.
    $form_fixtures = [
      'simple_form' => [],
      'node_article_edit_form' => [
        '#theme' => [
          'node_article_edit_form',
          'node_form',
        ],
      ],
      'with_child' => [
        'child' => [
          '#type' => 'with_theme_and_wrappers',
        ],
      ],
    ];
    $this->fixtures += $form_fixtures;
    foreach (array_keys($form_fixtures) as $form_id) {

      // All our form fixtures share this structure.
      $this->fixtures[$form_id] += [
        '#type' => 'form',
        '#form_id' => $form_id,
        '#theme' => [
          $form_id,
        ],
      ];
    }
  }
  return $this->fixtures[$name];
}