Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OutputBambooTestFilter.php
Go to the documentation of this file.
1 <?php
12 namespace Magento\Test\Profiler;
13 
14 class OutputBambooTestFilter extends \php_user_filter
15 {
16  private static $_collectedData = '';
17 
30  public function filter($in, $out, &$consumed, $closing)
31  {
32  while ($bucket = stream_bucket_make_writeable($in)) {
33  self::$_collectedData .= $bucket->data;
34  $consumed += $bucket->datalen;
35  stream_bucket_append($out, $bucket);
36  }
37  return PSFS_PASS_ON;
38  }
39 
40  public static function resetCollectedData()
41  {
42  self::$_collectedData = '';
43  }
44 
50  public static function assertCollectedData($expectedData)
51  {
52  \PHPUnit\Framework\Assert::assertStringMatchesFormat(
53  $expectedData,
54  self::$_collectedData,
55  'Expected data went through the stream.'
56  );
57  }
58 }