getTwigMock example



  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->helpTopic = new HelpTopicTwig([],
      self::PLUGIN_INFORMATION['id'],
      self::PLUGIN_INFORMATION,
      $this->getTwigMock());
  }

  /** * @covers ::getBody * @covers ::getLabel */
  public function testText() {
    $this->assertEquals($this->helpTopic->getBody(),
      ['#markup' => self::PLUGIN_INFORMATION['body']]);
    $this->assertEquals($this->helpTopic->getLabel(),
      self::PLUGIN_INFORMATION['label']);
  }
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig\Environment;

class WebDebugToolbarListenerTest extends TestCase
{
    /** * @dataProvider getInjectToolbarTests */
    public function testInjectToolbar($content$expected)
    {
        $listener = new WebDebugToolbarListener($this->getTwigMock());
        $m = new \ReflectionMethod($listener, 'injectToolbar');

        $response = new Response($content);

        $m->invoke($listener$response, Request::create('/')['csp_script_nonce' => 'scripto', 'csp_style_nonce' => 'stylo']);
        $this->assertEquals($expected$response->getContent());
    }

    public static function getInjectToolbarTests()
    {
        return [
            [
Home | Imprint | This part of the site doesn't use cookies.