123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php defined('SYSPATH') OR die('Kohana bootstrap needs to be included before tests run');
- /**
- * Tests Kohana Logging API
- *
- * @group kohana
- * @group kohana.core
- * @group kohana.core.logging
- *
- * @package Kohana
- * @category Tests
- * @author Kohana Team
- * @author Matt Button <[email protected]>
- * @copyright (c) 2008-2012 Kohana Team
- * @license http://kohanaframework.org/license
- */
- class Kohana_LogTest extends Unittest_TestCase
- {
- /**
- * Tests that when a new logger is created the list of messages is initially
- * empty
- *
- * @test
- * @covers Log
- */
- public function test_messages_is_initially_empty()
- {
- $logger = new Log;
- $this->assertAttributeSame(array(), '_messages', $logger);
- }
- /**
- * Tests that when a new logger is created the list of writers is initially
- * empty
- *
- * @test
- * @covers Log
- */
- public function test_writers_is_initially_empty()
- {
- $logger = new Log;
- $this->assertAttributeSame(array(), '_writers', $logger);
- }
- /**
- * Test that attaching a log writer using an array of levels adds it to the array of log writers
- *
- * @TODO Is this test too specific?
- *
- * @test
- * @covers Log::attach
- */
- public function test_attach_attaches_log_writer_and_returns_this()
- {
- $logger = new Log;
- $writer = $this->getMockForAbstractClass('Log_Writer');
- $this->assertSame($logger, $logger->attach($writer));
- $this->assertAttributeSame(
- array(spl_object_hash($writer) => array('object' => $writer, 'levels' => array())),
- '_writers',
- $logger
- );
- }
- /**
- * Test that attaching a log writer using a min/max level adds it to the array of log writers
- *
- * @TODO Is this test too specific?
- *
- * @test
- * @covers Log::attach
- */
- public function test_attach_attaches_log_writer_min_max_and_returns_this()
- {
- $logger = new Log;
- $writer = $this->getMockForAbstractClass('Log_Writer');
- $this->assertSame($logger, $logger->attach($writer, Log::NOTICE, Log::CRITICAL));
- $this->assertAttributeSame(
- array(spl_object_hash($writer) => array('object' => $writer, 'levels' => array(Log::CRITICAL, Log::ERROR, Log::WARNING, Log::NOTICE))),
- '_writers',
- $logger
- );
- }
- /**
- * When we call detach() we expect the specified log writer to be removed
- *
- * @test
- * @covers Log::detach
- */
- public function test_detach_removes_log_writer_and_returns_this()
- {
- $logger = new Log;
- $writer = $this->getMockForAbstractClass('Log_Writer');
- $logger->attach($writer);
- $this->assertSame($logger, $logger->detach($writer));
- $this->assertAttributeSame(array(), '_writers', $logger);
- }
- }
|