getHtml example


  protected function assertOrderInPage(array $items): void {
    $session = $this->getSession();
    $text = $session->getPage()->getHtml();
    $strings = [];
    foreach ($items as $item) {
      if (($pos = strpos($text$item)) === FALSE) {
        throw new ExpectationException("Cannot find '$item' in the page", $session->getDriver());
      }
      $strings[$pos] = $item;
    }
    ksort($strings);
    $ordered = implode(', ', array_map(function D$item) {
      return "'$item'";
    }$items));
    


        $rendered = new RenderedDocument(
            $html,
            '1001',
            InvoiceRenderer::TYPE,
            FileTypes::PDF,
            ['displayFooter' => true]
        );

        static::assertStringContainsString('<html>', $rendered->getHtml());
        static::assertStringContainsString('</html>', $rendered->getHtml());
        static::assertStringContainsString('DOMPDF_PAGE_COUNT_PLACEHOLDER', $rendered->getHtml());

        $pdfRenderer = new PdfRenderer([
            'isRemoteEnabled' => true,
            'isHtml5ParserEnabled' => true,
        ]);
        $generatorOutput = $pdfRenderer->render($rendered);
        static::assertNotEmpty($generatorOutput);

        $finfo = new \finfo(\FILEINFO_MIME_TYPE);
        
case 'url':
        $url = $resource->getUrl();
        return $url ? $url->toString() : NULL;

      case 'width':
        return $resource->getWidth();

      case 'height':
        return $resource->getHeight();

      case 'html':
        return $resource->getHtml();

      default:
        break;
    }
    return NULL;
  }

  /** * {@inheritdoc} */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    
'iconCls' => $iconCls,
            'tpl1variable' => $site->getTpl1Variable(),
            'tpl1path' => $site->getTpl1Path(),
            'tpl2variable' => $site->getTpl2Variable(),
            'tpl2path' => $site->getTpl2Path(),
            'tpl3variable' => $site->getTpl3Variable(),
            'tpl3path' => $site->getTpl3Path(),
            'description' => $site->getDescription(),
            'pageTitle' => $site->getPageTitle(),
            'metaKeywords' => $site->getMetaKeywords(),
            'metaDescription' => $site->getMetaDescription(),
            'html' => $site->getHtml(),
            'grouping' => $site->getGrouping(),
            'position' => $site->getPosition(),
            'link' => $site->getLink(),
            'target' => $site->getTarget(),
            'shopIds' => $site->getShopIds(),
            'changed' => $site->getChanged(),
            'parentId' => $site->getParentId(),
            'leaf' => true,
        ];

        // If the site has children, append them
    $this->drupalGet('test-content-ajax');

    $session_assert = $this->assertSession();

    $page = $this->getSession()->getPage();

    // Ensure that the Content we're testing for is in the right order, default     // sorting is by changed timestamp so the last created node should be first.     /** @var \Behat\Mink\Element\NodeElement[] $rows */
    $rows = $page->findAll('css', 'tbody tr');
    $this->assertCount(2, $rows);
    $this->assertStringContainsString('Page B', $rows[0]->getHtml());
    $this->assertStringContainsString('Page A', $rows[1]->getHtml());

    // Now sort by title and check if the order changed.     $page->clickLink('Title');
    $session_assert->assertWaitOnAjaxRequest();
    $rows = $page->findAll('css', 'tbody tr');
    $this->assertCount(2, $rows);
    $this->assertStringContainsString('Page A', $rows[0]->getHtml());
    $this->assertStringContainsString('Page B', $rows[1]->getHtml());
  }

}
$this->config('system.theme')->set('admin', 'stark')->save();

    $this->drupalGet('test-page');
    $this->assertSession()->statusCodeEquals(200);

    $admin_theme = \Drupal::configFactory()->get('system.theme')->get('admin');
    $default_theme = \Drupal::configFactory()->get('system.theme')->get('default');
    $this->assertEquals('stark', $admin_theme);
    $this->assertEquals('stark', $default_theme);

    $head = $this->getSession()->getPage()->find('css', 'head')->getHtml();

    // Confirm that Claro stylesheets are not loading, and the ones they would     // override were Claro enabled are still loading.     $stylesheet_positions = [];
    foreach ($default_stylesheets as $stylesheet) {
      $this->assertStringContainsString($stylesheet$head);
      $stylesheet_positions[] = strpos($head$stylesheet);
    }
    $sorted_stylesheet_positions = $stylesheet_positions;
    sort($sorted_stylesheet_positions);
    $this->assertEquals($sorted_stylesheet_positions$stylesheet_positions);

    
