+ return [
+ 'issue-8470' => [
+ 'expected' => 'Je n’y pense que maintenant (pask ma sonnette ne fonctionne pas) : mettre un gentil mot avec mes coordonnées sur ma porte est le moyen le plus simple de rester en contact si besoin avec mon voisinage direct ! [url=https://www.instagram.com/p/B-UdH2loee1/?igshid=x4aglyju9kva]instagram.com/p/B-UdH2loee1/…[/url] [rest of the post]',
+ 'string' => 'Je n’y pense que maintenant (pask ma sonnette ne fonctionne pas) : mettre un gentil mot avec mes coordonnées sur ma porte est le moyen le plus simple de rester en contact si besoin avec mon voisinage direct ! https://t.co/YoBWTHsAAk [rest of the post]',
+ 'replacement' => '[url=https://www.instagram.com/p/B-UdH2loee1/?igshid=x4aglyju9kva]instagram.com/p/B-UdH2loee1/…[/url]',
+ 'start' => 209,
+ 'length' => 23,
+ ],
+ ];
+ }
+
+ /**
+ * Tests cases where Strings::substringReplace is needed over substr_replace with multi-byte strings and character
+ * offsets
+ *
+ * @param string $expected
+ * @param string $string
+ * @param string $replacement
+ * @param int $start
+ * @param int|null $length
+ *
+ * @dataProvider dataSubstringReplaceMultiByte
+ */
+ public function testSubstringReplaceMultiByte(string $expected, string $string, string $replacement, int $start, int $length = null)
+ {
+ self::assertEquals(
+ $expected,
+ Strings::substringReplace(
+ $string,
+ $replacement,
+ $start,
+ $length
+ )
+ );
+ }
+
+ public function testPerformWithEscapedBlocks()
+ {
+ $originalText = '[noparse][/noparse][nobb]nobb[/nobb][noparse]noparse[/noparse]';
+
+ $text = Strings::performWithEscapedBlocks($originalText, '#[(?:noparse|nobb)].*?\[/(?:noparse|nobb)]#is', function ($text) {
+ return $text;
+ });
+
+ self::assertEquals($originalText, $text);
+ }
+
+ public function testPerformWithEscapedBlocksNested()
+ {
+ $originalText = '[noparse][/noparse][nobb]nobb[/nobb][noparse]noparse[/noparse]';
+
+ $text = Strings::performWithEscapedBlocks($originalText, '#[nobb].*?\[/nobb]#is', function ($text) {
+ $text = Strings::performWithEscapedBlocks($text, '#[noparse].*?\[/noparse]#is', function ($text) {
+ return $text;
+ });
+
+ return $text;
+ });
+
+ self::assertEquals($originalText, $text);