class LoggerChannelFactoryTest in Service Container 7
Same name and namespace in other branches
- 7.2 tests/src/Logger/LoggerChannelFactoryTest.php \Drupal\Tests\service_container\Logger\LoggerChannelFactoryTest
@coversDefaultClass \Drupal\service_container\Logger\LoggerChannelFactory
Hierarchy
- class \Drupal\Tests\service_container\Logger\LoggerChannelFactoryTest extends \Drupal\Tests\service_container\Logger\PHPUnit_Framework_TestCase
Expanded class hierarchy of LoggerChannelFactoryTest
File
- tests/
src/ Logger/ LoggerChannelFactoryTest.php, line 15 - Contains \Drupal\Tests\service_container\Logger\LoggerChannelFactoryTest.
Namespace
Drupal\Tests\service_container\LoggerView source
class LoggerChannelFactoryTest extends \PHPUnit_Framework_TestCase {
/**
* The tested logger channel.
*
* @var \Drupal\service_container\Logger\LoggerChannelFactory
*/
protected $loggerChannelFactory;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loggerChannelFactory = new LoggerChannelFactory();
}
/**
* @covers ::get()
*/
public function test_get_noLoggers() {
$logger_channel1 = $this->loggerChannelFactory
->get('test');
$this
->assertInstanceOf('Drupal\\service_container\\Logger\\LoggerChannel', $logger_channel1);
$logger_channel2 = $this->loggerChannelFactory
->get('test');
$this
->assertSame($logger_channel1, $logger_channel2);
$logger_channel3 = $this->loggerChannelFactory
->get('test2');
$this
->assertInstanceOf('Drupal\\service_container\\Logger\\LoggerChannel', $logger_channel3);
$this
->assertNotSame($logger_channel1, $logger_channel3);
}
/**
* @covers ::get()
* @covers ::addLogger()
*/
public function test_get_withExistingLoggers() {
$logger1 = \Mockery::mock('Psr\\Log\\LoggerInterface');
$logger2 = \Mockery::mock('Psr\\Log\\LoggerInterface');
$this->loggerChannelFactory
->addLogger($logger1);
$this->loggerChannelFactory
->addLogger($logger2);
$logger_channel = $this->loggerChannelFactory
->get('test');
$this
->assertAttributeEquals(array(
0 => array(
$logger1,
$logger2,
),
), 'loggers', $logger_channel);
}
/**
* @covers ::get()
* @covers ::addLogger()
*/
public function test_get_withExistingLoggersWithPriority() {
$logger1 = \Mockery::mock('Psr\\Log\\LoggerInterface');
$logger2 = \Mockery::mock('Psr\\Log\\LoggerInterface');
$this->loggerChannelFactory
->addLogger($logger1, 0);
$this->loggerChannelFactory
->addLogger($logger2, 10);
$logger_channel = $this->loggerChannelFactory
->get('test');
$this
->assertAttributeEquals(array(
0 => array(
$logger1,
),
10 => array(
$logger2,
),
), 'loggers', $logger_channel);
}
/**
* @covers ::addLogger()
*/
public function test_addLogger_withExistingLoggerChannel() {
$logger_channel1 = $this->loggerChannelFactory
->get('test');
$logger_channel2 = $this->loggerChannelFactory
->get('test2');
$logger = \Mockery::mock('Psr\\Log\\LoggerInterface');
$this->loggerChannelFactory
->addLogger($logger);
$this
->assertAttributeEquals(array(
0 => array(
$logger,
),
), 'loggers', $logger_channel1);
$this
->assertAttributeEquals(array(
0 => array(
$logger,
),
), 'loggers', $logger_channel2);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LoggerChannelFactoryTest:: |
protected | property | The tested logger channel. | |
LoggerChannelFactoryTest:: |
protected | function | ||
LoggerChannelFactoryTest:: |
public | function | @covers ::addLogger() | |
LoggerChannelFactoryTest:: |
public | function | @covers ::get() | |
LoggerChannelFactoryTest:: |
public | function | @covers ::get() @covers ::addLogger() | |
LoggerChannelFactoryTest:: |
public | function | @covers ::get() @covers ::addLogger() |