8
8
use Alcaeus \MongoDbAdapter \Tests \TestCase ;
9
9
use MongoId ;
10
10
use PHPUnit \Framework \Error \Warning ;
11
+ use function extension_loaded ;
11
12
12
13
/**
13
14
* @author alcaeus <alcaeus@alcaeus.org>
@@ -844,6 +845,8 @@ public function testDistinctWithIdQuery()
844
845
845
846
public function testAggregate ()
846
847
{
848
+ $ this ->skipTestIf (extension_loaded ('mongo ' ));
849
+
847
850
$ collection = $ this ->getCollection ();
848
851
849
852
$ this ->prepareData ();
@@ -860,7 +863,7 @@ public function testAggregate()
860
863
]
861
864
];
862
865
863
- $ result = $ collection ->aggregate ($ pipeline );
866
+ $ result = $ collection ->aggregate ($ pipeline, [ ' cursor ' => true ] );
864
867
$ this ->assertInternalType ('array ' , $ result );
865
868
$ this ->assertArrayHasKey ('result ' , $ result );
866
869
@@ -872,6 +875,8 @@ public function testAggregate()
872
875
873
876
public function testAggregateWithMultiplePilelineOperatorsAsArguments ()
874
877
{
878
+ $ this ->skipTestIf (version_compare ($ this ->getServerVersion (), '3.6.0 ' , '>= ' ), 'Test does not apply to MongoDB >= 3.6. ' );
879
+
875
880
$ collection = $ this ->getCollection ();
876
881
877
882
$ this ->prepareData ();
@@ -906,6 +911,8 @@ public function testAggregateWithMultiplePilelineOperatorsAsArguments()
906
911
907
912
public function testAggregateInvalidPipeline ()
908
913
{
914
+ $ this ->skipTestIf (extension_loaded ('mongo ' ));
915
+
909
916
$ collection = $ this ->getCollection ();
910
917
911
918
$ pipeline = [
@@ -916,7 +923,7 @@ public function testAggregateInvalidPipeline()
916
923
917
924
$ this ->expectException (\MongoResultException::class);
918
925
$ this ->expectExceptionMessage ('Unrecognized pipeline stage name ' );
919
- $ collection ->aggregate ($ pipeline );
926
+ $ collection ->aggregate ($ pipeline, [ ' cursor ' => true ] );
920
927
}
921
928
922
929
public function testAggregateTimeoutException ()
@@ -939,7 +946,7 @@ public function testAggregateTimeoutException()
939
946
]
940
947
];
941
948
942
- $ collection ->aggregate ($ pipeline , ['maxTimeMS ' => 1 ]);
949
+ $ collection ->aggregate ($ pipeline , ['maxTimeMS ' => 1 , ' cursor ' => true ]);
943
950
}
944
951
945
952
public function testAggregateCursor ()
@@ -1723,6 +1730,8 @@ public function testFindAndModifyWithFields()
1723
1730
1724
1731
public function testGroup ()
1725
1732
{
1733
+ $ this ->skipTestIf (version_compare ($ this ->getServerVersion (), '4.2.0 ' , '>= ' ), 'Test does not apply to MongoDB >= 4.2. ' );
1734
+
1726
1735
$ collection = $ this ->getCollection ();
1727
1736
1728
1737
$ document1 = ['a ' => 2 ];
@@ -1887,7 +1896,6 @@ public function testValidate()
1887
1896
'ns ' => 'mongo-php-adapter.test ' ,
1888
1897
'nrecords ' => 1 ,
1889
1898
'nIndexes ' => 1 ,
1890
- 'keysPerIndex ' => ['mongo-php-adapter.test.$_id_ ' => 1 ],
1891
1899
'valid ' => true ,
1892
1900
'errors ' => [],
1893
1901
],
@@ -1904,7 +1912,7 @@ public function testDrop()
1904
1912
'nIndexesWas ' => 1 ,
1905
1913
'ok ' => 1.0
1906
1914
];
1907
- $ this ->assertSame ($ expected , $ this ->getCollection ()->drop ());
1915
+ $ this ->assertEquals ($ expected , $ this ->getCollection ()->drop ());
1908
1916
}
1909
1917
1910
1918
public function testEmptyCollectionName ()
0 commit comments