public function testReadResource()
 {
     $decoder = new Utf8();
     // Read the file.
     $string = file_get_contents(dirname(dirname(dirname(__FILE__))) . '/test-resources/utf-8.txt');
     $this->assertTrue(mb_check_encoding($string, 'utf-8'));
     // Get the unicode stream.
     $stream = $decoder->decode($string, 'utf-8');
     $this->assertSame(mb_strlen($string, 'utf-8'), count($stream));
     // Re-encode the unicode stream.
     $encoded = $decoder->encode($stream, 'utf-8');
     $this->assertSame($string, $encoded);
 }
 /**
  * @dataProvider encodingProvider
  */
 public function testReadResource($encoding)
 {
     $decoder = new SingleByteDecoder();
     // Read the file.
     $string = file_get_contents(dirname(dirname(dirname(__FILE__))) . '/test-resources/' . $encoding . '.txt');
     // Get the unicode stream.
     $stream = $decoder->decode($string, $encoding);
     $utf8 = mb_convert_encoding($string, 'utf-8', $encoding);
     $utf8Encoder = new Utf8();
     $this->assertSame($utf8, $utf8Encoder->encode($stream));
     // Re-encode the unicode stream.
     $encoded = $decoder->encode($stream, $encoding);
     $this->assertSame($string, $encoded);
 }