|
9 | 9 | use MongoDB\Driver\ReadPreference; |
10 | 10 | use MongoDB\Driver\WriteConcern; |
11 | 11 | use MongoDB\Operation\MapReduce; |
| 12 | +use MongoDB\Tests\CommandObserver; |
| 13 | +use stdClass; |
12 | 14 |
|
13 | 15 | /** |
14 | 16 | * Functional tests for the Collection class. |
@@ -100,6 +102,35 @@ public function testGetNamespace() |
100 | 102 | $this->assertEquals($this->getNamespace(), $this->collection->getNamespace()); |
101 | 103 | } |
102 | 104 |
|
| 105 | + public function testCreateIndexSplitsCommandOptions() |
| 106 | + { |
| 107 | + if (version_compare($this->getServerVersion(), '3.6.0', '<')) { |
| 108 | + $this->markTestSkipped('Sessions are not supported'); |
| 109 | + } |
| 110 | + |
| 111 | + (new CommandObserver)->observe( |
| 112 | + function() { |
| 113 | + $this->collection->createIndex( |
| 114 | + ['x' => 1], |
| 115 | + [ |
| 116 | + 'maxTimeMS' => 1000, |
| 117 | + 'session' => $this->manager->startSession(), |
| 118 | + 'sparse' => true, |
| 119 | + 'unique' => true, |
| 120 | + 'writeConcern' => new WriteConcern(1), |
| 121 | + ] |
| 122 | + ); |
| 123 | + }, |
| 124 | + function(stdClass $command) { |
| 125 | + $this->assertObjectHasAttribute('lsid', $command); |
| 126 | + $this->assertObjectHasAttribute('maxTimeMS', $command); |
| 127 | + $this->assertObjectHasAttribute('writeConcern', $command); |
| 128 | + $this->assertObjectHasAttribute('sparse', $command->indexes[0]); |
| 129 | + $this->assertObjectHasAttribute('unique', $command->indexes[0]); |
| 130 | + } |
| 131 | + ); |
| 132 | + } |
| 133 | + |
103 | 134 | public function testDrop() |
104 | 135 | { |
105 | 136 | $writeResult = $this->collection->insertOne(['x' => 1]); |
|
0 commit comments