summaryrefslogtreecommitdiff
path: root/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php
blob: c13e5704e52bb67c732c504af326e1cd4a503c23 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php

class Swift_CharacterReaderFactory_SimpleCharacterReaderFactoryAcceptanceTest extends \PHPUnit_Framework_TestCase
{
    private $_factory;
    private $_prefix = 'Swift_CharacterReader_';

    protected function setUp()
    {
        $this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
    }

    public function testCreatingUtf8Reader()
    {
        foreach (array('utf8', 'utf-8', 'UTF-8', 'UTF8') as $utf8) {
            $reader = $this->_factory->getReaderFor($utf8);
            $this->assertInstanceOf($this->_prefix.'Utf8Reader', $reader);
        }
    }

    public function testCreatingIso8859XReaders()
    {
        $charsets = array();
        foreach (range(1, 16) as $number) {
            foreach (array('iso', 'iec') as $body) {
                $charsets[] = $body.'-8859-'.$number;
                $charsets[] = $body.'8859-'.$number;
                $charsets[] = strtoupper($body).'-8859-'.$number;
                $charsets[] = strtoupper($body).'8859-'.$number;
            }
        }

        foreach ($charsets as $charset) {
            $reader = $this->_factory->getReaderFor($charset);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(1, $reader->getInitialByteSize());
        }
    }

    public function testCreatingWindows125XReaders()
    {
        $charsets = array();
        foreach (range(0, 8) as $number) {
            $charsets[] = 'windows-125'.$number;
            $charsets[] = 'windows125'.$number;
            $charsets[] = 'WINDOWS-125'.$number;
            $charsets[] = 'WINDOWS125'.$number;
        }

        foreach ($charsets as $charset) {
            $reader = $this->_factory->getReaderFor($charset);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(1, $reader->getInitialByteSize());
        }
    }

    public function testCreatingCodePageReaders()
    {
        $charsets = array();
        foreach (range(0, 8) as $number) {
            $charsets[] = 'cp-125'.$number;
            $charsets[] = 'cp125'.$number;
            $charsets[] = 'CP-125'.$number;
            $charsets[] = 'CP125'.$number;
        }

        foreach (array(437, 737, 850, 855, 857, 858, 860,
            861, 863, 865, 866, 869, ) as $number) {
            $charsets[] = 'cp-'.$number;
            $charsets[] = 'cp'.$number;
            $charsets[] = 'CP-'.$number;
            $charsets[] = 'CP'.$number;
        }

        foreach ($charsets as $charset) {
            $reader = $this->_factory->getReaderFor($charset);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(1, $reader->getInitialByteSize());
        }
    }

    public function testCreatingAnsiReader()
    {
        foreach (array('ansi', 'ANSI') as $ansi) {
            $reader = $this->_factory->getReaderFor($ansi);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(1, $reader->getInitialByteSize());
        }
    }

    public function testCreatingMacintoshReader()
    {
        foreach (array('macintosh', 'MACINTOSH') as $mac) {
            $reader = $this->_factory->getReaderFor($mac);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(1, $reader->getInitialByteSize());
        }
    }

    public function testCreatingKOIReaders()
    {
        $charsets = array();
        foreach (array('7', '8-r', '8-u', '8u', '8r') as $end) {
            $charsets[] = 'koi-'.$end;
            $charsets[] = 'koi'.$end;
            $charsets[] = 'KOI-'.$end;
            $charsets[] = 'KOI'.$end;
        }

        foreach ($charsets as $charset) {
            $reader = $this->_factory->getReaderFor($charset);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(1, $reader->getInitialByteSize());
        }
    }

    public function testCreatingIsciiReaders()
    {
        foreach (array('iscii', 'ISCII', 'viscii', 'VISCII') as $charset) {
            $reader = $this->_factory->getReaderFor($charset);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(1, $reader->getInitialByteSize());
        }
    }

    public function testCreatingMIKReader()
    {
        foreach (array('mik', 'MIK') as $charset) {
            $reader = $this->_factory->getReaderFor($charset);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(1, $reader->getInitialByteSize());
        }
    }

    public function testCreatingCorkReader()
    {
        foreach (array('cork', 'CORK', 't1', 'T1') as $charset) {
            $reader = $this->_factory->getReaderFor($charset);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(1, $reader->getInitialByteSize());
        }
    }

    public function testCreatingUcs2Reader()
    {
        foreach (array('ucs-2', 'UCS-2', 'ucs2', 'UCS2') as $charset) {
            $reader = $this->_factory->getReaderFor($charset);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(2, $reader->getInitialByteSize());
        }
    }

    public function testCreatingUtf16Reader()
    {
        foreach (array('utf-16', 'UTF-16', 'utf16', 'UTF16') as $charset) {
            $reader = $this->_factory->getReaderFor($charset);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(2, $reader->getInitialByteSize());
        }
    }

    public function testCreatingUcs4Reader()
    {
        foreach (array('ucs-4', 'UCS-4', 'ucs4', 'UCS4') as $charset) {
            $reader = $this->_factory->getReaderFor($charset);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(4, $reader->getInitialByteSize());
        }
    }

    public function testCreatingUtf32Reader()
    {
        foreach (array('utf-32', 'UTF-32', 'utf32', 'UTF32') as $charset) {
            $reader = $this->_factory->getReaderFor($charset);
            $this->assertInstanceOf($this->_prefix.'GenericFixedWidthReader', $reader);
            $this->assertEquals(4, $reader->getInitialByteSize());
        }
    }
}