@@ 61-73 (lines=13) @@ | ||
58 | $this->converter->modify($randomThing); |
|
59 | } |
|
60 | ||
61 | public function testChangeEncodingCanConvertBetweenASCIIAndUtf8() |
|
62 | { |
|
63 | $asciiFile = new LocalFile(static::$dir . 'ascii_file.test'); |
|
64 | $asciiFile->put(mb_convert_encoding('Some random Text', 'ASCII')); |
|
65 | ||
66 | $isAscii = exec("file {$asciiFile->getPath()} | grep -i " . escapeshellarg('\bascii\b') . " | wc -l"); |
|
67 | static::assertEquals(1, $isAscii, "Original file to convert is not ascii"); |
|
68 | ||
69 | $newFile = $this->converter->toEncoding($asciiFile, 'UTF-8'); |
|
70 | ||
71 | $isUTF8 = exec("file {$newFile->getPath()} | grep -i " . escapeshellarg('\UTF-8\b') . " | wc -l"); |
|
72 | static::assertEquals(1, $isUTF8, "Converted file should be UTF8"); |
|
73 | } |
|
74 | ||
75 | public function testCallingModifyWillConvertTheEncoding() |
|
76 | { |
|
@@ 75-87 (lines=13) @@ | ||
72 | static::assertEquals(1, $isUTF8, "Converted file should be UTF8"); |
|
73 | } |
|
74 | ||
75 | public function testCallingModifyWillConvertTheEncoding() |
|
76 | { |
|
77 | $asciiFile = new LocalFile(static::$dir . 'ascii_file_modify.test'); |
|
78 | $asciiFile->put(mb_convert_encoding('Some random Text', 'ASCII')); |
|
79 | ||
80 | $isAscii = exec("file {$asciiFile->getPath()} | grep -i " . escapeshellarg('\bascii\b') . " | wc -l"); |
|
81 | static::assertEquals(1, $isAscii, "Original file to convert is not ascii"); |
|
82 | ||
83 | $newFile = $this->converter->modify($asciiFile, ['encoding' => 'UTF-8']); |
|
84 | ||
85 | $isUTF8 = exec("file {$newFile->getPath()} | grep -i " . escapeshellarg('\UTF-8\b') . " | wc -l"); |
|
86 | static::assertEquals(1, $isUTF8, "Converted file should be UTF8"); |
|
87 | } |
|
88 | ||
89 | public function testChangeEncodingCanConvertBetweenUTF8AndUTF16() |
|
90 | { |
|
@@ 89-102 (lines=14) @@ | ||
86 | static::assertEquals(1, $isUTF8, "Converted file should be UTF8"); |
|
87 | } |
|
88 | ||
89 | public function testChangeEncodingCanConvertBetweenUTF8AndUTF16() |
|
90 | { |
|
91 | $utf8file = new LocalFile(static::$dir . 'utf8_file.test'); |
|
92 | $utf8file->setEncoding('UTF-8'); |
|
93 | $utf8file->put(mb_convert_encoding('Some random Text €±§', 'UTF-8')); |
|
94 | ||
95 | $isUtf8 = exec("file {$utf8file->getPath()} | grep -i " . escapeshellarg('\butf-8\b') . " | wc -l"); |
|
96 | static::assertEquals(1, $isUtf8, "Original file to convert is not utf-8"); |
|
97 | ||
98 | $newFile = $this->converter->toEncoding($utf8file, 'UTF-16'); |
|
99 | ||
100 | $isUTF16 = exec("file {$newFile->getPath()} | grep -i " . escapeshellarg('\UTF-16\b') . " | wc -l"); |
|
101 | static::assertEquals(1, $isUTF16, "Converted file should be UTF16"); |
|
102 | } |
|
103 | ||
104 | public function testSpecifyingThePostfixWillUseThatForTheFile() |
|
105 | { |