2
0

HandlerWrapperTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. use Monolog\Test\TestCase;
  12. /**
  13. * @author Alexey Karapetov <alexey@karapetov.com>
  14. */
  15. class HandlerWrapperTest extends TestCase
  16. {
  17. /**
  18. * @var HandlerWrapper
  19. */
  20. private $wrapper;
  21. private $handler;
  22. public function setUp(): void
  23. {
  24. parent::setUp();
  25. $this->handler = $this->createMock('Monolog\\Handler\\HandlerInterface');
  26. $this->wrapper = new HandlerWrapper($this->handler);
  27. }
  28. public function tearDown(): void
  29. {
  30. parent::tearDown();
  31. unset($this->wrapper);
  32. }
  33. /**
  34. * @return array
  35. */
  36. public function trueFalseDataProvider()
  37. {
  38. return [
  39. [true],
  40. [false],
  41. ];
  42. }
  43. /**
  44. * @param $result
  45. * @dataProvider trueFalseDataProvider
  46. */
  47. public function testIsHandling($result)
  48. {
  49. $record = $this->getRecord();
  50. $this->handler->expects($this->once())
  51. ->method('isHandling')
  52. ->with($record)
  53. ->willReturn($result);
  54. $this->assertEquals($result, $this->wrapper->isHandling($record));
  55. }
  56. /**
  57. * @param $result
  58. * @dataProvider trueFalseDataProvider
  59. */
  60. public function testHandle($result)
  61. {
  62. $record = $this->getRecord();
  63. $this->handler->expects($this->once())
  64. ->method('handle')
  65. ->with($record)
  66. ->willReturn($result);
  67. $this->assertEquals($result, $this->wrapper->handle($record));
  68. }
  69. /**
  70. * @param $result
  71. * @dataProvider trueFalseDataProvider
  72. */
  73. public function testHandleBatch($result)
  74. {
  75. $records = $this->getMultipleRecords();
  76. $this->handler->expects($this->once())
  77. ->method('handleBatch')
  78. ->with($records);
  79. $this->wrapper->handleBatch($records);
  80. }
  81. }