Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add a bunch of traits to ZF2 #2927

Closed
wants to merge 6 commits into from

7 participants

@Mezzle

As requested @

protecinnovations/zf2-traits#1

This is the initial commit to start getting traits into ZF2.

We need to move our tests over - which are currently using Mockery.

library/Zend/ServiceManager/ServiceManagerAwareTrait.php
((9 lines not shown))
+ */
+
+namespace Zend\ServiceManager;
+
+use Zend\ServiceManager\ServiceManager;
+
+/**
+ * @category Zend
+ * @package Zend_ServiceManager
+ */
+trait ServiceManagerAwareTrait
+{
+ /**
+ * @var \Zend\ServiceManager\ServiceManager
+ */
+ protected $service_manager = null;
@EvanDotPro Collaborator

Camel case please. Also, the var docblock can just be ServiceManager since there's a use statement.

@Mezzle
Mezzle added a note

Personally, I prefer having the full path in the docblock - then I don't have to go to the top of a file to find which class I'm actually using, lose my place where I was editing... etc etc...

But as I said in IRC:

* Mez awaits the inevitable "but our coding standards don't match!"
< EvanDotPro> Mez: Mez lol
< EvanDotPro> just left a comment :-p
@weierophinney Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@bakura10 bakura10 commented on the diff
library/Zend/EventManager/EventManagerAwareTrait.php
((4 lines not shown))
+ *
+ * @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_EventManager
+ */
+
+namespace Zend\EventManager;
+
+use Zend\EventManager\EventManagerInterface;
+
+/**
+ * @category Zend
+ * @package Zend_EventManager
+ */
+trait EventManagerAwareTrait
@bakura10
bakura10 added a note

This one does not already exists ? The ProvidesEvent trait ?

@Mezzle
Mezzle added a note

Sort of...

I've just done a basic copy over of our stuff - the main reason we didn't use ProvidesEvent traits is due to the fact that ProvidesEvent is not neccesarily correct. It may just need to know about the Event Manager (for example, for adding listeners). So therefore, EventManagerAwareTrait is more technically correct (although the code should probably be bought in line with ProvidesEvent)

@bakura10
bakura10 added a note

Ok. Anyway, we should agree on a naming too for traits. I like the "Provides" something naming.

@Mezzle
Mezzle added a note

Our thinking was that it's easy just to s/Interface/Trait/ and that it's not really "Providing" anything - the trait just makes implements the Awareness....

So these traits make things that are aware of things actually aware of them...

s/Trait/Skynet/

@weierophinney Owner

@Mezzle The point is that ProvidesEvents already exists, and does exactly what this one does. One should use the other, and that way they can be synonyms/substitutions for each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Slamdunk

Please can you provide tests, and test skips when testing on php < 5.4 ?

@Mezzle

Slamdunk - please see initial comment - we still need to provide tests (hence WIP) :) Our old tests ultilise Mockery - so @alexdenvir is currently rewriting them :)

@Mezzle Mezzle referenced this pull request in protecinnovations/zf2-traits
Closed

Contribute to ZF2 #1

@Slamdunk

You can use @requires before test class declaration, so you won't need it in every test :)

@Mezzle

Slamdunk - unfortunately - we tried that and it didn't work (it tried to load the object)

@Slamdunk

I see you are using a lot of assets: why don't you use getObjectForTrait (http://sebastian-bergmann.de/archives/906-Testing-Traits.html) ?

@Mezzle Mezzle closed this
@Mezzle Mezzle reopened this
Mezzle and others added some commits
@Mezzle Mezzle Add a bunch of traits to ZF2
As requested @

protecinnovations/zf2-traits#1

This is the initial commit to start getting traits into ZF2.

