]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php
MediaWiki 1.30.2
[autoinstalls/mediawiki.git] / vendor / monolog / monolog / tests / Monolog / Processor / MemoryPeakUsageProcessorTest.php
1 <?php
2
3 /*
4  * This file is part of the Monolog package.
5  *
6  * (c) Jordi Boggiano <j.boggiano@seld.be>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Monolog\Processor;
13
14 use Monolog\TestCase;
15
16 class MemoryPeakUsageProcessorTest extends TestCase
17 {
18     /**
19      * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke
20      * @covers Monolog\Processor\MemoryProcessor::formatBytes
21      */
22     public function testProcessor()
23     {
24         $processor = new MemoryPeakUsageProcessor();
25         $record = $processor($this->getRecord());
26         $this->assertArrayHasKey('memory_peak_usage', $record['extra']);
27         $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_peak_usage']);
28     }
29
30     /**
31      * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke
32      * @covers Monolog\Processor\MemoryProcessor::formatBytes
33      */
34     public function testProcessorWithoutFormatting()
35     {
36         $processor = new MemoryPeakUsageProcessor(true, false);
37         $record = $processor($this->getRecord());
38         $this->assertArrayHasKey('memory_peak_usage', $record['extra']);
39         $this->assertInternalType('int', $record['extra']['memory_peak_usage']);
40         $this->assertGreaterThan(0, $record['extra']['memory_peak_usage']);
41     }
42 }