/** * asserts that the User is being passed to the Session by reference * by making changes to the behavior of the User after it is injected * into the Session * * @param string $methodName * @param string $expectedValue * * @dataProvider providerTestThatUserPropertyIsPassedByReference */ public function testThatUserPropertyIsPassedByReference($methodName, $expectedValue) { /* * create a mock User */ $user = $this->getMockBuilder('Acl\\Entity\\User')->getMock(); /* * instatiate the Session and inject the mock User */ $session = new Session(); $session->setUser($user); /* * change the behavior of the original mock User */ $user->expects($this->once())->method($methodName)->will($this->returnValue($expectedValue)); $actualValue = $session->getUser()->{$methodName}(); $errorMessage = sprintf("call to User::%s on user injected into Session is not consistent with the test value ofg injected", $methodName); $this->assertEquals($expectedValue, $actualValue, $errorMessage); }
/** *NEVER USED BY DoctrineSessionStorage * @param Session $session * * @return $this */ public function addSession(Session $session) { $this->sessions[] = $session; $session->setUser($this); return $this; }
/** * * get dependencies configuration for DependentObjectTrait */ protected function getDependenciesConfig() { return array(array('name' => 'Doctrine\\ORM\\EntityManager', 'object' => $this->entityManager), array('name' => 'Zend\\Authentication\\Storage\\StorageInterface', 'object' => $this->container), array('name' => Session::getEntityClass(), 'object' => $this->sessionPrototype)); }