RegistryTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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;
  11. class RegistryTest extends \PHPUnit_Framework_TestCase
  12. {
  13. protected function setUp()
  14. {
  15. Registry::clear();
  16. }
  17. /**
  18. * @dataProvider hasLoggerProvider
  19. * @covers Monolog\Registry::hasLogger
  20. */
  21. public function testHasLogger(array $loggersToAdd, array $loggersToCheck, array $expectedResult)
  22. {
  23. foreach ($loggersToAdd as $loggerToAdd) {
  24. Registry::addLogger($loggerToAdd);
  25. }
  26. foreach ($loggersToCheck as $index => $loggerToCheck) {
  27. $this->assertSame($expectedResult[$index], Registry::hasLogger($loggerToCheck));
  28. }
  29. }
  30. public function hasLoggerProvider()
  31. {
  32. $logger1 = new Logger('test1');
  33. $logger2 = new Logger('test2');
  34. $logger3 = new Logger('test3');
  35. return array(
  36. // only instances
  37. array(
  38. array($logger1),
  39. array($logger1, $logger2),
  40. array(true, false),
  41. ),
  42. // only names
  43. array(
  44. array($logger1),
  45. array('test1', 'test2'),
  46. array(true, false),
  47. ),
  48. // mixed case
  49. array(
  50. array($logger1, $logger2),
  51. array('test1', $logger2, 'test3', $logger3),
  52. array(true, true, false, false),
  53. ),
  54. );
  55. }
  56. }