Skip to content

Commit

Permalink
Fix controller tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielss89 committed May 5, 2016
1 parent a89e622 commit c447f6e
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions tests/ZfcUserTest/Controller/UserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ public function testChangeEmailAction($status, $postRedirectGetReturn, $isValid,
* @depend testActionControllHasIdentity
*/
public function testSetterGetterServices(
$methode,
$method,
$useServiceLocator,
$servicePrototype,
$serviceName,
Expand All @@ -984,34 +984,21 @@ public function testSetterGetterServices(

if ($useServiceLocator) {
$serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface');
$formElementManager = $this->getMock('Zend\Form\FormElementManager');
# Forms now use the FormElementManager so we need mock accordingly
if ($servicePrototype instanceof Form) {
$serviceLocator->expects($this->once())
->method('get')
->with('FormElementManager')
->will($this->returnValue($formElementManager));
$formElementManager->expects($this->once())
->method('get')
->with($serviceName)
->will($this->returnValue($servicePrototype));
} else {
$serviceLocator->expects($this->once())
->method('get')
->with($serviceName)
->will($this->returnValue($servicePrototype));
}
$serviceLocator->expects($this->once())
->method('get')
->with($serviceName)
->will($this->returnValue($servicePrototype));
$controller->setServiceLocator($serviceLocator);
} else {
call_user_func(array($controller, 'set' . $methode), $servicePrototype);
call_user_func(array($controller, 'set' . $method), $servicePrototype);
}

$result = call_user_func(array($controller, 'get' . $methode));
$result = call_user_func(array($controller, 'get' . $method));
$this->assertInstanceOf(get_class($servicePrototype), $result);
$this->assertSame($servicePrototype, $result);

// we need two check for every case
$result = call_user_func(array($controller, 'get' . $methode));
$result = call_user_func(array($controller, 'get' . $method));
$this->assertInstanceOf(get_class($servicePrototype), $result);
$this->assertSame($servicePrototype, $result);
}
Expand Down Expand Up @@ -1107,7 +1094,7 @@ public function providerTestSetterGetterServices ()


return array(
// $methode, $useServiceLocator, $servicePrototype, $serviceName, $loginFormCallback
// $method, $useServiceLocator, $servicePrototype, $serviceName, $loginFormCallback
array('UserService', true, new UserService(), 'zfcuser_user_service' ),
array('UserService', false, new UserService(), null ),
array('RegisterForm', true, new Form(), 'zfcuser_register_form' ),
Expand Down

0 comments on commit c447f6e

Please sign in to comment.