diff options
Diffstat (limited to 'tests/bookmark/LinkUtilsTest.php')
-rw-r--r-- | tests/bookmark/LinkUtilsTest.php | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/tests/bookmark/LinkUtilsTest.php b/tests/bookmark/LinkUtilsTest.php index cc7819bc..29941c8c 100644 --- a/tests/bookmark/LinkUtilsTest.php +++ b/tests/bookmark/LinkUtilsTest.php | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | namespace Shaarli\Bookmark; | 3 | namespace Shaarli\Bookmark; |
4 | 4 | ||
5 | use PHPUnit\Framework\TestCase; | 5 | use Shaarli\TestCase; |
6 | 6 | ||
7 | require_once 'tests/utils/CurlUtils.php'; | 7 | require_once 'tests/utils/CurlUtils.php'; |
8 | 8 | ||
@@ -43,6 +43,19 @@ class LinkUtilsTest extends TestCase | |||
43 | } | 43 | } |
44 | 44 | ||
45 | /** | 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 | /** | ||
46 | * Test headers_extract_charset() when the charset is not found. | 59 | * Test headers_extract_charset() when the charset is not found. |
47 | */ | 60 | */ |
48 | public function testHeadersExtractNonExistentCharset() | 61 | public function testHeadersExtractNonExistentCharset() |
@@ -526,13 +539,13 @@ class LinkUtilsTest extends TestCase | |||
526 | カタカナ #カタカナ」カタカナ\n'; | 539 | カタカナ #カタカナ」カタカナ\n'; |
527 | $autolinkedDescription = hashtag_autolink($rawDescription, $index); | 540 | $autolinkedDescription = hashtag_autolink($rawDescription, $index); |
528 | 541 | ||
529 | $this->assertContains($this->getHashtagLink('hashtag', $index), $autolinkedDescription); | 542 | $this->assertContainsPolyfill($this->getHashtagLink('hashtag', $index), $autolinkedDescription); |
530 | $this->assertNotContains(' #hashtag', $autolinkedDescription); | 543 | $this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription); |
531 | $this->assertNotContains('>#nothashtag', $autolinkedDescription); | 544 | $this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription); |
532 | $this->assertContains($this->getHashtagLink('ашок', $index), $autolinkedDescription); | 545 | $this->assertContainsPolyfill($this->getHashtagLink('ашок', $index), $autolinkedDescription); |
533 | $this->assertContains($this->getHashtagLink('カタカナ', $index), $autolinkedDescription); | 546 | $this->assertContainsPolyfill($this->getHashtagLink('カタカナ', $index), $autolinkedDescription); |
534 | $this->assertContains($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription); | 547 | $this->assertContainsPolyfill($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription); |
535 | $this->assertNotContains($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription); | 548 | $this->assertNotContainsPolyfill($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription); |
536 | } | 549 | } |
537 | 550 | ||
538 | /** | 551 | /** |
@@ -543,9 +556,9 @@ class LinkUtilsTest extends TestCase | |||
543 | $rawDescription = 'blabla #hashtag x#nothashtag'; | 556 | $rawDescription = 'blabla #hashtag x#nothashtag'; |
544 | $autolinkedDescription = hashtag_autolink($rawDescription); | 557 | $autolinkedDescription = hashtag_autolink($rawDescription); |
545 | 558 | ||
546 | $this->assertContains($this->getHashtagLink('hashtag'), $autolinkedDescription); | 559 | $this->assertContainsPolyfill($this->getHashtagLink('hashtag'), $autolinkedDescription); |
547 | $this->assertNotContains(' #hashtag', $autolinkedDescription); | 560 | $this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription); |
548 | $this->assertNotContains('>#nothashtag', $autolinkedDescription); | 561 | $this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription); |
549 | } | 562 | } |
550 | 563 | ||
551 | /** | 564 | /** |