This repository has been archived by the owner on Nov 11, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #307 from alcaeus/fix-empty-pipeline-match-stages
Convert empty match stages to objects
- Loading branch information
Showing
6 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
tests/Doctrine/MongoDB/Tests/Aggregation/FunctionalTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace Doctrine\MongoDB\Tests\Aggregation; | ||
|
||
use Doctrine\MongoDB\Tests\DatabaseTestCase; | ||
|
||
class FunctionalTest extends DatabaseTestCase | ||
{ | ||
public function testEmptyMatchStageDoesNotCauseError() | ||
{ | ||
$result = $this->createAggregationBuilder() | ||
->match() | ||
->execute(); | ||
|
||
$this->assertCount(0, $result); | ||
} | ||
|
||
public function testGeoNearWithEmptyQueryDoesNotCauseError() | ||
{ | ||
if (version_compare($this->getServerVersion(), '3.4.0', '>=')) { | ||
$this->conn->selectDatabase('admin')->command(['setFeatureCompatibilityVersion' => '3.4']); | ||
} | ||
|
||
$this->getCollection()->ensureIndex(['location' => '2dsphere']); | ||
$result = $this->createAggregationBuilder() | ||
->geoNear(0, 0) | ||
->distanceField('distance') | ||
->spherical() | ||
->execute(); | ||
|
||
$this->assertCount(0, $result); | ||
} | ||
|
||
public function testGraphLookupWithoutMatch() | ||
{ | ||
if (version_compare($this->getServerVersion(), '3.4.0', '<')) { | ||
$this->markTestSkipped('$graphLookup is only available on server version 3.4 and later.'); | ||
} | ||
|
||
$result = $this->createAggregationBuilder() | ||
->graphLookup('employees') | ||
->startWith('$reportsTo') | ||
->connectFromField('reportsTo') | ||
->connectToField('name') | ||
->alias('reportingHierarchy') | ||
->execute(); | ||
|
||
$this->assertCount(0, $result); | ||
} | ||
|
||
/** | ||
* @return \Doctrine\MongoDB\Aggregation\Builder | ||
*/ | ||
protected function createAggregationBuilder() | ||
{ | ||
return $this->getCollection()->createAggregationBuilder(); | ||
} | ||
|
||
/** | ||
* @return \Doctrine\MongoDB\Collection | ||
*/ | ||
protected function getCollection() | ||
{ | ||
$db = $this->conn->selectDatabase(self::$dbName); | ||
return $db->selectCollection('test'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters