public function getEnvironment() { if (is_null($this->environment)) { $this->environment = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $this->environment->method('loadTemplate')->willReturn($this->getTemplate()); } return $this->environment; }
/** * @dataProvider getRenderEditorTestData * * @param array $contents * @param array $separateContents * @param string $message */ public function testRenderEditor($contents, $separateContents, $message = '') { $this->twig->method('render')->will($this->returnValueMap([['@IvoazContentEditable/editor.html.twig', [], '<p>editor</p>'], ['@IvoazContentEditable/separately_editable_contents.html.twig', ['contents' => $separateContents], '<p>separate contents</p>']])); foreach ($contents as $content) { $this->editor->renderContent($content, []); } foreach ($separateContents as $content) { $this->editor->renderContent($content, ['separately' => true]); } $html = $this->editor->renderEditor(new Response()); $expectedHtml = empty($separateContents) ? '<p>editor</p>' : '<p>separate contents</p><p>editor</p>'; $this->assertSame($expectedHtml, $html, $message); }