Commit bb7452f4 authored by Jeremy Mikola's avatar Jeremy Mikola

PHPLIB-54: Update references to driver classes

As of 0.1.4, driver classes are under the MongoDB\Driver namespace. As of 0.1.5, QueryResult and CommandResult were consolidated into a single Result class.
parent 0cf95ce2
This diff is collapsed.
<?php <?php
namespace MongoDB; namespace MongoDB;
use MongoDB\Driver\WriteResult;
class DeleteResult class DeleteResult
{ {
protected $wr; protected $wr;
public function __construct(\MongoDB\WriteResult $wr) public function __construct(WriteResult $wr)
{ {
$this->wr = $wr; $this->wr = $wr;
} }
......
<?php <?php
namespace MongoDB; namespace MongoDB;
use BSON\ObjectId;
use MongoDB\Driver\WriteResult;
class InsertResult class InsertResult
{ {
protected $wr; protected $wr;
public function __construct(\MongoDB\WriteResult $wr, \BSON\ObjectId $id = null) public function __construct(WriteResult $wr, ObjectId $id = null)
{ {
$this->wr = $wr; $this->wr = $wr;
$this->id = $id; $this->id = $id;
......
<?php <?php
namespace MongoDB; namespace MongoDB;
use MongoDB\Driver\WriteResult;
class UpdateResult class UpdateResult
{ {
protected $wr; protected $wr;
public function __construct(\MongoDB\WriteResult $wr) public function __construct(WriteResult $wr)
{ {
$this->wr = $wr; $this->wr = $wr;
} }
......
<?php <?php
use MongoDB\Collection;
use MongoDB\Driver\Manager;
class CollectionTest extends PHPUnit_Framework_TestCase { class CollectionTest extends PHPUnit_Framework_TestCase {
function setUp() { function setUp() {
...@@ -6,8 +10,8 @@ class CollectionTest extends PHPUnit_Framework_TestCase { ...@@ -6,8 +10,8 @@ class CollectionTest extends PHPUnit_Framework_TestCase {
$this->faker = Faker\Factory::create(); $this->faker = Faker\Factory::create();
$this->faker->seed(1234); $this->faker->seed(1234);
$this->manager = new MongoDB\Manager("mongodb://localhost"); $this->manager = new Manager("mongodb://localhost");
$this->collection = new MongoDB\Collection($this->manager, "test.case"); $this->collection = new Collection($this->manager, "test.case");
$this->collection->deleteMany(array()); $this->collection->deleteMany(array());
} }
...@@ -17,8 +21,8 @@ class CollectionTest extends PHPUnit_Framework_TestCase { ...@@ -17,8 +21,8 @@ class CollectionTest extends PHPUnit_Framework_TestCase {
for($i=0; $i<10;$i++) { for($i=0; $i<10;$i++) {
$user = createUser($this->faker); $user = createUser($this->faker);
$result = $collection->insertOne($user); $result = $collection->insertOne($user);
$this->assertInstanceOf("MongoDB\\InsertResult", $result); $this->assertInstanceOf('MongoDB\InsertResult', $result);
$this->assertInstanceOf("BSON\ObjectId", $result->getInsertedId()); $this->assertInstanceOf('BSON\ObjectId', $result->getInsertedId());
$this->assertEquals(24, strlen($result->getInsertedId())); $this->assertEquals(24, strlen($result->getInsertedId()));
$user["_id"] = $result->getInsertedId(); $user["_id"] = $result->getInsertedId();
...@@ -33,7 +37,7 @@ class CollectionTest extends PHPUnit_Framework_TestCase { ...@@ -33,7 +37,7 @@ class CollectionTest extends PHPUnit_Framework_TestCase {
$count = $collection->count($query); $count = $collection->count($query);
$this->assertEquals(1, $count); $this->assertEquals(1, $count);
$cursor = $collection->find($query); $cursor = $collection->find($query);
$this->assertInstanceOf("MongoDB\\QueryResult", $cursor); $this->assertInstanceOf('MongoDB\Driver\Result', $cursor);
foreach($cursor as $n => $person) { foreach($cursor as $n => $person) {
$this->assertInternalType("array", $person); $this->assertInternalType("array", $person);
......
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