Commit 2b20dfa8 authored by Jeremy Mikola's avatar Jeremy Mikola

Rename ChangeStream operation to Watch

This makes the operation consistent with the Collection method name and avoids the naming conflict with the ChangeStream iterator class.
parent 0e1516b0
......@@ -19,7 +19,7 @@ namespace MongoDB;
use MongoDB\BSON\JavascriptInterface;
use MongoDB\BSON\Serializable;
use MongoDB\ChangeStream as ChangeStreamResult;
use MongoDB\ChangeStream;
use MongoDB\Driver\Cursor;
use MongoDB\Driver\Manager;
use MongoDB\Driver\ReadConcern;
......@@ -32,7 +32,6 @@ use MongoDB\Exception\UnsupportedException;
use MongoDB\Model\IndexInfoIterator;
use MongoDB\Operation\Aggregate;
use MongoDB\Operation\BulkWrite;
use MongoDB\Operation\ChangeStream;
use MongoDB\Operation\CreateIndexes;
use MongoDB\Operation\Count;
use MongoDB\Operation\DeleteMany;
......@@ -52,6 +51,7 @@ use MongoDB\Operation\MapReduce;
use MongoDB\Operation\ReplaceOne;
use MongoDB\Operation\UpdateMany;
use MongoDB\Operation\UpdateOne;
use MongoDB\Operation\Watch;
use Traversable;
class Collection
......@@ -939,14 +939,14 @@ class Collection
return $operation->execute($server);
}
/*
* ChangeStream outline
/**
* Create a change stream for watching changes to the collection.
*
* @see ChangeStream::__construct() for supported options
* @param array $pipeline List of pipeline operations
* @param array $options Command options
* @see Watch::__construct() for supported options
* @param array $pipeline List of pipeline operations
* @param array $options Command options
* @return ChangeStream
* @throws InvalidArgumentException for parameter/option parsing errors
* @return ChangeStreamResult
*/
public function watch(array $pipeline = [], array $options = [])
{
......@@ -960,7 +960,7 @@ class Collection
$options['readConcern'] = $this->readConcern;
}
$operation = new ChangeStream($this->databaseName, $this->collectionName, $pipeline, $options, $this->manager);
$operation = new Watch($this->databaseName, $this->collectionName, $pipeline, $options, $this->manager);
return $operation->execute($server);
}
......
......@@ -17,7 +17,7 @@
namespace MongoDB\Operation;
use MongoDB\ChangeStream as ChangeStreamResult;
use MongoDB\ChangeStream;
use MongoDB\Driver\Command;
use MongoDB\Driver\Manager;
use MongoDB\Driver\ReadConcern;
......@@ -35,7 +35,7 @@ use MongoDB\Exception\UnsupportedException;
* @see \MongoDB\Collection::changeStream()
* @see http://docs.mongodb.org/manual/reference/command/changeStream/
*/
class ChangeStream implements Executable
class Watch implements Executable
{
const FULL_DOCUMENT_DEFAULT = 'default';
const FULL_DOCUMENT_UPDATE_LOOKUP = 'updateLookup';
......@@ -131,7 +131,7 @@ class ChangeStream implements Executable
*
* @see Executable::execute()
* @param Server $server
* @return ChangeStreamResult
* @return ChangeStream
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if collation, read concern, or write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
......@@ -142,7 +142,7 @@ class ChangeStream implements Executable
$cursor = $command->execute($server);
return new ChangeStreamResult($cursor, $this->createResumeCallable());
return new ChangeStream($cursor, $this->createResumeCallable());
}
private function createAggregateOptions()
......
......@@ -938,7 +938,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this->assertNull($current);
// Start Changestream Example 2
$cursor = $db->inventory->watch([], ['fullDocument' => \MongoDB\Operation\ChangeStream::FULL_DOCUMENT_UPDATE_LOOKUP]);
$cursor = $db->inventory->watch([], ['fullDocument' => \MongoDB\Operation\Watch::FULL_DOCUMENT_UPDATE_LOOKUP]);
$cursor->next();
$current = $cursor->current();
// End Changestream Example 2
......
......@@ -6,7 +6,7 @@ use MongoDB\Client;
use MongoDB\Collection;
use MongoDB\Operation\DatabaseCommand;
class ChangeStreamFunctionalTest extends FunctionalTestCase
class WatchFunctionalTest extends FunctionalTestCase
{
public function setUp()
{
......@@ -37,7 +37,7 @@ class ChangeStreamFunctionalTest extends FunctionalTestCase
'_id' => $changeStreamResult->current()->_id,
'operationType' => 'insert',
'fullDocument' => (object) ['_id' => $result->getInsertedId(), 'x' => 2],
'ns' => (object) ['db' => 'phplib_test', 'coll' => 'ChangeStreamFunctionalTest.e68b9f01'],
'ns' => (object) ['db' => 'phplib_test', 'coll' => 'WatchFunctionalTest.e68b9f01'],
'documentKey' => (object) ['_id' => $result->getInsertedId()]
]);
$this->assertEquals($changeStreamResult->current(), $expectedResult);
......@@ -54,7 +54,7 @@ class ChangeStreamFunctionalTest extends FunctionalTestCase
'_id' => $changeStreamResult->current()->_id,
'operationType' => 'insert',
'fullDocument' => (object) ['_id' => $result->getInsertedId(), 'x' => 3],
'ns' => (object) ['db' => 'phplib_test', 'coll' => 'ChangeStreamFunctionalTest.e68b9f01'],
'ns' => (object) ['db' => 'phplib_test', 'coll' => 'WatchFunctionalTest.e68b9f01'],
'documentKey' => (object) ['_id' => $result->getInsertedId()]
]);
$this->assertEquals($changeStreamResult->current(), $expectedResult);
......@@ -81,7 +81,7 @@ class ChangeStreamFunctionalTest extends FunctionalTestCase
'_id' => $changeStreamResult->current()->_id,
'operationType' => 'insert',
'fullDocument' => (object) ['_id' => $result->getInsertedId(), 'x' => 2],
'ns' => (object) ['db' => 'phplib_test', 'coll' => 'ChangeStreamFunctionalTest.4a554985'],
'ns' => (object) ['db' => 'phplib_test', 'coll' => 'WatchFunctionalTest.4a554985'],
'documentKey' => (object) ['_id' => $result->getInsertedId()]
]);
$this->assertEquals($changeStreamResult->current(), $expectedResult);
......@@ -101,7 +101,7 @@ class ChangeStreamFunctionalTest extends FunctionalTestCase
'_id' => $changeStreamResult->current()->_id,
'operationType' => 'insert',
'fullDocument' => (object) ['_id' => $result->getInsertedId(), 'x' => 3],
'ns' => (object) ['db' => 'phplib_test', 'coll' => 'ChangeStreamFunctionalTest.4a554985'],
'ns' => (object) ['db' => 'phplib_test', 'coll' => 'WatchFunctionalTest.4a554985'],
'documentKey' => (object) ['_id' => $result->getInsertedId()]
]);
$this->assertEquals($changeStreamResult->current(), $expectedResult);
......@@ -232,7 +232,7 @@ class ChangeStreamFunctionalTest extends FunctionalTestCase
'_id' => $changeStreamResult->current()->_id,
'operationType' => 'insert',
'fullDocument' => (object) ['_id' => $result->getInsertedId(), 'x' => 1],
'ns' => (object) ['db' => 'phplib_test', 'coll' => 'ChangeStreamFunctionalTest.226d95f1'],
'ns' => (object) ['db' => 'phplib_test', 'coll' => 'WatchFunctionalTest.226d95f1'],
'documentKey' => (object) ['_id' => $result->getInsertedId()]
]);
$this->assertEquals($changeStreamResult->current(), $expectedResult);
......
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