SamplingHandlerTest.php 850 B

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