This repository has been archived by the owner on Feb 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/develop' into develop
- Loading branch information
Showing
3 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} |