SamplingHandlerTest.php 865 B

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