public function TextOverlayTest::testTextAlter in Image Effects 8.2
Same name and namespace in other branches
- 8.3 tests/src/Functional/Effect/TextOverlayTest.php \Drupal\Tests\image_effects\Functional\Effect\TextOverlayTest::testTextAlter()
- 8 tests/src/Functional/Effect/TextOverlayTest.php \Drupal\Tests\image_effects\Functional\Effect\TextOverlayTest::testTextAlter()
Text alteration test.
File
- tests/
src/ Functional/ Effect/ TextOverlayTest.php, line 144
Class
- TextOverlayTest
- Text overlay effect test.
Namespace
Drupal\Tests\image_effects\Functional\EffectCode
public function testTextAlter() {
// Add Text overlay effect to the test image style.
$effect_config = [
'id' => 'image_effects_text_overlay',
'data' => [
'text_default][text_string' => 'the quick brown fox jumps over the lazy dog',
'font][uri' => drupal_get_path('module', 'image_effects') . '/tests/fonts/LinLibertineTTF_5.3.0_2012_07_02/LinLibertine_Rah.ttf',
'font][size' => 40,
'layout][position][extended_color][container][transparent' => FALSE,
'layout][position][extended_color][container][hex' => '#FF00FF',
'layout][position][extended_color][container][opacity' => 100,
],
];
$uuid = $this
->addEffectToTestStyle($effect_config);
// Test text and HTML tags and entities.
$effect = $this->testImageStyle
->getEffect($uuid);
$this
->assertEqual('the quick brown fox jumps over the lazy dog', $effect
->getAlteredText($effect
->getConfiguration()['data']['text_string']));
$this
->assertEqual('Para1 Para2', $effect
->getAlteredText('<p>Para1</p><!-- Comment --> Para2'));
$this
->assertEqual('"Title" One …', $effect
->getAlteredText('"Title" One …'));
$this
->removeEffectFromTestStyle($uuid);
$effect_config['data'] += [
'text_default][strip_tags' => FALSE,
'text_default][decode_entities' => FALSE,
];
$uuid = $this
->addEffectToTestStyle($effect_config);
$effect = $this->testImageStyle
->getEffect($uuid);
$this
->assertEqual('<p>Para1</p><!-- Comment --> Para2', $effect
->getAlteredText('<p>Para1</p><!-- Comment --> Para2'));
$this
->assertEqual('"Title" One …', $effect
->getAlteredText('"Title" One …'));
// Test converting to uppercase and trimming text.
$this
->removeEffectFromTestStyle($uuid);
$effect_config['data'] += [
'text][maximum_chars' => 9,
'text][case_format' => 'upper',
];
$uuid = $this
->addEffectToTestStyle($effect_config);
$effect = $this->testImageStyle
->getEffect($uuid);
$this
->assertEqual('THE QUICK…', $effect
->getAlteredText($effect
->getConfiguration()['data']['text_string']));
}