TextUtilityTest.php in Image Effects 8.3
File
tests/src/Unit/TextUtilityTest.php
View source
<?php
namespace Drupal\Tests\image_effects\Unit;
use Drupal\Tests\UnitTestCase;
use Drupal\image_effects\Component\TextUtility;
class TextUtilityTest extends UnitTestCase {
public function testOffsetArgument() {
$matches = [];
$result = TextUtility::unicodePregMatch('/п/u', 'ппzz', $matches, NULL, 2);
$this
->assertEquals(0, $result, 'String was skipped using character-based offset.');
$result = TextUtility::unicodePregMatch('/.*$/u', 'пzz', $matches, NULL, 1);
$this
->assertTrue($result && $matches[0] === 'zz', 'String was matched using character-based offset.');
}
public function testCapturedOffset() {
$matches = [];
$result = TextUtility::unicodePregMatch('/z/u', 'пz', $matches, PREG_OFFSET_CAPTURE);
$this
->assertTrue($result && $matches[0][1] === 1, 'Returned offset is character-based.');
}
}
Classes
Name |
Description |
TextUtilityTest |
Tests the UTF-8 character-based wrapper of the preg_match function. |