File size: 2,309 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php

namespace Mautic\FormBundle\Tests\Controller;

use Mautic\CoreBundle\Test\MauticMysqlTestCase;
use Mautic\FormBundle\Entity\Form;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\HttpFoundation\Request;

final class ActionControllerFunctionalTest extends MauticMysqlTestCase
{
    /**
     * @throws \Doctrine\ORM\OptimisticLockException
     * @throws \Doctrine\ORM\ORMException
     */
    public function testNewActionWithJapanese(): void
    {
        // Create new form
        $form = new Form();
        $form->setName('Test Form');
        $form->setAlias('testform');
        $this->em->persist($form);
        $this->em->flush();

        // Fetch the form
        $this->client->request(Request::METHOD_GET, '/s/forms/action/new',
            [
                'formId' => $form->getId(),
                'type'   => 'form.email',
            ],
            [],
            $this->createAjaxHeaders(),
        );
        $this->assertTrue($this->client->getResponse()->isOk());
        $content     = $this->client->getResponse()->getContent();
        $content     = json_decode($content)->newContent;
        $crawler     = new Crawler($content, $this->client->getInternalRequest()->getUri());
        $formCrawler = $crawler->filter('form');
        $this->assertCount(1, $formCrawler);
        $form = $formCrawler->form();

        // Save new Send Form Results action
        $form->setValues([
            'formaction[properties][subject]' => 'Test Japanese',
            'formaction[properties][message]' => '<p style="font-family: メイリオ">Test</p>',
        ]);
        $this->client->submit($form, [], $this->createAjaxHeaders());
        $this->assertTrue($this->client->getResponse()->isOk());
        $content  = $this->client->getResponse()->getContent();
        $content  = json_decode($content)->actionHtml;
        $crawler  = new Crawler($content);
        $editPage = $crawler->filter('.btn-edit')->attr('href');

        // Check the content was not changed
        $this->client->request(Request::METHOD_GET, $editPage, [], [], $this->createAjaxHeaders());
        $this->assertStringContainsString('&lt;p style=&quot;font-family: メイリオ&quot;&gt;Test&lt;/p&gt;', json_decode($this->client->getResponse()->getContent())->newContent);
    }
}