processText example


  protected function applyFilter($text$langcode = 'en') {
    $this->assertStringContainsString('<drupal-media', $text);
    $this->assertStringContainsString('This placeholder should not be rendered.', $text);
    $filter_result = $this->processText($text$langcode);
    $output = $filter_result->getProcessedText();
    $this->assertStringNotContainsString('<drupal-media', $output);
    $this->assertStringNotContainsString('This placeholder should not be rendered.', $output);
    $this->setRawContent($output);
    return $filter_result;
  }

  /** * Assert that the SimpleXMLElement object has the given attributes. * * @param \SimpleXMLElement $element * The SimpleXMLElement object to check. * @param array $expected_attributes * An array of expected attributes. */

  public function testMissingEntityIndicator($uuid, array $filter_ids, array $additional_attributes) {
    $content = $this->createEmbedCode([
      'data-entity-type' => 'media',
      'data-entity-uuid' => $uuid,
      'data-view-mode' => 'foobar',
    ] + $additional_attributes);

    // If the UUID being used in the embed is that of the sample entity, first     // assert that it currently results in a functional embed, then delete it.     if ($uuid === static::EMBEDDED_ENTITY_UUID) {
      $result = $this->processText($content, 'en', $filter_ids);
      $this->setRawContent($result->getProcessedText());
      $this->assertCount(1, $this->cssSelect('div[data-media-embed-test-view-mode="foobar"]'));
      $this->embeddedEntity->delete();
    }
    $result = $this->processText($content, 'en', $filter_ids);
    $this->setRawContent($result->getProcessedText());
    $this->assertCount(0, $this->cssSelect('div[data-media-embed-test-view-mode="foobar"]'));
    $this->assertCount(1, $this->cssSelect('div.this-error-message-is-themeable'));
    if (in_array('filter_align', $filter_ids, TRUE) && !empty($additional_attributes['data-align'])) {
      $this->assertCount(1, $this->cssSelect('div.align-' . $additional_attributes['data-align']));
    }

  }
/** * Tests that the expected embedded media entity translation is selected. * * @dataProvider providerTranslationSituations */
  public function testTranslationSelection($text_langcode$expected_title_langcode) {
    $text = $this->createEmbedCode([
      'data-entity-type' => 'media',
      'data-entity-uuid' => static::EMBEDDED_ENTITY_UUID,
    ]);

    $result = $this->processText($text$text_langcode['media_embed']);
    $this->setRawContent($result->getProcessedText());

    $this->assertSame(
      $this->embeddedEntity->getTranslation($expected_title_langcode)->field_media_image->alt,
      (string) $this->cssSelect('img')[0]->attributes()['alt']
    );
    // Verify that the filtered text does not vary by translation-related cache     // contexts: a particular translation of the embedded entity is selected     // based on the host entity's language, which should require a cache context     // to be associated. (The host entity's language may itself be selected     // based on the request context, but that is of no concern to this filter.)
Home | Imprint | This part of the site doesn't use cookies.