Skip to content
This repository has been archived by the owner on May 1, 2019. It is now read-only.

Commit

Permalink
Merge pull request #464 from localheinz/fix/user-controller
Browse files Browse the repository at this point in the history
Fix: Integration test for User controller fails because of lack of mocking
  • Loading branch information
Ocramius committed Mar 5, 2015
2 parents 91eb7f3 + 3a90f98 commit bb778f3
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ZfModuleTest\Integration\Controller;

use ApplicationTest\Integration\Util\Bootstrap;
use Zend\Http;
use Zend\Paginator;
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
use ZfModule\Controller;
Expand All @@ -19,6 +20,8 @@ protected function setUp()

public function testUserPageCanBeAccessed()
{
$userName = 'gianarb';

$moduleMapper = $this->getMockBuilder(Mapper\Module::class)->getMock();

$moduleMapper
Expand All @@ -27,13 +30,20 @@ public function testUserPageCanBeAccessed()
->with(
$this->equalTo(1),
$this->equalTo(10),
$this->equalTo('gianarb'),
$this->equalTo($userName),
$this->equalTo('created_at'),
$this->equalTo('DESC')
)
->willReturn(new Paginator\Paginator(new Paginator\Adapter\Null()))
;

$moduleMapper
->expects($this->any())
->method('findAll')
->with($this->anything())
->willReturn([])
;

$this->getApplicationServiceLocator()
->setAllowOverride(true)
->setService(
Expand All @@ -42,9 +52,15 @@ public function testUserPageCanBeAccessed()
)
;

$this->dispatch('/user/gianarb');
$url = sprintf(
'/user/%s',
$userName
);

$this->dispatch($url);

$this->assertControllerName(Controller\UserController::class);
$this->assertActionName('modulesForUser');
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);
}
}

0 comments on commit bb778f3

Please sign in to comment.