Skip to content

Commit e02ab5b

Browse files
authored
Merge pull request #96 from UseMuffin/issue-95
Fix signature mismatch error.
2 parents a7d761b + 9bc8d00 commit e02ab5b

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/Datasource/Query.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Cake\Datasource\Exception\RecordNotFoundException;
88
use Cake\Datasource\QueryInterface;
99
use Cake\Datasource\QueryTrait;
10+
use Cake\Datasource\ResultSetInterface;
1011
use Cake\Utility\Hash;
1112
use InvalidArgumentException;
1213
use IteratorAggregate;
@@ -535,17 +536,19 @@ public function triggerBeforeFind()
535536
*/
536537
public function execute()
537538
{
538-
return $this->_execute();
539+
if ($this->clause('action') === self::ACTION_READ) {
540+
return $this->_execute();
541+
}
542+
543+
return $this->__resultSet = $this->_webservice->execute($this);
539544
}
540545

541546
/**
542547
* Executes this query and returns a traversable object containing the results
543548
*
544-
* @return bool|int|\Cake\Datasource\ResultSetInterface
545-
* @psalm-suppress TraitMethodSignatureMismatch
546-
* @psalm-suppress ImplementedReturnTypeMismatch
549+
* @return \Cake\Datasource\ResultSetInterface
547550
*/
548-
protected function _execute()
551+
protected function _execute(): ResultSetInterface
549552
{
550553
$this->triggerBeforeFind();
551554
if ($this->__resultSet) {

tests/TestCase/QueryTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ public function testExecuteTwice()
167167
{
168168
$mockWebservice = $this
169169
->getMockBuilder('\TestApp\Webservice\StaticWebservice')
170-
->setMethods([
170+
->onlyMethods([
171171
'execute',
172172
])
173173
->getMock();
174+
174175
$mockWebservice->expects($this->once())
175176
->method('execute')
176177
->will($this->returnValue(new ResultSet([
@@ -187,7 +188,10 @@ public function testExecuteTwice()
187188
'title' => 'Webservices',
188189
]),
189190
], 3)));
190-
$this->query->setWebservice($mockWebservice);
191+
192+
$this->query
193+
->setWebservice($mockWebservice)
194+
->action(Query::ACTION_READ);
191195

192196
$this->query->execute();
193197

0 commit comments

Comments
 (0)