Created
June 25, 2016 16:57
-
-
Save stefanruijsenaars/8bbc113b083e58339ac0f44534ccc897 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/modules/node/node.test b/modules/node/node.test | |
index c7c4711..cb56e85 100644 | |
--- a/modules/node/node.test | |
+++ b/modules/node/node.test | |
@@ -2986,3 +2986,52 @@ class NodePageCacheTest extends NodeWebTestCase { | |
$this->assertResponse(404); | |
} | |
} | |
+ | |
+/** | |
+ * Tests that we store and retrieve multi-byte UTF-8 characters correctly. | |
+ */ | |
+class NodeMultiByteUtf8Test extends NodeWebTestCase { | |
+ | |
+ /** | |
+ * {@inheritdoc} | |
+ */ | |
+ function setUp() { | |
+ parent::setUp(); | |
+ $connection = Database::getConnection(); | |
+ if ($connection->driver() == 'mysql' && $connection->utf8mb4IsAvailable()) { | |
+ $connection_info = Database::getConnectionInfo('default'); | |
+ Database::renameConnection('default', 'default_previous'); | |
+ foreach ($connection_info as $target => $value) { | |
+ $connection_info[$target]['prefix'] = array( | |
+ 'charset' => 'utf8mb4', | |
+ 'collation' => 'utf8mb4_general_ci', | |
+ ); | |
+ } | |
+ Database::addConnectionInfo('default', 'default', $connection_info['default']); | |
+ } | |
+ } | |
+ | |
+ /** | |
+ * Tests that we store and retrieve multi-byte UTF-8 characters correctly. | |
+ */ | |
+ public function testMultiByteUtf8() { | |
+ $connection = Database::getConnection(); | |
+ if ($connection->driver() == 'mysql' && !$connection->utf8mb4IsAvailable()) { | |
+ return; | |
+ } | |
+ $title = '<U+1F41D>'; | |
+ $this->assertTrue(mb_strlen($title, 'utf-8') < strlen($title), 'Title has multi-byte characters.'); | |
+ $node = $this->drupalCreateNode(array('title' => $title)); | |
+ $this->drupalGet($node->urlInfo()); | |
+ $result = $this->xpath('//span[contains(@class, "field-name-title")]'); | |
+ $this->assertEqual((string) $result[0], $title, 'The passed title was returned.'); | |
+ } | |
+ | |
+ /** | |
+ * {@inheritdoc} | |
+ */ | |
+ function tearDown() { | |
+ Database::renameConnection('default_previous', 'default'); | |
+ parent::tearDown(); | |
+ } | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment