X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fbookmark%2FLinkUtilsTest.php;h=ef00b92f8c3bce554b2dd56e518fa27bb4578a59;hb=7b18876361f2223672f3a2cac9fc0da16d12d69f;hp=591976f2c30b1a293ec7f845972147a02c3420c4;hpb=e26e2060f5470ce8bf4c5973284bae07b8af170a;p=github%2Fshaarli%2FShaarli.git
diff --git a/tests/bookmark/LinkUtilsTest.php b/tests/bookmark/LinkUtilsTest.php
index 591976f2..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.
*/
@@ -439,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);
}
/**
@@ -456,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);
}
/**
@@ -491,7 +502,7 @@ class LinkUtilsTest extends TestCase
*/
private function getHashtagLink($hashtag, $index = '')
{
- $hashtagLink = '#$1';
+ $hashtagLink = '#$1';
return str_replace('$1', $hashtag, $hashtagLink);
}
}