Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/2927' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/LoggerAwareTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Log
*/

namespace Zend\Log;

use Zend\Log\LoggerInterface;

/**
* @category Zend
* @package Zend_Log
*/
trait LoggerAwareTrait
{
/**
* @var LoggerInterface
*/
protected $logger = null;

/**
* Set logger object
*
* @param LoggerInterface $logger
* @return mixed
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;

return $this;
}
}
33 changes: 33 additions & 0 deletions test/LoggerAwareTraitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Log
*/

namespace ZendTest\Log;

use \PHPUnit_Framework_TestCase as TestCase;
use \Zend\Log\Logger;

/**
* @requires PHP 5.4
*/
class LoggerAwareTraitTest extends TestCase
{
public function testSetLogger()
{
$object = $this->getObjectForTrait('\Zend\Log\LoggerAwareTrait');

$this->assertAttributeEquals(null, 'logger', $object);

$logger = new Logger;

$object->setLogger($logger);

$this->assertAttributeEquals($logger, 'logger', $object);
}
}

0 comments on commit 5576455

Please sign in to comment.