public function test_img_src_replacement_with_non_utf8()
 {
     $url = 'http://example.com/image.jpg';
     $text = 'На берегу пустынных волн <a href="http://example.com/image.jpg"><img src=""></a>';
     $output = \HM\Import\Fixers::replace_img_src_a_href($text);
     $this->assertSame('На берегу пустынных волн <a href="http://example.com/image.jpg"><img src="' . $url . '"></a>', $output);
 }
 public function test_link_detection_regex()
 {
     $regex = \HM\Import\Fixers::get_link_detection_regex();
     // Clean links.
     preg_match_all($regex, '<a href="https://buddypress.org/download">BuddyPress</a>', $results, PREG_SET_ORDER);
     $this->assertNotEmpty($results);
     $this->assertSame($results[0][0], 'href="https://buddypress.org/download"');
     $this->assertSame($results[0][1], '"');
     $this->assertSame($results[0]['href'], 'https://buddypress.org/download');
     preg_match_all($regex, "<a href='https://bbpress.org/download'>bbPress</a>", $results, PREG_SET_ORDER);
     $this->assertNotEmpty($results);
     $this->assertSame($results[0][0], "href='https://bbpress.org/download'");
     $this->assertSame($results[0][1], "'");
     $this->assertSame($results[0]['href'], 'https://bbpress.org/download');
     // Messy links.
     preg_match_all($regex, "<a href='https://wordpress.org/download'>'WordPress</a>", $results, PREG_SET_ORDER);
     $this->assertNotEmpty($results);
     $this->assertSame($results[0][0], "href='https://wordpress.org/download'");
     $this->assertSame($results[0][1], "'");
     $this->assertSame($results[0]['href'], 'https://wordpress.org/download');
     preg_match_all($regex, '<a href="https://wordpress.org/download">\'WordPress</a>', $results, PREG_SET_ORDER);
     $this->assertNotEmpty($results);
     $this->assertSame($results[0][0], 'href="https://wordpress.org/download"');
     $this->assertSame($results[0][1], '"');
     $this->assertSame($results[0]['href'], 'https://wordpress.org/download');
 }