Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MultipleStreamOutputTest.php
Go to the documentation of this file.
1 <?php
7 
8 class MultipleStreamOutputTest extends \PHPUnit\Framework\TestCase
9 {
13  private $multipleStreamOutput;
14 
15  public function setUp()
16  {
17  $this->multipleStreamOutput = new MultipleStreamOutput(
18  [
19  fopen(__DIR__ . '/_files/a.txt', 'a+'),
20  fopen(__DIR__ . '/_files/b.txt', 'a+')
21  ]
22  );
23  }
24 
25  public function tearDown()
26  {
27  file_put_contents(__DIR__ . '/_files/a.txt', '');
28  file_put_contents(__DIR__ . '/_files/b.txt', '');
29  }
30 
35  public function testCreateException()
36  {
37  $this->multipleStreamOutput = new MultipleStreamOutput(['a', 'b']);
38  }
39 
40  public function testWriteln()
41  {
42  $this->multipleStreamOutput->writeln('Hello world');
43  $this->assertEquals('Hello world' . PHP_EOL, file_get_contents(__DIR__ . '/_files/a.txt'));
44  $this->assertEquals('Hello world' . PHP_EOL, file_get_contents(__DIR__ . '/_files/b.txt'));
45  }
46 
47  public function testWrite()
48  {
49  $this->multipleStreamOutput->write('Hello world');
50  $this->assertEquals('Hello world', file_get_contents(__DIR__ . '/_files/a.txt'));
51  $this->assertEquals('Hello world', file_get_contents(__DIR__ . '/_files/b.txt'));
52  }
53 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60