Completed
Push — master ( e32eeb...714cda )
by
unknown
89:50 queued 46:29
created

ContentDecoderTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 76
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testDecode() 0 7 1
A dataProvider() 0 57 1
1
<?php
2
3
namespace Oro\Bundle\EmailBundle\Tests\Unit\Decoder;
4
5
use Oro\Bundle\EmailBundle\Decoder\ContentDecoder;
6
7
class ContentDecoderTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @param string $str
11
     * @param string $contentTransferEncoding
12
     * @param string $fromEncode
13
     * @param string $toEncode
14
     * @param string $expected
15
     * @dataProvider dataProvider
16
     */
17
    public function testDecode($str, $contentTransferEncoding, $fromEncode, $toEncode, $expected)
18
    {
19
        $decoder = new ContentDecoder();
20
        $str = $decoder->decode($str, $contentTransferEncoding, $fromEncode, $toEncode);
21
22
        $this->assertEquals($expected, $str);
23
    }
24
25
    public function dataProvider()
26
    {
27
        return [
28
            'default' => [
29
                'string' => 'test',
30
                'contentTransferEncoding' => null,
31
                'fromEncode' => null,
32
                'toEncode' => null,
33
                'expected' => 'test'
34
            ],
35
            'simple base64' => [
36
                'string' => 'dGVzdA==',
37
                'contentTransferEncoding' => 'base64',
38
                'fromEncode' => null,
39
                'toEncode' => null,
40
                'expected' => 'test'
41
            ],
42
            'simple quoted-printable' => [
43
                'string' => 'test',
44
                'contentTransferEncoding' => 'quoted-printable',
45
                'fromEncode' => null,
46
                'toEncode' => null,
47
                'expected' => 'test'
48
            ],
49
            'simple quoted-printable encoded' => [
50
                'string' => 'test',
51
                'contentTransferEncoding' => 'quoted-printable',
52
                'fromEncode' => 'UTF-8',
53
                'toEncode' => 'windows-1250',
54
                'expected' => 'test'
55
            ],
56
            'UTF-8 quoted-printable' => [
57
                'string' => '=D1=80=D1=83=D1=80=D1=83bubu',
58
                'contentTransferEncoding' => 'quoted-printable',
59
                'fromEncode' => 'UTF-8',
60
                'toEncode' => 'UTF-8',
61
                'expected' => 'руруbubu'
62
            ],
63
            'koi8-r quoted-printable' => [
64
                'string' => 'T. &#268;ktesttest',
65
                'contentTransferEncoding' => 'quoted-printable',
66
                'fromEncode' => 'koi8-r',
67
                'toEncode' => 'UTF-8',
68
                'expected' => 'T. &#268;ktesttest'
69
            ],
70
            'windows-1250 quoted-printable' => [
71
                'string' => '<DIV><FONT face=3DArial=20
72
size=3D2>khsdkjdsljkdskl=9A=E8=9A=E8=9A=E8=F8=E8=F8=E8=E8=F8ffdssfdsfdsdf=
73
sdfsdf=E8dffdsd</FONT></DIV>',
74
                'contentTransferEncoding' => 'quoted-printable',
75
                'fromEncode' => 'windows-1250',
76
                'toEncode' => 'UTF-8',
77
                'expected' => '<DIV><FONT face=Arial 
78
size=2>khsdkjdsljkdsklščščščřčřččřffdssfdsfdsdfsdfsdfčdffdsd</FONT></DIV>'
79
            ],
80
        ];
81
    }
82
}
83