/** * @dataProvider getRenderContentEditableTestData * * @param string $expectedText * @param string $text * @param string $name * @param array $options * @param bool $isAuthorized * @param string $message */ public function testRenderContentEditable($expectedText, $text, $name, $options, $isAuthorized, $message) { $content = new Content(); $content->setId(1)->setName($name)->setText($text)->setLocale($options['locale']); $this->manager->method('get')->with($name, $options['locale'], $text)->willReturn($content); $this->authorizationChecker->method('isGranted')->with('ROLE_ADMIN')->willReturn($isAuthorized); $this->editor->method('renderContent')->with($content, $options)->willReturn(sprintf('editable_%s', $text)); $rendered = $this->extension->render($text, $name, $options); $this->assertSame($expectedText, $rendered, $message); }
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); }
/** * @param bool $authorized */ private function setAuthorized($authorized) { $this->authorizationChecker->method('isGranted')->with('ROLE_ADMIN')->willReturn($authorized); }