PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 31, 2022

[FIXED] Api-platform test Client::getResponse() is marked as @internal, what should I use instead?

 January 31, 2022     api-platform.com, php, symfony     No comments   

Issue

I have a test case in Api-Platform where I am checking that when I do filtering on a collection it gets me the correct data.

Therefore if my response is:

{
  "hydra:member": [
       {
          "test": "123"
       },
       {
          "test": "123"
       }
  ]
}

I want to assert that every "test" returned is "123".

The way I am doing it is:

        foreach ($client->getResponse()->toArray()['hydra:member'] as $member) {
            self::assertEquals($member['test'], "123");
        }

This works well but I see that the method getResponse is marked as @internal which means it should not be used outside the library. Is there something else I can use?


Solution

There is a Client::request() method that returns an ResponseInterface, defined here.

public function request(string $method, string $url, array $options = []): ResponseInterface

Why don't you use that response directly?



Answered By - yivi
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing