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'); }