You are here

public function StreamEncoderTest::testEncode in Replication 8

File

tests/src/Kernel/Encoder/StreamEncoderTest.php, line 32

Class

StreamEncoderTest
Tests the stream encoder.

Namespace

Drupal\Tests\replication\Kernel\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'));
}