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 7d4a7b89..ef00b92f 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() |
@@ -437,13 +450,13 @@ class LinkUtilsTest extends TestCase | |||
437 | カタカナ #カタカナ」カタカナ\n'; | 450 | カタカナ #カタカナ」カタカナ\n'; |
438 | $autolinkedDescription = hashtag_autolink($rawDescription, $index); | 451 | $autolinkedDescription = hashtag_autolink($rawDescription, $index); |
439 | 452 | ||
440 | $this->assertContains($this->getHashtagLink('hashtag', $index), $autolinkedDescription); | 453 | $this->assertContainsPolyfill($this->getHashtagLink('hashtag', $index), $autolinkedDescription); |
441 | $this->assertNotContains(' #hashtag', $autolinkedDescription); | 454 | $this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription); |
442 | $this->assertNotContains('>#nothashtag', $autolinkedDescription); | 455 | $this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription); |
443 | $this->assertContains($this->getHashtagLink('ашок', $index), $autolinkedDescription); | 456 | $this->assertContainsPolyfill($this->getHashtagLink('ашок', $index), $autolinkedDescription); |
444 | $this->assertContains($this->getHashtagLink('カタカナ', $index), $autolinkedDescription); | 457 | $this->assertContainsPolyfill($this->getHashtagLink('カタカナ', $index), $autolinkedDescription); |
445 | $this->assertContains($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription); | 458 | $this->assertContainsPolyfill($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription); |
446 | $this->assertNotContains($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription); | 459 | $this->assertNotContainsPolyfill($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription); |
447 | } | 460 | } |
448 | 461 | ||
449 | /** | 462 | /** |
@@ -454,9 +467,9 @@ class LinkUtilsTest extends TestCase | |||
454 | $rawDescription = 'blabla #hashtag x#nothashtag'; | 467 | $rawDescription = 'blabla #hashtag x#nothashtag'; |
455 | $autolinkedDescription = hashtag_autolink($rawDescription); | 468 | $autolinkedDescription = hashtag_autolink($rawDescription); |
456 | 469 | ||
457 | $this->assertContains($this->getHashtagLink('hashtag'), $autolinkedDescription); | 470 | $this->assertContainsPolyfill($this->getHashtagLink('hashtag'), $autolinkedDescription); |
458 | $this->assertNotContains(' #hashtag', $autolinkedDescription); | 471 | $this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription); |
459 | $this->assertNotContains('>#nothashtag', $autolinkedDescription); | 472 | $this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription); |
460 | } | 473 | } |
461 | 474 | ||
462 | /** | 475 | /** |