--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Schema\Schema;
+use Wallabag\CoreBundle\Doctrine\WallabagMigration;
+
+/**
+ * Convert tab label to utf8mb4_bin (MySQL only).
+ */
+final class Version20190511165128 extends WallabagMigration
+{
+ public function up(Schema $schema): void
+ {
+ $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
+
+ $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `slug` `slug` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;');
+ }
+
+ public function down(Schema $schema): void
+ {
+ $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
+
+ $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `slug` `slug` VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
+ }
+}
$this->assertInstanceOf(Tag::class, $newTag, 'Tag "specific label" exists.');
$this->assertTrue($newTag->hasEntry($freshEntry), 'Tag "specific label" is assigned to the entry.');
}
+
+ public function testAddUnicodeTagLabel()
+ {
+ $this->logInAs('admin');
+ $client = $this->getClient();
+
+ $entry = new Entry($this->getLoggedInUser());
+ $entry->setUrl('http://0.0.0.0/tag-caché');
+ $this->getEntityManager()->persist($entry);
+ $this->getEntityManager()->flush();
+ $this->getEntityManager()->clear();
+
+ $crawler = $client->request('GET', '/view/' . $entry->getId());
+
+ $form = $crawler->filter('form[name=tag]')->form();
+
+ $data = [
+ 'tag[label]' => 'cache',
+ ];
+
+ $client->submit($form, $data);
+
+ $crawler = $client->request('GET', '/view/' . $entry->getId());
+
+ $form = $crawler->filter('form[name=tag]')->form();
+
+ $data = [
+ 'tag[label]' => 'caché',
+ ];
+
+ $client->submit($form, $data);
+
+ $newEntry = $client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->find($entry->getId());
+
+ $tags = $newEntry->getTags()->toArray();
+ foreach ($tags as $key => $tag) {
+ $tags[$key] = $tag->getLabel();
+ }
+
+ $this->assertGreaterThanOrEqual(2, \count($tags));
+ $this->assertNotFalse(array_search('cache', $tags, true), 'Tag cache is assigned to the entry');
+ $this->assertNotFalse(array_search('caché', $tags, true), 'Tag caché is assigned to the entry');
+ }
}