$i'></p>"); jQuery('.csrf$i').html(response); }, error: function() { jQuery('body').append('Nothing'); } }); EOT;
    }
    $this->getSession()->getDriver()->executeScript($script);
    $token0 = $this->assertSession()->waitForElement('css', '.csrf0')->getHtml();
    $token1 = $this->assertSession()->waitForElement('css', '.csrf1')->getHtml();
    $this->assertNotNull($token0);
    $this->assertNotNull($token1);
    $this->assertEquals($token0$token1);
  }

}
      $new_page_text = $new_page_text . ' ' . $theme . ' ' . $block_plugin;
    }
    $web_assert = $this->assertSession();
    $page = $this->getSession()->getPage();
    $this->enableTheme($theme);
    $block = $this->placeBlock($block_plugin);
    $block_selector = $this->getBlockSelector($block);
    $block_id = $block->id();
    $this->drupalGet('user');

    $link = $web_assert->waitForElement('css', "$block_selector .contextual-links li a");
    $this->assertEquals('Quick edit', $link->getHtml(), "'Quick edit' is the first contextual link for the block.");
    $destination = (string) $this->loggedInUser->toUrl()->toString();
    $this->assertStringContainsString("/admin/structure/block/manage/$block_id/settings-tray?destination=$destination", $link->getAttribute('href'));

    if (isset($toolbar_item)) {
      // Check that you can open a toolbar tray and it will be closed after       // entering edit mode.       if ($element = $page->find('css', "#toolbar-administration a.is-active")) {
        // If a tray was open from page load close it.         $element->click();
        $web_assert->assertNoElementAfterWait('css', "#toolbar-administration a.is-active");
      }
      
