Commit 1933e89f authored by Jeremy Mikola's avatar Jeremy Mikola

Tests for BSON array and document serialize methods

parent 54b9605b
<?php
namespace MongoDB\Tests;
use MongoDB\Model\BSONArray;
class BSONArrayTest extends TestCase
{
public function testBsonSerializeReindexesKeys()
{
$data = [0 => 'foo', 2 => 'bar'];
$array = new BSONArray($data);
$this->assertSame($data, $array->getArrayCopy());
$this->assertSame(['foo', 'bar'], $array->bsonSerialize());
}
}
<?php
namespace MongoDB\Tests;
use MongoDB\Model\BSONDocument;
use ArrayObject;
class BSONDocumentTest extends TestCase
{
public function testBsonSerializeCastsToObject()
{
$data = [0 => 'foo', 2 => 'bar'];
$document = new BSONDocument($data);
$this->assertSame($data, $document->getArrayCopy());
$this->assertEquals((object) [0 => 'foo', 2 => 'bar'], $document->bsonSerialize());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment