コード例 #1
0
 /**
  * @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);
 }
コード例 #2
0
 public function testCustomEditorInjectionIsPossible()
 {
     $this->authorizationChecker->method('isGranted')->with('ROLE_ADMIN')->willReturn(true);
     $request = new Request();
     $response = new Response('<body></body>', 200, ['Content-Type' => 'text/html']);
     $this->event->method('getRequest')->willReturn($request);
     $this->event->method('getResponse')->willReturn($response);
     $this->event->method('isMasterRequest')->willReturn(true);
     $this->editor->expects($this->once())->method('renderEditor')->with($response)->willReturn(null);
     $this->listener->onKernelResponse($this->event);
 }