pictcode / lib / Cake / Test / Case / Log / LogEngineCollectionTest.php @ 4c96e5a3
履歴 | 表示 | アノテート | ダウンロード (2.125 KB)
| 1 | 635eef61 | spyder1211 | <?php
 | 
      
|---|---|---|---|
| 2 | /**
 | 
      ||
| 3 |  * LogEngineCollectionTest file
 | 
      ||
| 4 |  *
 | 
      ||
| 5 |  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
 | 
      ||
| 6 |  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 | 
      ||
| 7 |  *
 | 
      ||
| 8 |  * Licensed under The MIT License
 | 
      ||
| 9 |  * For full copyright and license information, please see the LICENSE.txt
 | 
      ||
| 10 |  * Redistributions of files must retain the above copyright notice
 | 
      ||
| 11 |  *
 | 
      ||
| 12 |  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 | 
      ||
| 13 |  * @link          http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
 | 
      ||
| 14 |  * @package       Cake.Test.Case.Log
 | 
      ||
| 15 |  * @since         CakePHP(tm) v 2.4
 | 
      ||
| 16 |  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 | 
      ||
| 17 |  */
 | 
      ||
| 18 | |||
| 19 | App::uses('LogEngineCollection', 'Log');  | 
      ||
| 20 | App::uses('FileLog', 'Log/Engine');  | 
      ||
| 21 | |||
| 22 | /**
 | 
      ||
| 23 |  * LoggerEngineLog class
 | 
      ||
| 24 |  */
 | 
      ||
| 25 | class LoggerEngineLog extends FileLog {  | 
      ||
| 26 | }  | 
      ||
| 27 | |||
| 28 | /**
 | 
      ||
| 29 |  * LogEngineCollectionTest class
 | 
      ||
| 30 |  *
 | 
      ||
| 31 |  * @package       Cake.Test.Case.Log
 | 
      ||
| 32 |  */
 | 
      ||
| 33 | class LogEngineCollectionTest extends CakeTestCase {  | 
      ||
| 34 | |||
| 35 | public $Collection;  | 
      ||
| 36 | |||
| 37 | /**
 | 
      ||
| 38 |  * Start test callback
 | 
      ||
| 39 |  *
 | 
      ||
| 40 |  * @return void
 | 
      ||
| 41 |  */
 | 
      ||
| 42 | public function setUp() {  | 
      ||
| 43 |                 parent::setUp();
 | 
      ||
| 44 | |||
| 45 | $this->Collection = new LogEngineCollection();  | 
      ||
| 46 | }  | 
      ||
| 47 | |||
| 48 | /**
 | 
      ||
| 49 |  * test load
 | 
      ||
| 50 |  *
 | 
      ||
| 51 |  * @return void
 | 
      ||
| 52 |  */
 | 
      ||
| 53 | public function testLoad() {  | 
      ||
| 54 | $result = $this->Collection->load('key', array('engine' => 'File'));  | 
      ||
| 55 | $this->assertInstanceOf('CakeLogInterface', $result);  | 
      ||
| 56 | }  | 
      ||
| 57 | |||
| 58 | /**
 | 
      ||
| 59 |  * test load with deprecated Log suffix
 | 
      ||
| 60 |  *
 | 
      ||
| 61 |  * @return void
 | 
      ||
| 62 |  */
 | 
      ||
| 63 | public function testLoadWithSuffix() {  | 
      ||
| 64 | $result = $this->Collection->load('key', array('engine' => 'FileLog'));  | 
      ||
| 65 | $this->assertInstanceOf('CakeLogInterface', $result);  | 
      ||
| 66 | }  | 
      ||
| 67 | |||
| 68 | /**
 | 
      ||
| 69 |  * test that engines starting with Log also work properly
 | 
      ||
| 70 |  *
 | 
      ||
| 71 |  * @return void
 | 
      ||
| 72 |  */
 | 
      ||
| 73 | public function testLoadWithSuffixAtBeginning() {  | 
      ||
| 74 | $result = $this->Collection->load('key', array('engine' => 'LoggerEngine'));  | 
      ||
| 75 | $this->assertInstanceOf('CakeLogInterface', $result);  | 
      ||
| 76 | }  | 
      ||
| 77 | |||
| 78 | /**
 | 
      ||
| 79 |  * test load with invalid Log
 | 
      ||
| 80 |  *
 | 
      ||
| 81 |  * @return void
 | 
      ||
| 82 |  * @expectedException CakeLogException
 | 
      ||
| 83 |  */
 | 
      ||
| 84 | public function testLoadInvalid() {  | 
      ||
| 85 | $result = $this->Collection->load('key', array('engine' => 'ImaginaryFile'));  | 
      ||
| 86 | $this->assertInstanceOf('CakeLogInterface', $result);  | 
      ||
| 87 | }  | 
      ||
| 88 | |||
| 89 | }  |