@@ -1093,6 +1093,116 @@ public function testCreateGetAllIdsAndDeleteCollectionThroughCreateFromArray()
1093
1093
}
1094
1094
1095
1095
1096
+ /**
1097
+ * test for creation, all, and delete of a collection
1098
+ */
1099
+ public function testCreateAndAllAndDeleteCollection ()
1100
+ {
1101
+ $ collectionHandler = $ this ->collectionHandler ;
1102
+
1103
+ $ collection = Collection::createFromArray (array ('name ' => 'ArangoDB_PHP_TestSuite_TestCollection_01 ' ));
1104
+ $ collectionHandler ->add ($ collection );
1105
+
1106
+ $ documentHandler = $ this ->documentHandler ;
1107
+
1108
+ $ document = Document::createFromArray (
1109
+ array ('someAttribute ' => 'someValue ' , 'someOtherAttribute ' => 'someOtherValue ' )
1110
+ );
1111
+ $ documentHandler ->add ($ collection ->getId (), $ document );
1112
+
1113
+ $ document = Document::createFromArray (
1114
+ array ('someAttribute ' => 'someValue2 ' , 'someOtherAttribute ' => 'someOtherValue2 ' )
1115
+ );
1116
+ $ documentHandler ->add ($ collection ->getId (), $ document );
1117
+
1118
+ $ cursor = $ collectionHandler ->all ($ collection ->getId ());
1119
+
1120
+ $ resultingDocument = null ;
1121
+
1122
+ foreach ($ cursor as $ key => $ value ) {
1123
+ $ resultingDocument [$ key ] = $ value ;
1124
+ }
1125
+
1126
+ $ this ->assertTrue (count ($ resultingDocument ) == 2 , 'Should be 2, was: ' . count ($ resultingDocument ));
1127
+
1128
+ $ response = $ collectionHandler ->delete ($ collection );
1129
+ $ this ->assertTrue ($ response , 'Delete should return true! ' );
1130
+ }
1131
+
1132
+
1133
+ /**
1134
+ * test for creation, all with limit, and delete of a collection
1135
+ */
1136
+ public function testCreateAndAllWithLimitAndDeleteCollection ()
1137
+ {
1138
+ $ collectionHandler = $ this ->collectionHandler ;
1139
+
1140
+ $ collection = Collection::createFromArray (array ('name ' => 'ArangoDB_PHP_TestSuite_TestCollection_01 ' ));
1141
+ $ collectionHandler ->add ($ collection );
1142
+
1143
+ $ documentHandler = $ this ->documentHandler ;
1144
+
1145
+ $ document = Document::createFromArray (
1146
+ array ('someAttribute ' => 'someValue ' , 'someOtherAttribute ' => 'someOtherValue ' )
1147
+ );
1148
+ $ documentHandler ->add ($ collection ->getId (), $ document );
1149
+
1150
+ $ document = Document::createFromArray (
1151
+ array ('someAttribute ' => 'someValue2 ' , 'someOtherAttribute ' => 'someOtherValue2 ' )
1152
+ );
1153
+ $ documentHandler ->add ($ collection ->getId (), $ document );
1154
+
1155
+ $ cursor = $ collectionHandler ->all ($ collection ->getId (), array ( 'limit ' => 1 ));
1156
+
1157
+ $ resultingDocument = null ;
1158
+
1159
+ foreach ($ cursor as $ key => $ value ) {
1160
+ $ resultingDocument [$ key ] = $ value ;
1161
+ }
1162
+
1163
+ // 2 Documents limited to 1, the result should be 1
1164
+ $ this ->assertTrue (count ($ resultingDocument ) == 1 , 'Should be 1, was: ' . count ($ resultingDocument ));
1165
+
1166
+ $ response = $ collectionHandler ->delete ($ collection );
1167
+ $ this ->assertTrue ($ response , 'Delete should return true! ' );
1168
+ }
1169
+
1170
+
1171
+ /**
1172
+ * test for creation, all with skip, and delete of a collection
1173
+ */
1174
+ public function testCreateAndAllWithSkipAndDeleteCollection ()
1175
+ {
1176
+ $ collectionHandler = $ this ->collectionHandler ;
1177
+
1178
+ $ collection = Collection::createFromArray (array ('name ' => 'ArangoDB_PHP_TestSuite_TestCollection_01 ' ));
1179
+ $ collectionHandler ->add ($ collection );
1180
+
1181
+ $ documentHandler = $ this ->documentHandler ;
1182
+
1183
+ for ($ i = 0 ; $ i < 3 ; $ i ++) {
1184
+ $ document = Document::createFromArray (
1185
+ array ('someAttribute ' => 'someValue ' . $ i , 'someOtherAttribute ' => 'someValue ' . $ i )
1186
+ );
1187
+ $ documentHandler ->add ($ collection ->getId (), $ document );
1188
+ }
1189
+
1190
+ $ cursor = $ collectionHandler ->all ($ collection ->getId (), array ( 'skip ' => 1 ));
1191
+
1192
+ $ resultingDocument = null ;
1193
+
1194
+ foreach ($ cursor as $ key => $ value ) {
1195
+ $ resultingDocument [$ key ] = $ value ;
1196
+ }
1197
+
1198
+ // With 3 Documents and skipping 1, the result should be 2
1199
+ $ this ->assertTrue (count ($ resultingDocument ) == 2 , 'Should be 2, was: ' . count ($ resultingDocument ));
1200
+
1201
+ $ response = $ collectionHandler ->delete ($ collection );
1202
+ $ this ->assertTrue ($ response , 'Delete should return true! ' );
1203
+ }
1204
+
1205
+
1096
1206
/**
1097
1207
* test for creating, filling with documents and truncating the collection.
1098
1208
*/
0 commit comments