diff --git a/tests/FindLinksTest.php b/tests/FindLinksTest.php new file mode 100644 index 0000000..6358b8a --- /dev/null +++ b/tests/FindLinksTest.php @@ -0,0 +1,42 @@ +assertContains('http://example.com/', $links); + } + + public function testFindLinksInHTML() { + $links = FindLinks::inHTML('Hello'); + $this->assertContains('http://example.com/', $links); + } + + public function testFindLinksInJSONArray() { + $links = FindLinks::all([ + 'link' => 'http://example.com/', + 'nested' => [ + 'foo' => 'http://example.net/', + 'html' => 'This is some html with a link', + 'photo' => [ + 'http://example.com/img.jpg' + ], + 'bar' => [ + 'baz' => [ + 'http://example.org/' + ] + ], + [[['http://example.io/']]] + ] + ]); + $this->assertContains('http://example.com/', $links); + $this->assertContains('http://example.com/img.jpg', $links); + $this->assertContains('http://example.net/', $links); + $this->assertContains('http://example.org/', $links); + $this->assertContains('http://example.io/', $links); + $this->assertContains('http://example.html/', $links); + } + +} +