From e26e2060f5470ce8bf4c5973284bae07b8af170a Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 17 Jan 2020 21:34:12 +0100 Subject: Add and update unit test for the new system (Bookmark + Service) See #1307 --- tests/bookmark/LinkUtilsTest.php | 9 --------- 1 file changed, 9 deletions(-) (limited to 'tests/bookmark/LinkUtilsTest.php') diff --git a/tests/bookmark/LinkUtilsTest.php b/tests/bookmark/LinkUtilsTest.php index 78cb8f2a..591976f2 100644 --- a/tests/bookmark/LinkUtilsTest.php +++ b/tests/bookmark/LinkUtilsTest.php @@ -388,15 +388,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. */ -- cgit v1.2.3 From 03340c18ead651ef9e11f883745695f2edafbae3 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 12 May 2020 12:44:48 +0200 Subject: Slim router: handle add tag route --- tests/bookmark/LinkUtilsTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests/bookmark/LinkUtilsTest.php') diff --git a/tests/bookmark/LinkUtilsTest.php b/tests/bookmark/LinkUtilsTest.php index 591976f2..7d4a7b89 100644 --- a/tests/bookmark/LinkUtilsTest.php +++ b/tests/bookmark/LinkUtilsTest.php @@ -3,8 +3,6 @@ namespace Shaarli\Bookmark; use PHPUnit\Framework\TestCase; -use ReferenceLinkDB; -use Shaarli\Config\ConfigManager; require_once 'tests/utils/CurlUtils.php'; @@ -491,7 +489,7 @@ class LinkUtilsTest extends TestCase */ private function getHashtagLink($hashtag, $index = '') { - $hashtagLink = '#$1'; + $hashtagLink = '#$1'; return str_replace('$1', $hashtag, $hashtagLink); } } -- cgit v1.2.3 From a5a9cf23acd1248585173aa32757d9720b5f2d62 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 29 Sep 2020 14:41:40 +0200 Subject: Compatibility with PHPUnit 9 --- tests/bookmark/LinkUtilsTest.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tests/bookmark/LinkUtilsTest.php') diff --git a/tests/bookmark/LinkUtilsTest.php b/tests/bookmark/LinkUtilsTest.php index 7d4a7b89..a7087953 100644 --- a/tests/bookmark/LinkUtilsTest.php +++ b/tests/bookmark/LinkUtilsTest.php @@ -2,7 +2,7 @@ namespace Shaarli\Bookmark; -use PHPUnit\Framework\TestCase; +use Shaarli\TestCase; require_once 'tests/utils/CurlUtils.php'; @@ -437,13 +437,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); } /** @@ -454,9 +454,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); } /** -- cgit v1.2.3 From 1ea09a1b8b8b7f68ec8c7ef069393ee58a0e623a Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 26 Sep 2020 13:28:38 +0200 Subject: Fix warning if the encoding retrieved from external headers is invalid Also fixed the regex to support this failing header: charset="utf-8"\r\n" --- tests/bookmark/LinkUtilsTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/bookmark/LinkUtilsTest.php') diff --git a/tests/bookmark/LinkUtilsTest.php b/tests/bookmark/LinkUtilsTest.php index 7d4a7b89..0d07897b 100644 --- a/tests/bookmark/LinkUtilsTest.php +++ b/tests/bookmark/LinkUtilsTest.php @@ -42,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. */ -- cgit v1.2.3