Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Update phpunit to 8.5 #457

Merged
merged 3 commits into from
Jan 18, 2022
Merged

Conversation

glensc
Copy link
Contributor

@glensc glensc commented Jan 17, 2022

No description provided.

@glensc glensc self-assigned this Jan 17, 2022
@glensc
Copy link
Contributor Author

glensc commented Jan 17, 2022

I don't understand how to fix this error:


Expectation failed for method name is "insert" when invoked 8 time(s)
Parameter count for invocation MongoCollection::insert(Array (...), Array (...)) is too low.

src/Saver/MongoSaver.php:45
tests/Saver/MongoTest.php:31

I've tried as described in docs:

@glensc glensc mentioned this pull request Jan 17, 2022
@glensc glensc added this to the 0.20.1 milestone Jan 17, 2022
@luzip665
Copy link
Contributor

luzip665 commented Jan 18, 2022

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.

@glensc
Copy link
Contributor Author

glensc commented Jan 18, 2022

you have omitted $this->equalTo calls to items, but I think I've tried too. I'll try again

@luzip665
Copy link
Contributor

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.

@glensc
Copy link
Contributor Author

glensc commented Jan 18, 2022

Ok, I figured it out: 9eaa7d8!

@luzip665
Copy link
Contributor

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.

@glensc
Copy link
Contributor Author

glensc commented Jan 18, 2022

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.

#358

->withConsecutive($this->equalTo($data));
->withConsecutive(...array_map(function () {
return [
$this->callback(function ($data) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't understand how $this->callback is able to obtain $data, but it works correctly

@glensc glensc changed the title Update phpunit to 8.5 Chore: Update phpunit to 8.5 Jan 18, 2022
@glensc glensc marked this pull request as ready for review January 18, 2022 09:36
@glensc glensc merged commit 043c14c into perftools:0.20.x Jan 18, 2022
@glensc glensc deleted the phpunit-update branch January 18, 2022 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants