Browse Source

add tests for FindLinks

main
Aaron Parecki 6 years ago
parent
commit
303e60daaa
No known key found for this signature in database GPG Key ID: 276C2817346D6056
1 changed files with 42 additions and 0 deletions
  1. +42
    -0
      tests/FindLinksTest.php

+ 42
- 0
tests/FindLinksTest.php View File

@ -0,0 +1,42 @@
<?php
use Telegraph\FindLinks;
class FindLinksTest extends PHPUnit_Framework_TestCase {
public function testFindLinksInText() {
$links = FindLinks::inText('Hello world http://example.com/');
$this->assertContains('http://example.com/', $links);
}
public function testFindLinksInHTML() {
$links = FindLinks::inHTML('<a href="http://example.com/">Hello</a>');
$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 <a href="http://example.html/">link</a>',
'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);
}
}

Loading…
Cancel
Save