@@ -692,6 +692,75 @@ public function testCreateSparseSkipListIndex()
692
692
static ::assertTrue ($ indexInfo [CollectionHandler::OPTION_SPARSE ], 'sparse flag was not set to true! ' );
693
693
}
694
694
}
695
+
696
+
697
+ /**
698
+ * Create a persistent index and verify it by getting information about the index from the server
699
+ */
700
+ public function testCreatePersistentIndex ()
701
+ {
702
+ $ result = $ this ->collectionHandler ->createPersistentIndex (
703
+ 'ArangoDB_PHP_TestSuite_IndexTestCollection ' ,
704
+ ['field1 ' , 'field2 ' ],
705
+ true
706
+ );
707
+
708
+ $ indices = $ this ->collectionHandler ->getIndexes ('ArangoDB_PHP_TestSuite_IndexTestCollection ' );
709
+
710
+ $ indicesByIdentifiers = $ indices ['identifiers ' ];
711
+
712
+ static ::assertArrayHasKey ($ result ['id ' ], $ indicesByIdentifiers , 'persistent index was not created! ' );
713
+
714
+ $ indexInfo = $ indicesByIdentifiers [$ result ['id ' ]];
715
+
716
+ static ::assertEquals (
717
+ CollectionHandler::OPTION_PERSISTENT_INDEX ,
718
+ $ indexInfo [CollectionHandler::OPTION_TYPE ],
719
+ "Index type is not 'persistent'! "
720
+ );
721
+ static ::assertCount (2 , $ indexInfo ['fields ' ], 'There should only be 2 indexed fields ' );
722
+ static ::assertEquals ('field1 ' , $ indexInfo ['fields ' ][0 ], "The indexed field is not 'field1' " );
723
+ static ::assertEquals ('field2 ' , $ indexInfo ['fields ' ][1 ], "The indexed field is not 'field2' " );
724
+ static ::assertTrue ($ indexInfo [CollectionHandler::OPTION_UNIQUE ], 'unique was not set to true! ' );
725
+ if ($ this ->hasSparseIndexes ) {
726
+ static ::assertFalse ($ indexInfo [CollectionHandler::OPTION_SPARSE ], 'sparse flag was not set to false! ' );
727
+ }
728
+ }
729
+
730
+
731
+ /**
732
+ * Create a sparse persistent index and verify it by getting information about the index from the server
733
+ */
734
+ public function testCreateSparsePersistentIndex ()
735
+ {
736
+ $ result = $ this ->collectionHandler ->createPersistentIndex (
737
+ 'ArangoDB_PHP_TestSuite_IndexTestCollection ' ,
738
+ ['field1 ' , 'field2 ' ],
739
+ false ,
740
+ ['sparse ' => true ]
741
+ );
742
+
743
+ $ indices = $ this ->collectionHandler ->getIndexes ('ArangoDB_PHP_TestSuite_IndexTestCollection ' );
744
+
745
+ $ indicesByIdentifiers = $ indices ['identifiers ' ];
746
+
747
+ static ::assertArrayHasKey ($ result ['id ' ], $ indicesByIdentifiers , 'persistent index was not created! ' );
748
+
749
+ $ indexInfo = $ indicesByIdentifiers [$ result ['id ' ]];
750
+
751
+ static ::assertEquals (
752
+ CollectionHandler::OPTION_PERSISTENT_INDEX ,
753
+ $ indexInfo [CollectionHandler::OPTION_TYPE ],
754
+ "Index type is not 'persistent'! "
755
+ );
756
+ static ::assertCount (2 , $ indexInfo ['fields ' ], 'There should only be 2 indexed fields ' );
757
+ static ::assertEquals ('field1 ' , $ indexInfo ['fields ' ][0 ], "The indexed field is not 'field1' " );
758
+ static ::assertEquals ('field2 ' , $ indexInfo ['fields ' ][1 ], "The indexed field is not 'field2' " );
759
+ static ::assertFalse ($ indexInfo [CollectionHandler::OPTION_UNIQUE ], 'unique was not set to false! ' );
760
+ if ($ this ->hasSparseIndexes ) {
761
+ static ::assertTrue ($ indexInfo [CollectionHandler::OPTION_SPARSE ], 'sparse flag was not set to true! ' );
762
+ }
763
+ }
695
764
696
765
697
766
/**
0 commit comments