MemoryUsageProcessorTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php declare(strict_types=1);
  2. /*
  3. * This file is part of the Monolog package.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Monolog\Processor;
  11. class MemoryUsageProcessorTest extends \Monolog\Test\MonologTestCase
  12. {
  13. /**
  14. * @covers Monolog\Processor\MemoryUsageProcessor::__invoke
  15. * @covers Monolog\Processor\MemoryProcessor::formatBytes
  16. */
  17. public function testProcessor()
  18. {
  19. $processor = new MemoryUsageProcessor();
  20. $record = $processor($this->getRecord());
  21. $this->assertArrayHasKey('memory_usage', $record->extra);
  22. $this->assertMatchesRegularExpression('#[0-9.]+ (M|K)?B$#', $record->extra['memory_usage']);
  23. }
  24. /**
  25. * @covers Monolog\Processor\MemoryUsageProcessor::__invoke
  26. * @covers Monolog\Processor\MemoryProcessor::formatBytes
  27. */
  28. public function testProcessorWithoutFormatting()
  29. {
  30. $processor = new MemoryUsageProcessor(true, false);
  31. $record = $processor($this->getRecord());
  32. $this->assertArrayHasKey('memory_usage', $record->extra);
  33. $this->assertIsInt($record->extra['memory_usage']);
  34. $this->assertGreaterThan(0, $record->extra['memory_usage']);
  35. }
  36. }