Closed glensc closed 2 years ago
I have no glue where is the difference in the phpunit versions, but when I use
$test_data = array();
foreach ($data as $a) {
$test_data[] = array($a, ['w' => 0]);
}
$collection
->expects($this->exactly(count($data)))
->method('insert')
->withConsecutive(...$test_data);
the error is replaced by
Expectation failed for method name is "insert" when invoked 8 time(s)
Parameter 0 for invocation #0 MongoCollection::insert(Array (...), Array (...)) does not match expected value.
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
- '_id' => 'aaaaaaaaaaaaaaaaaaaaaaaa'
+ '_id' => MongoId Object (...)
'meta' => Array (
'url' => '/tasks?page=3'
'simple_url' => '/tasks'
@@ @@
'get' => Array (...)
'env' => Array ()
'SERVER' => Array (...)
- 'request_ts_micro' => Array (...)
+ 'request_ts_micro' => MongoDate Object (...)
+ 'request_ts' => MongoDate Object (...)
+ 'request_date' => '2013-01-21'
)
'profile' => Array (...)
)
which seems expectable to me.
The important difference in the call are the ...
in withConsecutive
.
May be it help.
you have omitted $this->equalTo
calls to items, but I think I've tried too. I'll try again
As far as I see in vendor/phpunit/phpunit/src/Framework/MockObject/Rule/ConsecutiveParameters.php
the constraint is set to IsEqual, when there is no constraint.
Ok, I figured it out: 9eaa7d89!
Just for interest: Would it be possible to check the insert via the MongoSearcher after insertion? For checking if the data is really inserted and not only the insert-method is called.
Just for interest: Would it be possible to check the insert via the MongoSearcher after insertion? For checking if the data is really inserted and not only the insert-method is called.
I don't understand how to fix this error:
I've tried as described in docs: