Alcaeus\MongoDbAdapter\Tests\Mongo\MongoCollectionTest::testCreateRecord PHP Méthode

testCreateRecord() public méthode

public testCreateRecord ( )
    public function testCreateRecord()
    {
        $collection = $this->getCollection();
        $expected = ['ok' => 1.0, 'n' => 0, 'err' => null, 'errmsg' => null];
        $document = ['foo' => 'bar'];
        $this->assertSame($expected, $collection->insert($document));
        $this->assertInstanceOf('MongoId', $document['_id']);
        $id = (string) $document['_id'];
        $newCollection = $this->getCheckDatabase()->selectCollection('test');
        $this->assertSame(1, $newCollection->count());
        $object = $newCollection->findOne();
        $this->assertNotNull($object);
        $this->assertAttributeInstanceOf('MongoDB\\BSON\\ObjectID', '_id', $object);
        $this->assertSame($id, (string) $object->_id);
        $this->assertObjectHasAttribute('foo', $object);
        $this->assertAttributeSame('bar', 'foo', $object);
    }
MongoCollectionTest