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