Laravel exception when I try to create a test for a link with PestPHP

66 views Asked by At

I have that kind of problem when I try to create a test for a Link:

Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames

$response = $this->get('/odata/dim_regions');

Error details:

Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames

  at vendor\symfony\http-foundation\Request.php:501
    497▕      * are most of the time sub-requests of the main one.
    498▕      */
    499▕     public function __clone()
    500▕     {
  ➜ 501▕         $this->query = clone $this->query;
    502▕         $this->request = clone $this->request;
    503▕         $this->attributes = clone $this->attributes;
    504▕         $this->cookies = clone $this->cookies;
    505▕         $this->files = clone $this->files;

  1   vendor\symfony\http-foundation\Request.php:501
  2   vendor\symfony\http-foundation\Request.php:502

I'm using PestPHP.

Can anyone help me with this?

1

There are 1 answers

0
Vivick On

You're asking Request to clone its $request property inside the __clone method. That's infinite recursion.

You don't need to override it, or you can always write $this->request = $this; after every property.