Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHPUnit测试中容器的Symfony内存问题_Php_Phpunit_Php 7.2_Symfony 4.3 - Fatal编程技术网

PHPUnit测试中容器的Symfony内存问题

PHPUnit测试中容器的Symfony内存问题,php,phpunit,php-7.2,symfony-4.3,Php,Phpunit,Php 7.2,Symfony 4.3,我有以下测试。这导致PHP致命错误:内存不足(已分配704905216)(试图分配139802474386369字节)error 这里的$this->client->getContainer()似乎是问题的根源。但我不知道该怎么写。如何解决这个内存问题 public function testIndexWithCreateUser() { $printMock = $this->createMock(InternPrintApi::class); $

我有以下测试。这导致
PHP致命错误:内存不足(已分配704905216)(试图分配139802474386369字节)
error

这里的
$this->client->getContainer()
似乎是问题的根源。但我不知道该怎么写。如何解决这个内存问题

public function testIndexWithCreateUser()
    {
        $printMock = $this->createMock(InternPrintApi::class);
        $printMock->expects($this->once())
            ->method('createUser')
            ->willReturn(json_decode('{"user":{"account":{"email":"test.user@example.com"}}}'));

        $this->client->getContainer()->set(InternPrintApi::class, $printMock);

        $this->client->request('POST', '/registration', [
            'registration' => [
                'email' => 'test.user@example.com',
                'password' => 'password'
            ]
        ]);

        $this->assertEquals(302, $this->client->getResponse()->getStatusCode());
    }