SamplingHandlerTest.php 869 B

1234567891011121314151617181920212223242526272829303132333435
  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. {
  24. $handler->handle($this->getRecord());
  25. }
  26. $count = count($testHandler->getRecords());
  27. // $count should be half of 10k, so between 4k and 6k
  28. $this->assertLessThan(6000, $count);
  29. $this->assertGreaterThan(4000, $count);
  30. }
  31. }