You are here

public function DazzlerTest::testPreRenderFormNoDebugging in Formdazzle! 2.x

@covers ::preRenderForm

@dataProvider providerRepeatedPreRenderFormCalls

File

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

Class

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

Namespace

Drupal\Tests\formdazzle\Unit

Code

public function testPreRenderFormNoDebugging() {

  // Turn off Twig debugging.
  $twig_service = $this
    ->createMock('\\Twig_Environment');
  $twig_service
    ->method('isDebug')
    ->willReturn(FALSE);
  $container = new ContainerBuilder();
  $container
    ->set('element_info', $this->elementInfoManager);
  $container
    ->set('twig', $twig_service);
  \Drupal::setContainer($container);
  $form = $this
    ->getFixture('node_article_edit_form');
  Dazzler::formAlter($form, 'node_article_edit_form');

  // The expected form should not contain any #markup.
  $expected = $form + [
    '#theme_wrappers' => [
      'form__node_article_edit_form',
    ],
  ];
  unset($expected['#formdazzle']);
  $actual = Dazzler::preRenderForm($form);
  $this
    ->assertEquals($expected, $actual, $this
    ->getTestMessage());
}