We need to move our tests over - which are currently using Mockery.
331151c
@alexdenvir alexdenvir Improve coding standards on new traits, add tests c568239
@Mezzle Mezzle Fix Minor problems with tests b0e0b89
library/Zend/I18n/Translator/TranslatorAwareTrait.php
((41 lines not shown))
+ * @param string $textDomain
+ * @return mixed
+ */
+ public function setTranslator(Translator $translator = null, $textDomain = null)
+ {
+ $this->translator = $translator;
+
+ if (!is_null($textDomain)) {
+ $this->setTranslatorTextDomain($textDomain);
+ }
+
+ return $this;
+ }
+
+ /**
+ * getTranslator
@Ocramius Collaborator

Those comments are quite useless... Could you fix them with real text (or strip them?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...ry/Zend/EventManager/SharedEventManagerAwareTrait.php
@@ -0,0 +1,60 @@
@weierophinney Owner

I'm not 100% convinced we need this one; the only place you'd really need it is if you were creating a custom EventManagerInterface implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
library/Zend/ServiceManager/ServiceManagerAwareTrait.php
@@ -0,0 +1,38 @@
@weierophinney Owner

Definitely should not have this one; we're promoting ServiceLocatorAwareInterface as the only interface you should utilize inside your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weierophinney

This is looking great -- with the few changes suggested, I'll be ready to merge.

@alexdenvir

@weierophinney I've removed the two traits you were unsure of. Did you also want me to make changes to EventManagerAwareTrait/ProvidesEvents like suggested in the above discussion as well?

@weierophinney
@alexdenvir

@weierophinney Done :) EventManagerAwareTrait now uses ProvidesEvents

@weierophinney

Merged to develop branch, for 2.1.0.

@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'feature/2927' into develop
Close #2927
fe909f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 19, 2012
  1. @Mezzle

    Add a bunch of traits to ZF2

    Mezzle authored
    As requested @
    
    protecinnovations/zf2-traits#1
    
    This is the initial commit to start getting traits into ZF2.
    
    We need to move our tests over - which are currently using Mockery.
  2. @alexdenvir @Mezzle

    Improve coding standards on new traits, add tests

    alexdenvir authored Mezzle committed
  3. @Mezzle

    Fix Minor problems with tests

    Mezzle authored
  4. @alexdenvir
Commits on Nov 20, 2012
  1. @alexdenvir
  2. @alexdenvir
This page is out of date. Refresh to see the latest.
View
39 library/Zend/Db/Adapter/AdapterAwareTrait.php
@@ -0,0 +1,39 @@
+<?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_Db
+ */
+
+namespace Zend\Db\Adapter;
+
+use Zend\Db\Adapter\Adapter;
+
+/**
+ * @category Zend
+ * @packcage Zend_Db
+ * @subpackage Adapter
+ */
+trait AdapterAwareTrait
+{
+ /**
+ * @var Adapter
+ */
+ protected $adapter = null;
+
+ /**
+ * Set db adapter
+ *
+ * @param Adapter $adapter
+ * @return mixed
+ */
+ public function setDbAdapter(Adapter $adapter)
+ {
+ $this->adapter = $adapter;
+
+ return $this;
+ }
+}
View
22 library/Zend/EventManager/EventManagerAwareTrait.php
@@ -0,0 +1,22 @@
+<?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_EventManager
+ */
+
+namespace Zend\EventManager;
+
+use \Zend\EventManager\ProvidesEvents;
+
+/**
+ * @category Zend
+ * @package Zend_EventManager
+ */
+trait EventManagerAwareTrait
@bakura10
bakura10 added a note

This one does not already exists ? The ProvidesEvent trait ?

@Mezzle
Mezzle added a note

Sort of...

I've just done a basic copy over of our stuff - the main reason we didn't use ProvidesEvent traits is due to the fact that ProvidesEvent is not neccesarily correct. It may just need to know about the Event Manager (for example, for adding listeners). So therefore, EventManagerAwareTrait is more technically correct (although the code should probably be bought in line with ProvidesEvent)

@bakura10
bakura10 added a note

Ok. Anyway, we should agree on a naming too for traits. I like the "Provides" something naming.

@Mezzle
Mezzle added a note

Our thinking was that it's easy just to s/Interface/Trait/ and that it's not really "Providing" anything - the trait just makes implements the Awareness....

So these traits make things that are aware of things actually aware of them...

s/Trait/Skynet/

@weierophinney Owner

@Mezzle The point is that ProvidesEvents already exists, and does exactly what this one does. One should use the other, and that way they can be synonyms/substitutions for each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+{
+ use ProvidesEvents;
+}
View
38 library/Zend/Form/FormFactoryAwareTrait.php
@@ -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_Form
+ */
+
+namespace Zend\Form;
+
+use \Zend\Form\Factory;
+
+/**
+ * @catagory Zend
+ * @package Zend_Form
+ */
+trait FormFactoryAwareTrait
+{
+ /**
+ * @var Factory
+ */
+ protected $factory = null;
+
+ /**
+ * Compose a form factory into the object
+ *
+ * @param Factory $factory
+ * @return mixed
+ */
+ public function setFormFactory(Factory $factory)
+ {
+ $this->factory = $factory;
+
+ return $this;
+ }
+}
View
120 library/Zend/I18n/Translator/TranslatorAwareTrait.php
@@ -0,0 +1,120 @@
+<?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_I18n
+ */
+
+namespace Zend\I18n\Translator;
+
+use Zend\I18n\Translator\Translator;
+
+/**
+ * @category Zend
+ * @package Zend_I18n
+ * @subpackage Translator
+ */
+trait TranslatorAwareTrait
+{
+ /**
+ * @var Translator
+ */
+ protected $translator = null;
+
+ /**
+ * @var bool
+ */
+ protected $translatorEnabled = true;
+
+ /**
+ * @var string
+ */
+ protected $translatorTextDomain = 'default';
+
+ /**
+ * Sets translator to use in helper
+ *
+ * @param Translator $translator
+ * @param string $textDomain
+ * @return mixed
+ */
+ public function setTranslator(Translator $translator = null, $textDomain = null)
+ {
+ $this->translator = $translator;
+
+ if (!is_null($textDomain)) {
+ $this->setTranslatorTextDomain($textDomain);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns translator used in object
+ *
+ * @return Translator
+ */
+ public function getTranslator()
+ {
+ return $this->translator;
+ }
+
+ /**
+ * Checks if the object has a translator
+ *
+ * @return bool
+ */
+ public function hasTranslator()
+ {
+ return !is_null($this->translator);
+ }
+
+ /**
+ * Sets whether translator is enabled and should be used
+ *
+ * @param bool $enabled
+ * @return mixed
+ */
+ public function setTranslatorEnabled($enabled = true)
+ {
+ $this->translatorEnabled = $enabled;
+
+ return $this;
+ }
+
+ /**
+ * Returns whether translator is enabled and should be used
+ *
+ * @return bool
+ */
+ public function isTranslatorEnabled()
+ {
+ return $this->translatorEnabled;
+ }
+
+ /**
+ * Set translation text domain
+ *
+ * @param string $textDomain
+ * @return mixed
+ */
+ public function setTranslatorTextDomain($textDomain = 'default')
+ {
+ $this->translatorTextDomain = $textDomain;
+
+ return $this;
+ }
+
+ /**
+ * Return the translation text domain
+ *
+ * @return string
+ */
+ public function getTranslatorTextDomain()
+ {
+ return $this->translatorTextDomain;
+ }
+}
View
48 library/Zend/InputFilter/InputFilterAwareTrait.php
@@ -0,0 +1,48 @@
+<?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_InputFilter
+ */
+
+namespace Zend\InputFilter;
+
+use Zend\InputFilter\InputFilterInterface;
+
+/**
+ * @category Zend
+ * @package Zend_InputFilter
+ */
+trait InputFilterAwareTrait
+{
+ /**
+ * @var InputFilterInterface
+ */
+ protected $inputFilter = null;
+
+ /**
+ * Set input filter
+ *
+ * @param InputFilterInterface $inputFilter
+ * @return mixed
+ */
+ public function setInputFilter(InputFilterInterface $inputFilter)
+ {
+ $this->inputFilter = $inputFilter;
+
+ return $this;
+ }
+
+ /**
+ * Retrieve input filter
+ *
+ * @return InputFilterInterface
+ */
+ public function getInputFilter()
+ {
+ return $this->inputFilter;
+ }
+}
View
38 library/Zend/Log/LoggerAwareTrait.php
@@ -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;
+ }
+}
View
48 library/Zend/ServiceManager/ServiceLocatorAwareTrait.php
@@ -0,0 +1,48 @@
+<?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_ServiceManager
+ */
+
+namespace Zend\ServiceManager;
+
+use Zend\ServiceManager\ServiceLocatorInterface;
+
+/**
+ * @category Zend
+ * @package Zend_ServiceManager
+ */
+trait ServiceLocatorAwareTrait
+{
+ /**
+ * @var ServiceLocator
+ */
+ protected $serviceLocator = null;
+
+ /**
+ * Set service locator
+ *
+ * @param ServiceLocatorInterface $serviceLocator
+ * @return mixed
+ */
+ public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
+ {
+ $this->serviceLocator = $serviceLocator;
+
+ return $this;
+ }
+
+ /**
+ * Get service locator
+ *
+ * @return ServiceLocator
+ */
+ public function getServiceLocator()
+ {
+ return $this->serviceLocator;
+ }
+}
View
36 tests/ZendTest/Db/Adapter/AdapterAwareTraitTest.php
@@ -0,0 +1,36 @@
+<?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_Db
+ */
+
+namespace ZendTest\Db\Adapter;
+
+use \PHPUnit_Framework_TestCase as TestCase;
+use \Zend\Db\Adapter\Adapter;
+
+/**
+ * @requires PHP 5.4
+ */
+class AdapterAwareTraitTest extends TestCase
+{
+ public function testSetDbAdapter()
+ {
+ $object = $this->getObjectForTrait('\Zend\Db\Adapter\AdapterAwareTrait');
+
+ $this->assertAttributeEquals(null, 'adapter', $object);
+
+ $driver = $this->getMock('Zend\Db\Adapter\Driver\DriverInterface');
+ $platform = $this->getMock('Zend\Db\Adapter\Platform\PlatformInterface');
+
+ $adapter = new Adapter($driver, $platform);
+
+ $object->setDbAdapter($adapter);
+
+ $this->assertAttributeEquals($adapter, 'adapter', $object);
+ }
+}
View
46 tests/ZendTest/EventManager/EventManagerAwareTraitTest.php
@@ -0,0 +1,46 @@
+<?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_EventManager
+ */
+
+namespace ZendTest\EventManager;
+
+use \PHPUnit_Framework_TestCase as TestCase;
+use \Zend\EventManager\EventManager;
+
+/**
+ * @requires PHP 5.4
+ */
+class EventManagerAwareTraitTest extends TestCase
+{
+ public function testSetEventManager()
+ {
+ $object = $this->getObjectForTrait('\Zend\EventManager\EventManagerAwareTrait');
+
+ $this->assertAttributeEquals(null, 'events', $object);
+
+ $eventManager = new EventManager;
+
+ $object->setEventManager($eventManager);
+
+ $this->assertAttributeEquals($eventManager, 'events', $object);
+ }
+
+ public function testGetEventManager()
+ {
+ $object = $this->getObjectForTrait('\Zend\EventManager\EventManagerAwareTrait');
+
+ $this->assertInstanceOf('\Zend\EventManager\EventManagerInterface', $object->getEventManager());
+
+ $eventManager = new EventManager;
+
+ $object->setEventManager($eventManager);
+
+ $this->assertSame($eventManager, $object->getEventManager());
+ }
+}
View
33 tests/ZendTest/Form/FormFactoryAwareTraitTest.php
@@ -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_Form
+ */
+
+namespace ZendTest\Form;
+
+use \PHPUnit_Framework_TestCase as TestCase;
+use \Zend\Form\Factory;
+
+/**
+ * @requires PHP 5.4
+ */
+class FormFactoryAwareTraitTest extends TestCase
+{
+ public function testSetFormFactory()
+ {
+ $object = $this->getObjectForTrait('\Zend\Form\FormFactoryAwareTrait');
+
+ $this->assertAttributeEquals(null, 'factory', $object);
+
+ $factory = new Factory;
+
+ $object->setFormFactory($factory);
+
+ $this->assertAttributeEquals($factory, 'factory', $object);
+ }
+}
View
129 tests/ZendTest/I18n/Translator/TranslatorAwareTraitTest.php
@@ -0,0 +1,129 @@
+<?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_I18n
+ */
+
+namespace ZendTest\I18n\Translator;
+
+use \PHPUnit_Framework_TestCase as TestCase;
+use \Zend\I18n\Translator\Translator;
+
+/**
+ * @requires PHP 5.4
+ */
+class TranslatorAwareTraitTest extends TestCase
+{
+ public function testSetTranslator()
+ {
+ $object = $this->getObjectForTrait('\Zend\I18n\Translator\TranslatorAwareTrait');
+
+ $this->assertAttributeEquals(null, 'translator', $object);
+
+ $translator = new Translator;
+
+ $object->setTranslator($translator);
+
+ $this->assertAttributeEquals($translator, 'translator', $object);
+ }
+
+ public function testSetTranslatorAndTextDomain()
+ {
+ $object = $this->getObjectForTrait('\Zend\I18n\Translator\TranslatorAwareTrait');
+
+ $this->assertAttributeEquals(null, 'translator', $object);
+ $this->assertAttributeEquals('default', 'translatorTextDomain', $object);
+
+ $translator = new Translator;
+ $textDomain = 'domain';
+
+ $object->setTranslator($translator, $textDomain);
+
+ $this->assertAttributeEquals($translator, 'translator', $object);
+ $this->assertAttributeEquals($textDomain, 'translatorTextDomain', $object);
+ }
+
+ public function testGetTranslator()
+ {
+ $object = $this->getObjectForTrait('\Zend\I18n\Translator\TranslatorAwareTrait');
+
+ $this->assertNull($object->getTranslator());
+
+ $translator = new Translator;
+
+ $object->setTranslator($translator);
+
+ $this->assertEquals($translator, $object->getTranslator());
+ }
+
+ public function testHasTranslator()
+ {
+ $object = $this->getObjectForTrait('\Zend\I18n\Translator\TranslatorAwareTrait');
+
+ $this->assertFalse($object->hasTranslator());
+
+ $translator = new Translator;
+
+ $object->setTranslator($translator);
+
+ $this->assertTrue($object->hasTranslator());
+ }
+
+ public function testSetTranslatorEnabled()
+ {
+ $object = $this->getObjectForTrait('\Zend\I18n\Translator\TranslatorAwareTrait');
+
+ $this->assertAttributeEquals(true, 'translatorEnabled', $object);
+
+ $enabled = false;
+
+ $object->setTranslatorEnabled($enabled);
+
+ $this->assertAttributeEquals($enabled, 'translatorEnabled', $object);
+
+ $object->setTranslatorEnabled();
+
+ $this->assertAttributeEquals(true, 'translatorEnabled', $object);
+ }
+
+ public function testIsTranslatorEnabled()
+ {
+ $object = $this->getObjectForTrait('\Zend\I18n\Translator\TranslatorAwareTrait');
+
+ $this->assertTrue($object->isTranslatorEnabled());
+
+ $object->setTranslatorEnabled(false);
+
+ $this->assertFalse($object->isTranslatorEnabled());
+ }
+
+ public function testSetTranslatorTextDomain()
+ {
+ $object = $this->getObjectForTrait('\Zend\I18n\Translator\TranslatorAwareTrait');
+
+ $this->assertAttributeEquals('default', 'translatorTextDomain', $object);
+
+ $textDomain = 'domain';
+
+ $object->setTranslatorTextDomain($textDomain);
+
+ $this->assertAttributeEquals($textDomain, 'translatorTextDomain', $object);
+ }
+
+ public function testGetTranslatorTextDomain()
+ {
+ $object = $this->getObjectForTrait('\Zend\I18n\Translator\TranslatorAwareTrait');
+
+ $this->assertEquals('default', $object->getTranslatorTextDomain());
+
+ $textDomain = 'domain';
+
+ $object->setTranslatorTextDomain($textDomain);
+
+ $this->assertEquals($textDomain, $object->getTranslatorTextDomain());
+ }
+}
View
46 tests/ZendTest/InputFilter/InputFilterAwareTraitTest.php
@@ -0,0 +1,46 @@
+<?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_InputFilter
+ */
+
+namespace ZendTest\InputFilter;
+
+use \PHPUnit_Framework_TestCase as TestCase;
+use \Zend\InputFilter\InputFilter;
+
+/**
+ * @requires PHP 5.4
+ */
+class InputFilterAwareTraitTest extends TestCase
+{
+ public function testSetInputFilter()
+ {
+ $object = $this->getObjectForTrait('\Zend\InputFilter\InputFilterAwareTrait');
+
+ $this->assertAttributeEquals(null, 'inputFilter', $object);
+
+ $inputFilter = new InputFilter;
+
+ $object->setInputFilter($inputFilter);
+
+ $this->assertAttributeEquals($inputFilter, 'inputFilter', $object);
+ }
+
+ public function testGetInputFilter()
+ {
+ $object = $this->getObjectForTrait('\Zend\InputFilter\InputFilterAwareTrait');
+
+ $this->assertNull($object->getInputFilter());
+
+ $inputFilter = new InputFilter;
+
+ $object->setInputFilter($inputFilter);
+
+ $this->assertEquals($inputFilter, $object->getInputFilter());
+ }
+}
View
33 tests/ZendTest/Log/LoggerAwareTraitTest.php
@@ -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);
+ }
+}
View
46 tests/ZendTest/ServiceManager/ServiceLocatorAwareTraitTest.php
@@ -0,0 +1,46 @@
+<?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_ServiceManager
+ */
+
+namespace ZendTest\ServiceManager;
+
+use \PHPUnit_Framework_TestCase as TestCase;
+use \Zend\ServiceManager\ServiceManager;
+
+/**
+ * @requires PHP 5.4
+ */
+class ServiceLocatorAwareTraitTest extends TestCase
+{
+ public function testSetServiceLocator()
+ {
+ $object = $this->getObjectForTrait('\Zend\ServiceManager\ServiceLocatorAwareTrait');
+
+ $this->assertAttributeEquals(null, 'serviceLocator', $object);
+
+ $serviceLocator = new ServiceManager;
+
+ $object->setServiceLocator($serviceLocator);
+
+ $this->assertAttributeEquals($serviceLocator, 'serviceLocator', $object);
+ }
+
+ public function testGetServiceLocator()
+ {
+ $object = $this->getObjectForTrait('\Zend\ServiceManager\ServiceLocatorAwareTrait');
+
+ $this->assertNull($object->getServiceLocator());
+
+ $serviceLocator = new ServiceManager;
+
+ $object->setServiceLocator($serviceLocator);
+
+ $this->assertEquals($serviceLocator, $object->getServiceLocator());
+ }
+}
Something went wrong with that request. Please try again.