- Issue created by @nicxvan
- First commit to issue fork.
- Merge request !93Issue #3447490: Fix default return values for ConnectionStub::execute() β (Merged) created by murz
- Status changed to Needs review
5 months ago 9:39am 21 June 2024 - π¦π²Armenia murz Yerevan, Armenia
Yeah, by default the ConnectionStub always returns the array, that is wrong.
I fixed this by returning a mock of PDOStatement for select and integers for insert and delete actions.
See the MR.Please test it and report if it works well for you.
Actually, to test your code, you should manually make a stub of the execute response, using this approach:
$database = TestHelpers::service('database'); $yourExpectedResult = [1, 2, 3]; $executeMock = $this->createMock(\PDOStatement::class); $executeMock->method('fetchAll')->willReturn($yourExpectedResult); $database->stubSetExecuteHandler(function () use ($executeMock) { return $executeMock; }, 'select'); $result = $database->select('table1')->execute()->fetchAll(); $this->assertEquals($yourExpectedResult, $result);
- π¦π²Armenia murz Yerevan, Armenia
I tested and merged this. If it will not help to you, please reopen the issue.
- Status changed to Fixed
5 months ago 1:09pm 21 June 2024 - πΊπΈUnited States nicxvan
I'm no longer getting this error, I added some more detail in π What is the proper way to inject the cache backend? Needs review with what I am experiencing now.
Automatically closed - issue fixed for 2 weeks with no activity.