Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MichaelGooden/6306420 to your computer and use it in GitHub Desktop.
Save MichaelGooden/6306420 to your computer and use it in GitHub Desktop.
<?php
/**
*
*/
public function myTestWithNumber()
{
// Mock Service:
$mockService = $this->getMockBuilder('myService')
->disableOriginalConstructor()
->getMock();
$mockService->expects($this->atLeastOnce())
->method('getUserById')
->will($this->returnValue(false));
$controller = new Controller($mockService, array());
//$result = $controller->indexAction();
$request = new \Zend\Http\PhpEnvironment\Request();
$request->setRequestUri(/*......*/);
// whatever else you want to simulate
$routeMatch = new \Zend\Mvc\Router\RouteMatch(array('id' => 6));
$routeMatch->setMatchedRouteName('my/route/i/have');
$controller->getEvent()->setRouteMatch($routeMatch);
$result = $controller->dispatch($request);
// Assertions:
$this->assertInstanceOf(
'Zend\View\Model\ViewModel',
$result,
'index action with no ID did not return ViewModel'
);
$this->assertInstanceOf('My\Users\Class', $result->user, 'error here');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment