Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.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
序列化';MongoDB\Driver\Manager';不允许(php单元)_Mongodb_Phpunit - Fatal编程技术网

序列化';MongoDB\Driver\Manager';不允许(php单元)

序列化';MongoDB\Driver\Manager';不允许(php单元),mongodb,phpunit,Mongodb,Phpunit,我从一个转到另一个。 我重新编写了我的persistence类和persistenceTest类。一切都很顺利。然后我重新启动电脑,测试失败,并显示错误消息: PHPUnit 5.7.21 by Sebastian Bergmann and contributors. Serialization of 'MongoDB\Driver\Manager' is not allowed 我将问题简化为一个非常基本的类和类测试 班级: class Abc { protected $x;

我从一个转到另一个。 我重新编写了我的persistence类和persistenceTest类。一切都很顺利。然后我重新启动电脑,测试失败,并显示错误消息:

PHPUnit 5.7.21 by Sebastian Bergmann and contributors.

Serialization of 'MongoDB\Driver\Manager' is not allowed
我将问题简化为一个非常基本的类和类测试

班级:

class Abc
{
    protected $x;

    public function __construct()
    {
        $driverOptions = [ 'typeMap' => [ 'root' => 'array', 'document' => 'array', 'array' => 'array' ] ];
        $manager = new \MongoDB\Driver\Manager("mongodb://user7:user777@localhost", [], $driverOptions);
        $this->x = new MongoDB\Database($manager, 'testDB', $driverOptions);
        $d = $this->x->{'testCollection'}->find();
        foreach ($d as $e) var_dump($e);
    }
}
$y = new Abc();
TestClass:

class AbcTest extends PHPUnit_Framework_TestCase
{
    public function test123(){}
}
我在windows上使用PHP5.6.30 PHPUnit 5.7.21和“mongodb/mongodb”:“1.1.2”

你知道为什么它一开始工作,现在我收到了这个错误信息吗?
该类本身可以工作,通过apache调用,它提供testCollection的内容,没有错误或警告。

经过2天的测试,我认为问题在于,如果对象->变量=对象->变量=…=的级别太多,则对象成员变量无法容纳Manager类新建MongoDB\Client()。我的解决方案是将它放在一个静态成员var self::$persistens=new Manager\Client()…您能发布这个问题的解决方案吗?我收到了同样的错误信息,我对你写的东西很感兴趣,我想知道它的去向。