Skip to content

Commit

Permalink
Merge pull request #377 from FriendsOfCake/josegonzalez-patch-1
Browse files Browse the repository at this point in the history
Fix issue where tested table does not return a mocked BehaviorRegistry
  • Loading branch information
ADmad committed Dec 26, 2015
2 parents a58a672 + 8f03f68 commit 140f696
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .coveralls.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ before_script:

script:
- sh -c "if [ '$COVERALLS' = '1' ]; then phpunit --stderr --coverage-clover build/logs/clover.xml; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then php vendor/bin/coveralls -c .coveralls.yml -v; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then php vendor/bin/coveralls -v; fi"
- sh -c "if [ '$DEFAULT' = '1' ]; then phpunit --stderr; fi"
- sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -n -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP --ignore=vendor --ignore=docs . ; fi"

Expand Down
17 changes: 13 additions & 4 deletions tests/TestCase/Listener/SearchListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,24 @@ public function testInjectSearch()
$eventManager = new \Cake\Event\EventManager();
$controller = new \Cake\Controller\Controller($request, $response, 'Search', $eventManager);

$behaviorRegistryMock = $this->getMockBuilder('\Cake\ORM\BehaviorRegistry')
->setMockClassName('BehaviorRegistry')
->setMethods(['hasMethod'])
->getMock();
$behaviorRegistryMock->expects($this->once())
->method('hasMethod')
->will($this->returnValue(true));

$tableMock = $this->getMockBuilder('\Cake\ORM\Table')
->setMockClassName('SearchTables')
->setMethods(['filterParams'])
->setMethods(['filterParams', 'behaviors'])
->getMock();
$tableMock->expects($this->once())
->method('filterParams')
->will($this->returnCallback(function () use ($params) {
return $params;
}));
->will($this->returnValue($params));
$tableMock->expects($this->once())
->method('behaviors')
->will($this->returnValue($behaviorRegistryMock));

\Cake\ORM\TableRegistry::set('Search', $tableMock);

Expand Down

0 comments on commit 140f696

Please sign in to comment.