@@ -566,7 +566,43 @@ public function testCreateHashIndex()
566
566
$ this ->assertCount (2 , $ indexInfo ['fields ' ], "There should only be 2 indexed fields " );
567
567
$ this ->assertEquals ("hashfield1 " , $ indexInfo ['fields ' ][0 ], "The first indexed field is not 'hashfield1' " );
568
568
$ this ->assertEquals ("hashfield2 " , $ indexInfo ['fields ' ][1 ], "The second indexed field is not 'hashfield2' " );
569
- $ this ->assertEquals (true , $ indexInfo [CollectionHandler::OPTION_UNIQUE ], 'unique was not set to true! ' );
569
+ $ this ->assertTrue ($ indexInfo [CollectionHandler::OPTION_UNIQUE ], 'unique was not set to true! ' );
570
+ $ this ->assertFalse ($ indexInfo [CollectionHandler::OPTION_SPARSE ], 'sparse flag was not set to false! ' );
571
+ $ this ->assertTrue (isset ($ indexInfo ['selectivityEstimate ' ]), 'selectivity estimate not present! ' );
572
+ }
573
+
574
+
575
+ /**
576
+ * Create a sparse hash index and verify it by getting information about the index from the server
577
+ */
578
+ public function testCreateSparseHashIndex ()
579
+ {
580
+ $ result = $ this ->collectionHandler ->createHashIndex (
581
+ 'ArangoDB_PHP_TestSuite_IndexTestCollection ' ,
582
+ array ('hashfield1 ' , 'hashfield2 ' ),
583
+ false ,
584
+ array ('sparse ' => true )
585
+ );
586
+
587
+ $ indices = $ this ->collectionHandler ->getIndexes ('ArangoDB_PHP_TestSuite_IndexTestCollection ' );
588
+
589
+ $ indicesByIdentifiers = $ indices ['identifiers ' ];
590
+
591
+ $ this ->assertArrayHasKey ($ result ['id ' ], $ indicesByIdentifiers , 'Hash index was not created! ' );
592
+
593
+ $ indexInfo = $ indicesByIdentifiers [$ result ['id ' ]];
594
+
595
+ $ this ->assertEquals (
596
+ CollectionHandler::OPTION_HASH_INDEX ,
597
+ $ indexInfo [CollectionHandler::OPTION_TYPE ],
598
+ "Index type is not 'hash'! "
599
+ );
600
+ $ this ->assertCount (2 , $ indexInfo ['fields ' ], "There should only be 2 indexed fields " );
601
+ $ this ->assertEquals ("hashfield1 " , $ indexInfo ['fields ' ][0 ], "The first indexed field is not 'hashfield1' " );
602
+ $ this ->assertEquals ("hashfield2 " , $ indexInfo ['fields ' ][1 ], "The second indexed field is not 'hashfield2' " );
603
+ $ this ->assertFalse ($ indexInfo [CollectionHandler::OPTION_UNIQUE ], 'unique was not set to false! ' );
604
+ $ this ->assertTrue ($ indexInfo [CollectionHandler::OPTION_SPARSE ], 'sparse flag was not set to true! ' );
605
+ $ this ->assertTrue (isset ($ indexInfo ['selectivityEstimate ' ]), 'selectivity estimate not present! ' );
570
606
}
571
607
572
608
@@ -627,7 +663,41 @@ public function testCreateSkipListIndex()
627
663
$ this ->assertCount (2 , $ indexInfo ['fields ' ], "There should only be 2 indexed field " );
628
664
$ this ->assertEquals ("skiplistfield1 " , $ indexInfo ['fields ' ][0 ], "The indexed field is not 'skiplistfield1' " );
629
665
$ this ->assertEquals ("skiplistfield2 " , $ indexInfo ['fields ' ][1 ], "The indexed field is not 'skiplistfield2' " );
630
- $ this ->assertEquals (true , $ indexInfo [CollectionHandler::OPTION_UNIQUE ], 'unique was not set to true! ' );
666
+ $ this ->assertTrue ($ indexInfo [CollectionHandler::OPTION_UNIQUE ], 'unique was not set to true! ' );
667
+ $ this ->assertFalse ($ indexInfo [CollectionHandler::OPTION_SPARSE ], 'sparse flag was not set to false! ' );
668
+ }
669
+
670
+
671
+ /**
672
+ * Create a sparse skiplist index and verify it by getting information about the index from the server
673
+ */
674
+ public function testCreateSparseSkipListIndex ()
675
+ {
676
+ $ result = $ this ->collectionHandler ->createSkipListIndex (
677
+ 'ArangoDB_PHP_TestSuite_IndexTestCollection ' ,
678
+ array ('skiplistfield1 ' , 'skiplistfield2 ' ),
679
+ false ,
680
+ array ('sparse ' => true )
681
+ );
682
+
683
+ $ indices = $ this ->collectionHandler ->getIndexes ('ArangoDB_PHP_TestSuite_IndexTestCollection ' );
684
+
685
+ $ indicesByIdentifiers = $ indices ['identifiers ' ];
686
+
687
+ $ this ->assertArrayHasKey ($ result ['id ' ], $ indicesByIdentifiers , 'skip-list index was not created! ' );
688
+
689
+ $ indexInfo = $ indicesByIdentifiers [$ result ['id ' ]];
690
+
691
+ $ this ->assertEquals (
692
+ CollectionHandler::OPTION_SKIPLIST_INDEX ,
693
+ $ indexInfo [CollectionHandler::OPTION_TYPE ],
694
+ "Index type is not 'skip-list'! "
695
+ );
696
+ $ this ->assertCount (2 , $ indexInfo ['fields ' ], "There should only be 2 indexed field " );
697
+ $ this ->assertEquals ("skiplistfield1 " , $ indexInfo ['fields ' ][0 ], "The indexed field is not 'skiplistfield1' " );
698
+ $ this ->assertEquals ("skiplistfield2 " , $ indexInfo ['fields ' ][1 ], "The indexed field is not 'skiplistfield2' " );
699
+ $ this ->assertFalse ($ indexInfo [CollectionHandler::OPTION_UNIQUE ], 'unique was not set to false! ' );
700
+ $ this ->assertTrue ($ indexInfo [CollectionHandler::OPTION_SPARSE ], 'sparse flag was not set to true! ' );
631
701
}
632
702
633
703
0 commit comments