ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
RegistryTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Monolog package.
5  *
6  * (c) Jordi Boggiano <j.boggiano@seld.be>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Monolog;
13 
15 {
16  protected function setUp()
17  {
18  Registry::clear();
19  }
20 
25  public function testHasLogger(array $loggersToAdd, array $loggersToCheck, array $expectedResult)
26  {
27  foreach ($loggersToAdd as $loggerToAdd) {
28  Registry::addLogger($loggerToAdd);
29  }
30  foreach ($loggersToCheck as $index => $loggerToCheck) {
31  $this->assertSame($expectedResult[$index], Registry::hasLogger($loggerToCheck));
32  }
33  }
34 
35  public function hasLoggerProvider()
36  {
37  $logger1 = new Logger('test1');
38  $logger2 = new Logger('test2');
39  $logger3 = new Logger('test3');
40 
41  return array(
42  // only instances
43  array(
44  array($logger1),
45  array($logger1, $logger2),
46  array(true, false),
47  ),
48  // only names
49  array(
50  array($logger1),
51  array('test1', 'test2'),
52  array(true, false),
53  ),
54  // mixed case
55  array(
56  array($logger1, $logger2),
57  array('test1', $logger2, 'test3', $logger3),
58  array(true, true, false, false),
59  ),
60  );
61  }
62 
66  public function testClearClears()
67  {
68  Registry::addLogger(new Logger('test1'), 'log');
69  Registry::clear();
70 
71  $this->setExpectedException('\InvalidArgumentException');
72  Registry::getInstance('log');
73  }
74 
80  public function testRemovesLogger($loggerToAdd, $remove)
81  {
82  Registry::addLogger($loggerToAdd);
83  Registry::removeLogger($remove);
84 
85  $this->setExpectedException('\InvalidArgumentException');
86  Registry::getInstance($loggerToAdd->getName());
87  }
88 
89  public function removedLoggerProvider()
90  {
91  $logger1 = new Logger('test1');
92 
93  return array(
94  array($logger1, $logger1),
95  array($logger1, 'test1'),
96  );
97  }
98 
104  public function testGetsSameLogger()
105  {
106  $logger1 = new Logger('test1');
107  $logger2 = new Logger('test2');
108 
109  Registry::addLogger($logger1, 'test1');
110  Registry::addLogger($logger2);
111 
112  $this->assertSame($logger1, Registry::getInstance('test1'));
113  $this->assertSame($logger2, Registry::test2());
114  }
115 
121  {
122  Registry::getInstance('test1');
123  }
124 
128  public function testReplacesLogger()
129  {
130  $log1 = new Logger('test1');
131  $log2 = new Logger('test2');
132 
133  Registry::addLogger($log1, 'log');
134 
135  Registry::addLogger($log2, 'log', true);
136 
137  $this->assertSame($log2, Registry::getInstance('log'));
138  }
139 
145  {
146  $log1 = new Logger('test1');
147  $log2 = new Logger('test2');
148 
149  Registry::addLogger($log1, 'log');
150 
151  Registry::addLogger($log2, 'log');
152  }
153 }
testFailsOnUnspecifiedReplacement()
Monolog::addLogger
Monolog log channel.
Definition: Logger.php:27
$index
Definition: metadata.php:60
testClearClears()
Monolog::clear
testHasLogger(array $loggersToAdd, array $loggersToCheck, array $expectedResult)
hasLoggerProvider Monolog::hasLogger
testReplacesLogger()
Monolog::addLogger
Create styles array
The data for the language used.
testRemovesLogger($loggerToAdd, $remove)
removedLoggerProvider Monolog::addLogger Monolog::removeLogger
testGetsSameLogger()
Monolog::addLogger Monolog::getInstance Monolog::__callStatic
testFailsOnNonExistantLogger()
Monolog::getInstance