From a5b4b8d6770cf6de22a5c9c3313fa8594c71360b Mon Sep 17 00:00:00 2001 From: Alex Denvir Date: Fri, 9 Nov 2012 15:33:33 +0000 Subject: [PATCH 1/2] Improve coding standards on new traits, add tests --- src/LoggerAwareTrait.php | 6 ++--- test/LoggerAwareTraitTest.php | 33 +++++++++++++++++++++++++ test/TestAsset/MockLoggerAwareTrait.php | 19 ++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 test/LoggerAwareTraitTest.php create mode 100644 test/TestAsset/MockLoggerAwareTrait.php diff --git a/src/LoggerAwareTrait.php b/src/LoggerAwareTrait.php index 02f538df..b610682d 100644 --- a/src/LoggerAwareTrait.php +++ b/src/LoggerAwareTrait.php @@ -19,15 +19,15 @@ trait LoggerAwareTrait { /** - * @var \Zend\Log\LoggerInterface + * @var LoggerInterface */ protected $logger = null; /** * setLogger * - * @param \Zend\Log\LoggerInterface $logger - * @return + * @param LoggerInterface $logger + * @return mixed */ public function setLogger(LoggerInterface $logger) { diff --git a/test/LoggerAwareTraitTest.php b/test/LoggerAwareTraitTest.php new file mode 100644 index 00000000..e981e139 --- /dev/null +++ b/test/LoggerAwareTraitTest.php @@ -0,0 +1,33 @@ +assertAttributeEquals(null, 'logger', $object); + + $logger = new Logger; + + $object->setLogger($logger); + + $this->assertAttributeEquals($logger, 'logger', $object); + } +} diff --git a/test/TestAsset/MockLoggerAwareTrait.php b/test/TestAsset/MockLoggerAwareTrait.php new file mode 100644 index 00000000..4bbac129 --- /dev/null +++ b/test/TestAsset/MockLoggerAwareTrait.php @@ -0,0 +1,19 @@ + Date: Mon, 19 Nov 2012 17:30:14 +0000 Subject: [PATCH 2/2] Improve function comment quality, clean up tests a little --- src/LoggerAwareTrait.php | 2 +- test/LoggerAwareTraitTest.php | 8 ++++---- test/TestAsset/MockLoggerAwareTrait.php | 19 ------------------- 3 files changed, 5 insertions(+), 24 deletions(-) delete mode 100644 test/TestAsset/MockLoggerAwareTrait.php diff --git a/src/LoggerAwareTrait.php b/src/LoggerAwareTrait.php index b610682d..33cbfe43 100644 --- a/src/LoggerAwareTrait.php +++ b/src/LoggerAwareTrait.php @@ -24,7 +24,7 @@ trait LoggerAwareTrait protected $logger = null; /** - * setLogger + * Set logger object * * @param LoggerInterface $logger * @return mixed diff --git a/test/LoggerAwareTraitTest.php b/test/LoggerAwareTraitTest.php index e981e139..55e9ad78 100644 --- a/test/LoggerAwareTraitTest.php +++ b/test/LoggerAwareTraitTest.php @@ -13,14 +13,14 @@ use \PHPUnit_Framework_TestCase as TestCase; use \Zend\Log\Logger; +/** + * @requires PHP 5.4 + */ class LoggerAwareTraitTest extends TestCase { - /** - * @requires PHP 5.4 - */ public function testSetLogger() { - $object = new TestAsset\MockLoggerAwareTrait; + $object = $this->getObjectForTrait('\Zend\Log\LoggerAwareTrait'); $this->assertAttributeEquals(null, 'logger', $object); diff --git a/test/TestAsset/MockLoggerAwareTrait.php b/test/TestAsset/MockLoggerAwareTrait.php deleted file mode 100644 index 4bbac129..00000000 --- a/test/TestAsset/MockLoggerAwareTrait.php +++ /dev/null @@ -1,19 +0,0 @@ -