RelToAbsTest.php in Relative Path to Absolute URLs 8
File
src/Tests/RelToAbsTest.php
View source
<?php
namespace Drupal\rel_to_abs\Tests;
use Drupal\rel_to_abs\Plugin\Filter\RelToAbs;
use Drupal\Core\Language\LanguageInterface;
use Drupal\simpletest\WebTestBase;
class RelToAbsTest extends WebTestBase {
public static $modules = array(
'rel_to_abs',
);
public function testRelToAbsFilterUnitTestCase() {
$language = \Drupal::getContainer()
->get('language_manager')
->getLanguage(LanguageInterface::LANGCODE_NOT_SPECIFIED);
$front = \Drupal::url('<front>', array(), array(
'absolute' => TRUE,
'language' => $language,
));
$filter = new RelToAbs(array(), 'rel_to_abs', array(
'provider' => 'rel_to_abs',
));
$markup = '<div><a href="/node/1">link</a><img src="/files/test.jpg"/><span background="/files/test.jpg">test</span><a href="mailto:test@test.test"></a><a href="#anchor"></a></div>';
$check = '<div><a href="' . $front . '/node/1">link</a><img src="' . $front . '/files/test.jpg"/><span background="' . $front . '/files/test.jpg">test</span><a href="mailto:test@test.test"></a><a href="#anchor"></a></div>';
$result = $filter
->process($markup, NULL);
$this
->assertEqual($check, $result);
}
}
Classes
Name |
Description |
RelToAbsTest |
Ensure that the rel_to_abs filter provided functions properly. |