SamplingHandlerTest.php 869 B

12345678910111213141516171819202122232425262728293031
  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\Handler;
  11. /**
  12. * @covers Monolog\Handler\SamplingHandler::handle
  13. */
  14. class SamplingHandlerTest extends \Monolog\Test\MonologTestCase
  15. {
  16. public function testHandle()
  17. {
  18. $testHandler = new TestHandler();
  19. $handler = new SamplingHandler($testHandler, 2);
  20. for ($i = 0; $i < 10000; $i++) {
  21. $handler->handle($this->getRecord());
  22. }
  23. $count = \count($testHandler->getRecords());
  24. // $count should be half of 10k, so between 4k and 6k
  25. $this->assertLessThan(6000, $count);
  26. $this->assertGreaterThan(4000, $count);
  27. }
  28. }