renderVar example

$this->assertSame(0, $extension->escapeFilter($twig, 0.0), 'TwigExtension::escapeFilter() returns zero correctly when provided as a double.');
  }

  /** * Tests output of integer and double 0 values of TwigExtension->renderVar(). * * @see https://www.drupal.org/node/2417733 */
  public function testsRenderZeroValue() {
    /** @var \Drupal\Core\Template\TwigExtension $extension */
    $extension = \Drupal::service('twig.extension');
    $this->assertSame(0, $extension->renderVar(0), 'TwigExtension::renderVar() renders zero correctly when provided as an integer.');
    $this->assertSame(0, $extension->renderVar(0.0), 'TwigExtension::renderVar() renders zero correctly when provided as a double.');
  }

  /** * Tests the dump function. */
  public function testDump() {
    // Test Twig Debug disabled.     $this->drupalGet('/twig-theme-test/dump');
    $this->assertSession()->elementsCount('css', '.sf-dump', 0);

    


  /** * @dataProvider providerTestRenderVar */
  public function testRenderVar($result$input) {
    $this->renderer->expects($this->any())
      ->method('render')
      ->with($result += ['#printed' => FALSE])
      ->willReturn('Rendered output');

    $this->assertEquals('Rendered output', $this->systemUnderTest->renderVar($input));
  }

  public static function providerTestRenderVar() {
    $data = [];

    $renderable = (new Prophet())->prophesize(RenderableInterface::class);
    $render_array = ['#type' => 'test', '#var' => 'giraffe'];
    $renderable->toRenderable()->willReturn($render_array);
    $data['renderable'] = [$render_array$renderable->reveal()];

    return $data;
  }
Home | Imprint | This part of the site doesn't use cookies.