HandlerWrapperTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. * @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()
  23. {
  24. parent::setUp();
  25. $this->handler = $this->getMock('Monolog\\Handler\\HandlerInterface');
  26. $this->wrapper = new HandlerWrapper($this->handler);
  27. }
  28. /**
  29. * @return array
  30. */
  31. public function trueFalseDataProvider()
  32. {
  33. return array(
  34. array(true),
  35. array(false),
  36. );
  37. }
  38. /**
  39. * @param $result
  40. * @dataProvider trueFalseDataProvider
  41. */
  42. public function testIsHandling($result)
  43. {
  44. $record = $this->getRecord();
  45. $this->handler->expects($this->once())
  46. ->method('isHandling')
  47. ->with($record)
  48. ->willReturn($result);
  49. $this->assertEquals($result, $this->wrapper->isHandling($record));
  50. }
  51. /**
  52. * @param $result
  53. * @dataProvider trueFalseDataProvider
  54. */
  55. public function testHandle($result)
  56. {
  57. $record = $this->getRecord();
  58. $this->handler->expects($this->once())
  59. ->method('handle')
  60. ->with($record)
  61. ->willReturn($result);
  62. $this->assertEquals($result, $this->wrapper->handle($record));
  63. }
  64. /**
  65. * @param $result
  66. * @dataProvider trueFalseDataProvider
  67. */
  68. public function testHandleBatch($result)
  69. {
  70. $records = $this->getMultipleRecords();
  71. $this->handler->expects($this->once())
  72. ->method('handleBatch')
  73. ->with($records)
  74. ->willReturn($result);
  75. $this->assertEquals($result, $this->wrapper->handleBatch($records));
  76. }
  77. }