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

Bug: nested arrays cause array to string conversion in Subset #1252

Closed
Danny-Smart opened this issue May 2, 2023 · 1 comment · Fixed by #1253
Closed

Bug: nested arrays cause array to string conversion in Subset #1252

Danny-Smart opened this issue May 2, 2023 · 1 comment · Fixed by #1253
Assignees
Labels
Bug An error or unexpected behavior.
Milestone

Comments

@Danny-Smart
Copy link
Contributor

If an expectation fails a count check, Mockery converts argument matchers into strings in order to display the expectation in the assertion failure message. When this is done to the Subset matcher when using a nested subset of arrays, casting to a string causes an "Array to string conversion" error

public function testSubsetError()
{
  $expected = [
    "foo" => [
      "bar" => "baz"
    ]
  ];

  $mock = \Mockery::mock(\Exception::class);
  $mock->shouldReceive("getMessage")->with(\Mockery::subset($expected))->once();
}

Results in :

There was 1 error:

1) tests\ExampleTest::testSubsetError()
Array to string conversion

/project/path/mockery/library/Mockery/Matcher/Subset.php:87

@ghostwriter ghostwriter added the Bug An error or unexpected behavior. label May 3, 2023
@ghostwriter
Copy link
Member

Resolved via #1253

@ghostwriter ghostwriter self-assigned this May 4, 2023
@ghostwriter ghostwriter added this to the 1.6.0 milestone May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An error or unexpected behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants