Open Journal Systems  3.3.0
Zf2LogAdapterTest.php
1 <?php
2 
3 namespace Guzzle\Tests\Log;
4 
6 use Zend\Log\Logger;
7 use Zend\Log\Writer\Stream;
8 
13 {
15  protected $adapter;
16 
18  protected $log;
19 
21  protected $stream;
22 
23  protected function setUp()
24  {
25  $this->stream = fopen('php://temp', 'r+');
26  $this->log = new Logger();
27  $this->log->addWriter(new Stream($this->stream));
28  $this->adapter = new Zf2LogAdapter($this->log);
29 
30  }
31 
33  {
34  // Test without a priority
35  $this->adapter->log('Zend_Test!', \LOG_NOTICE);
36  rewind($this->stream);
37  $contents = stream_get_contents($this->stream);
38  $this->assertEquals(1, substr_count($contents, 'Zend_Test!'));
39 
40  // Test with a priority
41  $this->adapter->log('Zend_Test!', \LOG_ALERT);
42  rewind($this->stream);
43  $contents = stream_get_contents($this->stream);
44  $this->assertEquals(2, substr_count($contents, 'Zend_Test!'));
45  }
46 
47  public function testExposesAdaptedLogObject()
48  {
49  $this->assertEquals($this->log, $this->adapter->getLogObject());
50  }
51 }
Guzzle\Tests\Log\Zf2LogAdapterTest\setUp
setUp()
Definition: Zf2LogAdapterTest.php:32
Guzzle\Tests\GuzzleTestCase
Definition: GuzzleTestCase.php:22
Guzzle\Tests\Log\Zf2LogAdapterTest\testExposesAdaptedLogObject
testExposesAdaptedLogObject()
Definition: Zf2LogAdapterTest.php:56
Guzzle\Tests\Log\Zf2LogAdapterTest\$log
$log
Definition: Zf2LogAdapterTest.php:24
Guzzle\Tests\Log
Definition: ArrayLogAdapterTest.php:3
Guzzle\Tests\Log\Zf2LogAdapterTest
Definition: Zf2LogAdapterTest.php:12
Guzzle\Tests\Log\Zf2LogAdapterTest\testLogsMessagesToAdaptedObject
testLogsMessagesToAdaptedObject()
Definition: Zf2LogAdapterTest.php:41
Guzzle\Tests\Log\Zf2LogAdapterTest\$stream
$stream
Definition: Zf2LogAdapterTest.php:30
Guzzle\Tests\Log\Zf2LogAdapterTest\$adapter
$adapter
Definition: Zf2LogAdapterTest.php:18
Guzzle\Log\Zf2LogAdapter
Definition: Zf2LogAdapter.php:10