2
0
Просмотр исходного кода

ZF-9790: add unit test on formatter and filter factory feature of Zend_Log in the resource plugin (patch by Aaron S. Hawley)

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23642 44c647ce-9c0f-0410-b52a-842ac1e357ba
intiilapa 15 лет назад
Родитель
Сommit
87daffab86
1 измененных файлов с 39 добавлено и 1 удалено
  1. 39 1
      tests/Zend/Application/Resource/LogTest.php

+ 39 - 1
tests/Zend/Application/Resource/LogTest.php

@@ -145,8 +145,46 @@ class Zend_Application_Resource_LogTest extends PHPUnit_Framework_TestCase
         $resource->setBootstrap($this->bootstrap);
         $resource->init();
     }
+
+    /**
+     * @group ZF-9790
+     */
+    public function testInitializationWithFilterAndFormatter()
+    {
+        $stream = fopen('php://memory', 'w+');
+        $options = array(
+            'memory' => array(
+                'writerName' => 'Stream',
+                'writerParams' => array(
+                     'stream' => $stream,
+                ),
+                'filterName' => 'Priority',
+                'filterParams' => array(
+                    'priority' => Zend_Log::INFO,
+                ),
+                'formatterName' => 'Simple',
+                'formatterParams' => array(
+                    'format' => '%timestamp%: %message%',
+                )
+            )
+        );
+        $message = 'tottakai';
+
+        $resource = new Zend_Application_Resource_Log($options);
+        $resource->setBootstrap($this->bootstrap);
+        $log = $resource->init();
+
+        $this->assertType('Zend_Log', $log);
+
+        $log->log($message, Zend_Log::INFO);
+        rewind($stream);
+        $contents = stream_get_contents($stream);
+
+        $this->assertStringEndsWith($message, $contents);
+        $this->assertRegexp('/\d\d:\d\d:\d\d/', $contents);
+    }
 }
 
 if (PHPUnit_MAIN_METHOD == 'Zend_Application_Resource_LogTest::main') {
     Zend_Application_Resource_LogTest::main();
-}
+}