/** * Tests comment rss output. */
  public function testRssRow() {
    $this->drupalGet('test-comment-rss');

    // Because the response is XML we can't use the page which depends on an     // HTML tag being present.     $result = $this->getSession()->getDriver()->find('//item');
    $this->assertCount(1, $result, 'Just one comment was found in the rss output.');

    $this->assertEquals(gmdate('r', $this->comment->getCreatedTime())$result[0]->find('xpath', '//pubDate')->getHtml(), 'The right pubDate appears in the rss output.');
  }

}
AnnounceTestHttpClientMiddleware::setAnnounceTestEndpoint('/announce-feed-json/community-feeds');
  }

  /** * Check the status of the announcements when the feed is updated and removed. */
  public function testAnnounceFeedUpdatedAndRemoved() {
    $this->drupalLogin($this->user);
    $this->drupalGet('<front>');
    $this->clickLink('Announcements');
    $this->waitForOffCanvasToOpen();
    $page_html = $this->getSession()->getPage()->getHtml();
    $this->assertStringNotContainsString('Only 10 - Drupal 106 is available and this feed is Updated', $page_html);

    // Change the feed url and reset temp storage.     AnnounceTestHttpClientMiddleware::setAnnounceTestEndpoint('/announce-feed-json/updated');

    $this->drupalGet('<front>');
    $this->clickLink('Announcements');
    $this->waitForOffCanvasToOpen();
    $page_html = $this->getSession()->getPage()->getHtml();
    $this->assertStringContainsString('Only 10 - Drupal 106 is available and this feed is Updated', $page_html);
    $this->drupalLogout();

    
$processedTemplate = $this->deliveryNoteRenderer->render(
            [$orderId => $operation],
            $this->context,
            new DocumentRendererConfig()
        );

        static::assertArrayHasKey($orderId$processedTemplate->getSuccess());
        static::assertInstanceOf(RenderedDocument::class$processedTemplate->getSuccess()[$orderId]);

        $rendered = $processedTemplate->getSuccess()[$orderId];

        static::assertStringContainsString('<html>', $rendered->getHtml());
        static::assertStringContainsString('</html>', $rendered->getHtml());

        $generatorOutput = $this->pdfRenderer->render($rendered);
        static::assertNotEmpty($generatorOutput);

        $finfo = new \finfo(\FILEINFO_MIME_TYPE);
        static::assertEquals('application/pdf', $finfo->buffer($generatorOutput));
    }
}
static::assertNotNull($order);

        if ($processedTemplate->getSuccess() !== []) {
            static::assertArrayHasKey($orderId$processedTemplate->getSuccess());

            /** @var RenderedDocument $rendered */
            $rendered = $processedTemplate->getSuccess()[$orderId];

            static::assertInstanceOf(OrderLineItemCollection::class$lineItems = $order->getLineItems());
            static::assertInstanceOf(OrderLineItemEntity::class$firstLineItem = $lineItems->first());
            static::assertInstanceOf(OrderLineItemEntity::class$lastLineItem = $lineItems->last());
            static::assertStringContainsString('<html>', $rendered->getHtml());
            static::assertStringContainsString('</html>', $rendered->getHtml());
            static::assertStringContainsString($firstLineItem->getLabel()$rendered->getHtml());
            static::assertStringContainsString($lastLineItem->getLabel()$rendered->getHtml());

            $assertionCallback($rendered$order$this->getContainer());
        } else {
            $assertionCallback($order->getId()$processedTemplate->getErrors());
        }
    }

    public static function invoiceDataProvider(): \Generator
    {


        static::assertInstanceOf(StornoOrdersEvent::class$caughtEvent);
        static::assertCount(1, $caughtEvent->getOperations());
        static::assertSame($operation$caughtEvent->getOperations()[$orderId] ?? null);
        static::assertCount(1, $caughtEvent->getOrders());
        $order = $caughtEvent->getOrders()->get($orderId);
        static::assertNotNull($order);
        static::assertArrayHasKey($orderId$processedTemplate->getSuccess());
        $rendered = $processedTemplate->getSuccess()[$orderId];
        static::assertInstanceOf(RenderedDocument::class$rendered);
        static::assertStringContainsString('<html>', $rendered->getHtml());
        static::assertStringContainsString('</html>', $rendered->getHtml());

        $assertionCallback($rendered);
    }

    public function testRenderWithoutInvoice(): void
    {
        $cart = $this->generateDemoCart([7, 13]);
        $orderId = $this->cartService->order($cart$this->salesChannelContext, new RequestDataBag());

        $operation = new DocumentGenerateOperation($orderId);

        
$query->addExpression('MAX([wid])');
    $wid = $query->execute()->fetchField();
    $this->drupalGet('admin/reports/dblog/event/' . $wid);

    // Verify table headers are present.     $this->assertSession()->pageTextContains('Location');

    // Verify severity.     $this->assertSession()->pageTextContains('Notice');

    // Verify location is available as plain text.     $this->assertEquals($request_uri$this->cssSelect('table.dblog-event > tbody > tr:nth-child(4) > td')[0]->getHtml());
    $this->assertSession()->linkNotExists($request_uri);
  }

  /** * Test that twig errors are displayed correctly. */
  public function testMessageParsing() {
    $this->drupalLogin($this->adminUser);
    // Log a common twig error with {{ }} and { } variables.     \Drupal::service('logger.factory')->get("php")
      ->error('Incorrect parameter {{foo}} in path {path}: {value}',
        [
'bundle' => $media_type->id(),
      $source_field->getName() => $url,
    ]);
    $entity->save();

    $this->drupalGet($entity->toUrl());
    $assert = $this->assertSession();
    $assert->statusCodeEquals(200);
    foreach ($selectors as $selector => $attributes) {
      $element = $assert->elementExists('css', $selector);
      if ($self_closing) {
        self::assertStringContainsString("</$selector", $element->getParent()->getHtml());
      }
      foreach ($attributes as $attribute => $value) {
        if (isset($value)) {
          $this->assertStringContainsString($value$element->getAttribute($attribute));
        }
        else {
          $this->assertFalse($element->hasAttribute($attribute));
        }
      }
    }
  }

}
Home | Imprint | This part of the site doesn't use cookies.