X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fbookmark%2FLinkUtilsTest.php;h=ef00b92f8c3bce554b2dd56e518fa27bb4578a59;hb=7b18876361f2223672f3a2cac9fc0da16d12d69f;hp=78cb8f2abda69c07b26e9bfe54d7c508eec5ec40;hpb=c03c90a13e1356ca9cf40cc664547c49305cb24b;p=github%2Fshaarli%2FShaarli.git 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 @@ namespace Shaarli\Bookmark; -use PHPUnit\Framework\TestCase; -use ReferenceLinkDB; -use Shaarli\Config\ConfigManager; +use Shaarli\TestCase; require_once 'tests/utils/CurlUtils.php'; @@ -44,6 +42,19 @@ class LinkUtilsTest extends TestCase $this->assertEquals(strtolower($charset), header_extract_charset($headers)); } + /** + * Test headers_extract_charset() when the charset is found with odd quotes. + */ + public function testHeadersExtractExistentCharsetWithQuotes() + { + $charset = 'x-MacCroatian'; + $headers = 'text/html; charset="' . $charset . '"otherstuff="test"'; + $this->assertEquals(strtolower($charset), header_extract_charset($headers)); + + $headers = 'text/html; charset=\'' . $charset . '\'otherstuff="test"'; + $this->assertEquals(strtolower($charset), header_extract_charset($headers)); + } + /** * Test headers_extract_charset() when the charset is not found. */ @@ -388,15 +399,6 @@ class LinkUtilsTest extends TestCase $this->assertEmpty($keywords); } - /** - * Test count_private. - */ - public function testCountPrivateLinks() - { - $refDB = new ReferenceLinkDB(); - $this->assertEquals($refDB->countPrivateLinks(), count_private($refDB->getLinks())); - } - /** * Test text2clickable. */ @@ -448,13 +450,13 @@ class LinkUtilsTest extends TestCase カタカナ #カタカナ」カタカナ\n'; $autolinkedDescription = hashtag_autolink($rawDescription, $index); - $this->assertContains($this->getHashtagLink('hashtag', $index), $autolinkedDescription); - $this->assertNotContains(' #hashtag', $autolinkedDescription); - $this->assertNotContains('>#nothashtag', $autolinkedDescription); - $this->assertContains($this->getHashtagLink('ашок', $index), $autolinkedDescription); - $this->assertContains($this->getHashtagLink('カタカナ', $index), $autolinkedDescription); - $this->assertContains($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription); - $this->assertNotContains($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription); + $this->assertContainsPolyfill($this->getHashtagLink('hashtag', $index), $autolinkedDescription); + $this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription); + $this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription); + $this->assertContainsPolyfill($this->getHashtagLink('ашок', $index), $autolinkedDescription); + $this->assertContainsPolyfill($this->getHashtagLink('カタカナ', $index), $autolinkedDescription); + $this->assertContainsPolyfill($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription); + $this->assertNotContainsPolyfill($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription); } /** @@ -465,9 +467,9 @@ class LinkUtilsTest extends TestCase $rawDescription = 'blabla #hashtag x#nothashtag'; $autolinkedDescription = hashtag_autolink($rawDescription); - $this->assertContains($this->getHashtagLink('hashtag'), $autolinkedDescription); - $this->assertNotContains(' #hashtag', $autolinkedDescription); - $this->assertNotContains('>#nothashtag', $autolinkedDescription); + $this->assertContainsPolyfill($this->getHashtagLink('hashtag'), $autolinkedDescription); + $this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription); + $this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription); } /** @@ -500,7 +502,7 @@ class LinkUtilsTest extends TestCase */ private function getHashtagLink($hashtag, $index = '') { - $hashtagLink = '#$1'; + $hashtagLink = '#$1'; return str_replace('$1', $hashtag, $hashtagLink); } }