Brak opisu

MemoryUsageProcessorTest.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  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. use Monolog\TestCase;
  12. class MemoryUsageProcessorTest extends TestCase
  13. {
  14. /**
  15. * @covers Monolog\Processor\MemoryUsageProcessor::__invoke
  16. * @covers Monolog\Processor\MemoryProcessor::formatBytes
  17. */
  18. public function testProcessor()
  19. {
  20. $processor = new MemoryUsageProcessor();
  21. $record = $processor($this->getRecord());
  22. $this->assertArrayHasKey('memory_usage', $record['extra']);
  23. $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_usage']);
  24. }
  25. /**
  26. * @covers Monolog\Processor\MemoryUsageProcessor::__invoke
  27. * @covers Monolog\Processor\MemoryProcessor::formatBytes
  28. */
  29. public function testProcessorWithoutFormatting()
  30. {
  31. $processor = new MemoryUsageProcessor(true, false);
  32. $record = $processor($this->getRecord());
  33. $this->assertArrayHasKey('memory_usage', $record['extra']);
  34. $this->assertInternalType('int', $record['extra']['memory_usage']);
  35. $this->assertGreaterThan(0, $record['extra']['memory_usage']);
  36. }
  37. }