diff options
Diffstat (limited to 'tests/bookmark/LinkUtilsTest.php')
-rw-r--r-- | tests/bookmark/LinkUtilsTest.php | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/tests/bookmark/LinkUtilsTest.php b/tests/bookmark/LinkUtilsTest.php index 78cb8f2a..ef00b92f 100644 --- a/tests/bookmark/LinkUtilsTest.php +++ b/tests/bookmark/LinkUtilsTest.php | |||
@@ -2,9 +2,7 @@ | |||
2 | 2 | ||
3 | namespace Shaarli\Bookmark; | 3 | namespace Shaarli\Bookmark; |
4 | 4 | ||
5 | use PHPUnit\Framework\TestCase; | 5 | use Shaarli\TestCase; |
6 | use ReferenceLinkDB; | ||
7 | use Shaarli\Config\ConfigManager; | ||
8 | 6 | ||
9 | require_once 'tests/utils/CurlUtils.php'; | 7 | require_once 'tests/utils/CurlUtils.php'; |
10 | 8 | ||
@@ -45,6 +43,19 @@ class LinkUtilsTest extends TestCase | |||
45 | } | 43 | } |
46 | 44 | ||
47 | /** | 45 | /** |
46 | * Test headers_extract_charset() when the charset is found with odd quotes. | ||
47 | */ | ||
48 | public function testHeadersExtractExistentCharsetWithQuotes() | ||
49 | { | ||
50 | $charset = 'x-MacCroatian'; | ||
51 | $headers = 'text/html; charset="' . $charset . '"otherstuff="test"'; | ||
52 | $this->assertEquals(strtolower($charset), header_extract_charset($headers)); | ||
53 | |||
54 | $headers = 'text/html; charset=\'' . $charset . '\'otherstuff="test"'; | ||
55 | $this->assertEquals(strtolower($charset), header_extract_charset($headers)); | ||
56 | } | ||
57 | |||
58 | /** | ||
48 | * Test headers_extract_charset() when the charset is not found. | 59 | * Test headers_extract_charset() when the charset is not found. |
49 | */ | 60 | */ |
50 | public function testHeadersExtractNonExistentCharset() | 61 | public function testHeadersExtractNonExistentCharset() |
@@ -389,15 +400,6 @@ class LinkUtilsTest extends TestCase | |||
389 | } | 400 | } |
390 | 401 | ||
391 | /** | 402 | /** |
392 | * Test count_private. | ||
393 | */ | ||
394 | public function testCountPrivateLinks() | ||
395 | { | ||
396 | $refDB = new ReferenceLinkDB(); | ||
397 | $this->assertEquals($refDB->countPrivateLinks(), count_private($refDB->getLinks())); | ||
398 | } | ||
399 | |||
400 | /** | ||
401 | * Test text2clickable. | 403 | * Test text2clickable. |
402 | */ | 404 | */ |
403 | public function testText2clickable() | 405 | public function testText2clickable() |
@@ -448,13 +450,13 @@ class LinkUtilsTest extends TestCase | |||
448 | カタカナ #カタカナ」カタカナ\n'; | 450 | カタカナ #カタカナ」カタカナ\n'; |
449 | $autolinkedDescription = hashtag_autolink($rawDescription, $index); | 451 | $autolinkedDescription = hashtag_autolink($rawDescription, $index); |
450 | 452 | ||
451 | $this->assertContains($this->getHashtagLink('hashtag', $index), $autolinkedDescription); | 453 | $this->assertContainsPolyfill($this->getHashtagLink('hashtag', $index), $autolinkedDescription); |
452 | $this->assertNotContains(' #hashtag', $autolinkedDescription); | 454 | $this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription); |
453 | $this->assertNotContains('>#nothashtag', $autolinkedDescription); | 455 | $this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription); |
454 | $this->assertContains($this->getHashtagLink('ашок', $index), $autolinkedDescription); | 456 | $this->assertContainsPolyfill($this->getHashtagLink('ашок', $index), $autolinkedDescription); |
455 | $this->assertContains($this->getHashtagLink('カタカナ', $index), $autolinkedDescription); | 457 | $this->assertContainsPolyfill($this->getHashtagLink('カタカナ', $index), $autolinkedDescription); |
456 | $this->assertContains($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription); | 458 | $this->assertContainsPolyfill($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription); |
457 | $this->assertNotContains($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription); | 459 | $this->assertNotContainsPolyfill($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription); |
458 | } | 460 | } |
459 | 461 | ||
460 | /** | 462 | /** |
@@ -465,9 +467,9 @@ class LinkUtilsTest extends TestCase | |||
465 | $rawDescription = 'blabla #hashtag x#nothashtag'; | 467 | $rawDescription = 'blabla #hashtag x#nothashtag'; |
466 | $autolinkedDescription = hashtag_autolink($rawDescription); | 468 | $autolinkedDescription = hashtag_autolink($rawDescription); |
467 | 469 | ||
468 | $this->assertContains($this->getHashtagLink('hashtag'), $autolinkedDescription); | 470 | $this->assertContainsPolyfill($this->getHashtagLink('hashtag'), $autolinkedDescription); |
469 | $this->assertNotContains(' #hashtag', $autolinkedDescription); | 471 | $this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription); |
470 | $this->assertNotContains('>#nothashtag', $autolinkedDescription); | 472 | $this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription); |
471 | } | 473 | } |
472 | 474 | ||
473 | /** | 475 | /** |
@@ -500,7 +502,7 @@ class LinkUtilsTest extends TestCase | |||
500 | */ | 502 | */ |
501 | private function getHashtagLink($hashtag, $index = '') | 503 | private function getHashtagLink($hashtag, $index = '') |
502 | { | 504 | { |
503 | $hashtagLink = '<a href="' . $index . '?addtag=$1" title="Hashtag $1">#$1</a>'; | 505 | $hashtagLink = '<a href="' . $index . './add-tag/$1" title="Hashtag $1">#$1</a>'; |
504 | return str_replace('$1', $hashtag, $hashtagLink); | 506 | return str_replace('$1', $hashtag, $hashtagLink); |
505 | } | 507 | } |
506 | } | 508 | } |