You are here

public function StreamEncoderTest::testEncode in Replication 8.2

File

tests/src/Unit/Encoder/StreamEncoderTest.php, line 27

Class

StreamEncoderTest
Tests the stream encoder.

Namespace

Drupal\Tests\replication\Unit\Encoder

Code

public function testEncode() {
  $a_string = 'foo';
  $a = fopen('php://memory', 'w+b');
  fwrite($a, $a_string);
  rewind($a);
  $b_string = 'foo';
  $b = fopen('php://memory', 'w+b');
  fwrite($b, $b_string);
  rewind($b);
  $this
    ->assertEquals($a_string, $this->encoder
    ->encode($a, 'stream'));
  $this
    ->assertEquals(base64_encode($b_string), $this->encoder
    ->encode($b, 'base64_stream'));
}