*/ class AuthorizeAwareServiceInitializerTest extends PHPUnit_Framework_TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $authorize; /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $locator; /** * @var \BjyAuthorize\Service\AuthorizeAwareServiceInitializer */ protected $initializer; /** * {@inheritDoc} */ public function setUp() { $this->authorize = $this->getMock('BjyAuthorize\\Service\\Authorize', array(), array(), '', false); $this->locator = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface'); $this->initializer = new AuthorizeAwareServiceInitializer(); $this->locator->expects($this->any())->method('get')->will($this->returnValue($this->authorize)); } /** * @covers \BjyAuthorize\Service\AuthorizeAwareServiceInitializer::initialize */ public function testInitializeWithAuthorizeAwareObject() { $awareObject = $this->getMock('BjyAuthorize\\Service\\AuthorizeAwareInterface'); $awareObject->expects($this->once())->method('setAuthorizeService')->with($this->authorize); $this->initializer->initialize($awareObject, $this->locator); } /** * @covers \BjyAuthorize\Service\AuthorizeAwareServiceInitializer::initialize */ public function testInitializeWithSimpleObject() { $awareObject = $this->getMock('stdClass', array('setAuthorizeService')); $awareObject->expects($this->never())->method('setAuthorizeService'); $this->initializer->initialize($awareObject, $this->locator); } }