Skip to content

Commit 21c34d8

Browse files
committed
Changes
1 parent 5971be2 commit 21c34d8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/FileEncodingTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
namespace Descom\File_Encoding\Test;
3+
use Descom\File_Encoding\FileEncoding;
4+
5+
class FileEncodingTest extends TestCase
6+
{
7+
public function setUp()
8+
{
9+
parent::setUp();
10+
copy('files/test_iso88591.txt', 'iso88591.txt');
11+
copy('files/test_utf8.txt', 'utf8.txt');
12+
}
13+
14+
/** @test */
15+
public function test_encoding_iso88591_as_UTF8()
16+
{
17+
$encoding = new FileEncoding();
18+
$result = FileEncoding->encodeFile('iso88591.txt', 'UTF-8', 'UTF-8,ISO-8859-1,WINDOWS-1252');
19+
$this->assertTrue($result);
20+
}
21+
22+
/** @test */
23+
public function test_encoding_UTF8_as_UTF8()
24+
{
25+
$encoding = new FileEncoding();
26+
$result = FileEncoding->encodeFile('utf8.txt');
27+
$this->assertTrue($result);
28+
}
29+
30+
/** @test */
31+
public function test_encoding_file_not_exists()
32+
{
33+
$encoding = new FileEncoding();
34+
$result = FileEncoding->encodeFile('test.txt');
35+
$this->assertTrue(!$result);
36+
}
37+
}

0 commit comments

Comments
 (0)