summaryrefslogtreecommitdiff
path: root/ext/spl/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/spl/tests')
-rw-r--r--ext/spl/tests/ArrayObject_unserialize_empty_string.phpt16
-rw-r--r--ext/spl/tests/CallbackFilterIteratorTest-002.phpt50
-rw-r--r--ext/spl/tests/CallbackFilterIteratorTest.phpt133
-rw-r--r--ext/spl/tests/DirectoryIterator_by_reference.phpt14
-rw-r--r--ext/spl/tests/DirectoryIterator_empty_constructor.phpt15
-rw-r--r--ext/spl/tests/DirectoryIterator_getBasename_basic_test.phpt23
-rw-r--r--ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt23
-rw-r--r--ext/spl/tests/DirectoryIterator_getExtension_basic.phpt57
-rw-r--r--ext/spl/tests/DirectoryIterator_getGroup_basic.phpt29
-rw-r--r--ext/spl/tests/DirectoryIterator_getInode_basic.phpt29
-rw-r--r--ext/spl/tests/DirectoryIterator_getInode_error.phpt28
-rw-r--r--ext/spl/tests/DirectoryIterator_getOwner_basic.phpt29
-rw-r--r--ext/spl/tests/RecursiveCallbackFilterIteratorTest.phpt138
-rw-r--r--ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt50
-rw-r--r--ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt56
-rw-r--r--ext/spl/tests/SplArray_fromArray.phpt17
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_bottom_pass_array.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_bottom_pass_float.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_bottom_pass_integer.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_bottom_pass_null.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_count.phpt12
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_count_param_SplDoublyLinkedList.phpt11
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_current.phpt11
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_current_empty.phpt13
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_debug-info.phpt29
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_getIteratorMode.phpt12
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_getIteratorMode_error.phpt12
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_isEmpty_empty-with-parameter.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_isEmpty_empty.phpt13
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty-with-parameter.phpt20
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty.phpt19
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_lifoMode.phpt23
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetExists_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetExists_success.phpt31
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetGet_empty.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetGet_missing_param.phpt15
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetGet_param_array.phpt18
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetGet_param_string.phpt18
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetSet_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetSet_one_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetUnset_greater_than_elements.phpt27
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt23
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt23
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_pop_noParams.phpt15
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_pop_params.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_push_missing_parameter.phpt13
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_serialization.phpt67
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_setIteratorMode_param_SplDoublyLinkedList.phpt11
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_top_pass_array.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_top_pass_float.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_top_pass_integer.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_top_pass_null.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_unshift_missing_parameter.phpt13
-rw-r--r--ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt25
-rw-r--r--ext/spl/tests/SplDoublylinkedlist_offsetunset_first002.phpt17
-rw-r--r--ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt25
-rw-r--r--ext/spl/tests/SplFileInfo_001.phpt11
-rw-r--r--ext/spl/tests/SplFileInfo_getExtension_basic.phpt31
-rw-r--r--ext/spl/tests/SplFileInfo_getGroup_basic.phpt26
-rw-r--r--ext/spl/tests/SplFileInfo_getGroup_error.phpt28
-rw-r--r--ext/spl/tests/SplFileInfo_getInode_basic.phpt30
-rw-r--r--ext/spl/tests/SplFileInfo_getInode_error.phpt28
-rw-r--r--ext/spl/tests/SplFileInfo_getOwner_basic.phpt26
-rw-r--r--ext/spl/tests/SplFileInfo_getOwner_error.phpt28
-rw-r--r--ext/spl/tests/SplFileInfo_getPerms_basic.phpt30
-rw-r--r--ext/spl/tests/SplFileInfo_getPerms_error.phpt28
-rw-r--r--ext/spl/tests/SplFileObject_current_basic.phpt18
-rw-r--r--ext/spl/tests/SplFileObject_current_error001.phpt19
-rw-r--r--ext/spl/tests/SplFileObject_current_variation001.phpt21
-rw-r--r--ext/spl/tests/SplFileObject_fflush_basic_001.phpt38
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_basic.phpt31
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_delimiter_basic.phpt31
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_delimiter_error.phpt23
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_enclosure_basic.phpt31
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_enclosure_error.phpt23
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_escape_basic.phpt24
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt24
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt18
-rw-r--r--ext/spl/tests/SplFileObject_fpassthru_basic.phpt13
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv.phpt106
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_002.phpt42
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_error.phpt35
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation1.phpt826
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation10.phpt327
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation11.phpt826
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation12.phpt827
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation13.phpt29
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation14.phpt29
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation5.phpt826
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation6.phpt829
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation7.phpt829
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation8.phpt829
-rw-r--r--ext/spl/tests/SplFileObject_fscanf_basic.phpt12
-rw-r--r--ext/spl/tests/SplFileObject_fseek_error_001.phpt12
-rw-r--r--ext/spl/tests/SplFileObject_ftruncate_error_001.phpt32
-rw-r--r--ext/spl/tests/SplFileObject_fwrite_error_001.phpt12
-rw-r--r--ext/spl/tests/SplFileObject_fwrite_variation_001.phpt21
-rw-r--r--ext/spl/tests/SplFileObject_fwrite_variation_002.phpt21
-rw-r--r--ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt15
-rw-r--r--ext/spl/tests/SplFileObject_getchildren_basic.phpt12
-rw-r--r--ext/spl/tests/SplFileObject_getchildren_error001.phpt12
-rw-r--r--ext/spl/tests/SplFileObject_getflags_basic.phpt22
-rw-r--r--ext/spl/tests/SplFileObject_getflags_error001.phpt26
-rw-r--r--ext/spl/tests/SplFileObject_getflags_error002.phpt21
-rw-r--r--ext/spl/tests/SplFileObject_getflags_variation001.phpt29
-rw-r--r--ext/spl/tests/SplFileObject_haschildren_basic.phpt12
-rw-r--r--ext/spl/tests/SplFileObject_haschildren_error001.phpt12
-rw-r--r--ext/spl/tests/SplFileObject_key_basic.phpt19
-rw-r--r--ext/spl/tests/SplFileObject_key_error001.phpt22
-rw-r--r--ext/spl/tests/SplFileObject_key_error002.phpt22
-rw-r--r--ext/spl/tests/SplFileObject_key_error003.phpt15
-rw-r--r--ext/spl/tests/SplFileObject_next_basic.phpt22
-rw-r--r--ext/spl/tests/SplFileObject_next_variation001.phpt24
-rw-r--r--ext/spl/tests/SplFileObject_next_variation002.phpt30
-rw-r--r--ext/spl/tests/SplFileObject_rewind_basic.phpt21
-rw-r--r--ext/spl/tests/SplFileObject_rewind_error001.phpt18
-rw-r--r--ext/spl/tests/SplFileObject_rewind_variation001.phpt28
-rw-r--r--ext/spl/tests/SplFileObject_seek_basic.phpt19
-rw-r--r--ext/spl/tests/SplFileObject_seek_error002.phpt18
-rw-r--r--ext/spl/tests/SplFileObject_seek_error_001.phpt19
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_basic.phpt30
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_error001.phpt24
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_error002.phpt24
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_error003.phpt26
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt30
-rw-r--r--ext/spl/tests/SplFileObject_testinput.csv5
-rw-r--r--ext/spl/tests/SplFixedArray__construct_param_array.phpt12
-rw-r--r--ext/spl/tests/SplFixedArray__construct_param_float.phpt14
-rw-r--r--ext/spl/tests/SplFixedArray__construct_param_null.phpt16
-rw-r--r--ext/spl/tests/SplFixedArray__construct_param_string.phpt12
-rw-r--r--ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt13
-rw-r--r--ext/spl/tests/SplFixedArray_count_checkParams.phpt16
-rw-r--r--ext/spl/tests/SplFixedArray_count_param_int.phpt11
-rw-r--r--ext/spl/tests/SplFixedArray_current_param.phpt24
-rw-r--r--ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_001.phpt10
-rw-r--r--ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_002.phpt10
-rw-r--r--ext/spl/tests/SplFixedArray_fromarray_indexes.phpt22
-rw-r--r--ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt21
-rw-r--r--ext/spl/tests/SplFixedArray_fromarray_param_boolean.phpt10
-rw-r--r--ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt17
-rw-r--r--ext/spl/tests/SplFixedArray_getSize_pass_param.phpt12
-rw-r--r--ext/spl/tests/SplFixedArray_key_param.phpt24
-rw-r--r--ext/spl/tests/SplFixedArray_key_setsize.phpt20
-rw-r--r--ext/spl/tests/SplFixedArray_next_param.phpt18
-rw-r--r--ext/spl/tests/SplFixedArray_offsetExists_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplFixedArray_offsetExists_less_than_zero.phpt13
-rw-r--r--ext/spl/tests/SplFixedArray_offsetGet_invalid_parameter.phpt16
-rw-r--r--ext/spl/tests/SplFixedArray_offsetSet_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplFixedArray_offsetSet_one_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplFixedArray_offsetUnset_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplFixedArray_offsetUnset_string.phpt33
-rw-r--r--ext/spl/tests/SplFixedArray_rewind_param.phpt18
-rw-r--r--ext/spl/tests/SplFixedArray_setSize_filled_to_smaller.phpt22
-rw-r--r--ext/spl/tests/SplFixedArray_setSize_param_array.phpt18
-rw-r--r--ext/spl/tests/SplFixedArray_setSize_param_float.phpt19
-rw-r--r--ext/spl/tests/SplFixedArray_setSize_param_null.phpt13
-rw-r--r--ext/spl/tests/SplFixedArray_setSize_reduce.phpt22
-rw-r--r--ext/spl/tests/SplFixedArray_setsize_001.phpt22
-rw-r--r--ext/spl/tests/SplFixedArray_setsize_grow.phpt30
-rw-r--r--ext/spl/tests/SplFixedArray_setsize_shrink.phpt28
-rw-r--r--ext/spl/tests/SplFixedArray_toArray_with-params.phpt19
-rw-r--r--ext/spl/tests/SplHeap_count_invalid_parameter.phpt47
-rw-r--r--ext/spl/tests/SplHeap_extract_invalid_parameter.phpt47
-rw-r--r--ext/spl/tests/SplHeap_insert_invalid_parameter.phpt16
-rw-r--r--ext/spl/tests/SplHeap_isEmpty.phpt15
-rw-r--r--ext/spl/tests/SplHeap_isEmpty_invalid_parameter.phpt47
-rw-r--r--ext/spl/tests/SplObjectStorage_addAll_invalid_parameter.phpt43
-rw-r--r--ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt20
-rw-r--r--ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt43
-rw-r--r--ext/spl/tests/SplObjectStorage_current_empty_storage.phpt15
-rw-r--r--ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt43
-rw-r--r--ext/spl/tests/SplObjectStorage_getHash.phpt60
-rw-r--r--ext/spl/tests/SplObjectStorage_getInfo_empty_storage.phpt15
-rw-r--r--ext/spl/tests/SplObjectStorage_offsetGet.phpt17
-rw-r--r--ext/spl/tests/SplObjectStorage_offsetGet_invalid_parameter.phpt45
-rw-r--r--ext/spl/tests/SplObjectStorage_offsetGet_missing_object.phpt20
-rw-r--r--ext/spl/tests/SplObjectStorage_removeAllExcept_basic.phpt27
-rw-r--r--ext/spl/tests/SplObjectStorage_removeAllExcept_invalid_parameter.phpt44
-rw-r--r--ext/spl/tests/SplObjectStorage_removeAll_invalid_parameter.phpt43
-rw-r--r--ext/spl/tests/SplObjectStorage_setInfo_empty_storage.phpt15
-rw-r--r--ext/spl/tests/SplObjectStorage_setInfo_invalid_parameter.phpt16
-rw-r--r--ext/spl/tests/SplObjectStorage_unserialize_bad.phpt45
-rw-r--r--ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt27
-rw-r--r--ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt34
-rw-r--r--ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt19
-rw-r--r--ext/spl/tests/SplObjectStorage_unserialize_nested.phpt47
-rw-r--r--ext/spl/tests/SplObjectStorage_var_dump.phpt23
-rw-r--r--ext/spl/tests/SplPriorityQueue_extract_invalid_parameter.phpt47
-rw-r--r--ext/spl/tests/SplPriorityQueue_insert_invalid_parameter.phpt16
-rw-r--r--ext/spl/tests/SplQueue_setIteratorMode.phpt15
-rw-r--r--ext/spl/tests/SplQueue_setIteratorMode_param_lifo.phpt19
-rw-r--r--ext/spl/tests/SplStack_setIteratorMode.phpt15
-rw-r--r--ext/spl/tests/SplTempFileObject_constructor_basic.phpt19
-rw-r--r--ext/spl/tests/SplTempFileObject_constructor_error.phpt12
-rw-r--r--ext/spl/tests/SplTempFileObject_constructor_maxmemory_basic.phpt19
-rw-r--r--ext/spl/tests/SplTempFileObject_constructor_memory_lt1_variation.phpt19
-rw-r--r--ext/spl/tests/arrayObject___construct_basic1.phpt52
-rw-r--r--ext/spl/tests/arrayObject___construct_basic2.phpt104
-rw-r--r--ext/spl/tests/arrayObject___construct_basic3.phpt104
-rw-r--r--ext/spl/tests/arrayObject___construct_basic4.phpt106
-rw-r--r--ext/spl/tests/arrayObject___construct_basic5.phpt106
-rw-r--r--ext/spl/tests/arrayObject___construct_basic6.phpt80
-rw-r--r--ext/spl/tests/arrayObject___construct_error1.phpt25
-rw-r--r--ext/spl/tests/arrayObject___construct_error2.phpt22
-rw-r--r--ext/spl/tests/arrayObject_asort_basic1.phpt64
-rw-r--r--ext/spl/tests/arrayObject_asort_basic2.phpt52
-rw-r--r--ext/spl/tests/arrayObject_clone_basic1.phpt48
-rw-r--r--ext/spl/tests/arrayObject_clone_basic2.phpt46
-rw-r--r--ext/spl/tests/arrayObject_clone_basic3.phpt80
-rw-r--r--ext/spl/tests/arrayObject_count_basic1.phpt84
-rw-r--r--ext/spl/tests/arrayObject_exchangeArray_basic1.phpt40
-rw-r--r--ext/spl/tests/arrayObject_exchangeArray_basic2.phpt97
-rw-r--r--ext/spl/tests/arrayObject_exchangeArray_basic3.phpt128
-rw-r--r--ext/spl/tests/arrayObject_getFlags_basic1.phpt25
-rw-r--r--ext/spl/tests/arrayObject_getFlags_basic2.phpt24
-rw-r--r--ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt116
-rw-r--r--ext/spl/tests/arrayObject_ksort_basic1.phpt67
-rw-r--r--ext/spl/tests/arrayObject_ksort_basic2.phpt52
-rw-r--r--ext/spl/tests/arrayObject_magicMethods1.phpt195
-rw-r--r--ext/spl/tests/arrayObject_magicMethods2.phpt197
-rw-r--r--ext/spl/tests/arrayObject_magicMethods3.phpt195
-rw-r--r--ext/spl/tests/arrayObject_magicMethods4.phpt206
-rw-r--r--ext/spl/tests/arrayObject_magicMethods5.phpt206
-rw-r--r--ext/spl/tests/arrayObject_magicMethods6.phpt206
-rw-r--r--ext/spl/tests/arrayObject_natcasesort_basic1.phpt56
-rw-r--r--ext/spl/tests/arrayObject_natsort_basic1.phpt57
-rw-r--r--ext/spl/tests/arrayObject_offsetExists_nullcheck.phpt10
-rw-r--r--ext/spl/tests/arrayObject_setFlags_basic1.phpt51
-rw-r--r--ext/spl/tests/arrayObject_setFlags_basic2.phpt29
-rw-r--r--ext/spl/tests/arrayObject_setIteratorClass_error1.phpt56
-rw-r--r--ext/spl/tests/arrayObject_uasort_basic1.phpt44
-rw-r--r--ext/spl/tests/arrayObject_uasort_error1.phpt30
-rw-r--r--ext/spl/tests/arrayObject_uksort_basic1.phpt47
-rw-r--r--ext/spl/tests/arrayObject_uksort_error1.phpt30
-rw-r--r--ext/spl/tests/array_001.phpt113
-rw-r--r--ext/spl/tests/array_002.phpt41
-rw-r--r--ext/spl/tests/array_003.phpt63
-rw-r--r--ext/spl/tests/array_004.phpt30
-rw-r--r--ext/spl/tests/array_005.phpt91
-rw-r--r--ext/spl/tests/array_006.phpt30
-rw-r--r--ext/spl/tests/array_007.phpt71
-rw-r--r--ext/spl/tests/array_008.phpt31
-rw-r--r--ext/spl/tests/array_009.phpt24
-rw-r--r--ext/spl/tests/array_009a.phpt37
-rw-r--r--ext/spl/tests/array_010.phpt144
-rw-r--r--ext/spl/tests/array_011.phpt35
-rw-r--r--ext/spl/tests/array_012.phpt63
-rw-r--r--ext/spl/tests/array_013.phpt79
-rw-r--r--ext/spl/tests/array_014.phpt59
-rw-r--r--ext/spl/tests/array_015.phpt97
-rw-r--r--ext/spl/tests/array_016.phpt32
-rw-r--r--ext/spl/tests/array_017.phpt817
-rw-r--r--ext/spl/tests/array_018.phptbin0 -> 633 bytes
-rw-r--r--ext/spl/tests/array_019.phpt30
-rw-r--r--ext/spl/tests/array_020.phpt64
-rw-r--r--ext/spl/tests/array_021.phpt31
-rw-r--r--ext/spl/tests/array_022.phpt80
-rw-r--r--ext/spl/tests/array_023.phpt87
-rw-r--r--ext/spl/tests/array_024.phpt17
-rw-r--r--ext/spl/tests/array_025.phpt40
-rw-r--r--ext/spl/tests/array_026.phpt24
-rw-r--r--ext/spl/tests/array_027.phpt18
-rw-r--r--ext/spl/tests/bug28822.phpt16
-rw-r--r--ext/spl/tests/bug31185.phpt61
-rw-r--r--ext/spl/tests/bug31346.phpt19
-rw-r--r--ext/spl/tests/bug31348.phpt15
-rw-r--r--ext/spl/tests/bug31926.phpt16
-rw-r--r--ext/spl/tests/bug32134.phpt48
-rw-r--r--ext/spl/tests/bug32394.phpt17
-rw-r--r--ext/spl/tests/bug33136.phpt80
-rw-r--r--ext/spl/tests/bug34548.phpt38
-rw-r--r--ext/spl/tests/bug36258.phpt19
-rw-r--r--ext/spl/tests/bug36287.phpt32
-rw-r--r--ext/spl/tests/bug36825.phpt31
-rw-r--r--ext/spl/tests/bug36941.phpt46
-rw-r--r--ext/spl/tests/bug37457.phpt80
-rw-r--r--ext/spl/tests/bug38325.phpt9
-rw-r--r--ext/spl/tests/bug38618.phpt105
-rw-r--r--ext/spl/tests/bug40036.phpt32
-rw-r--r--ext/spl/tests/bug40091.phpt43
-rw-r--r--ext/spl/tests/bug40442.phpt12
-rw-r--r--ext/spl/tests/bug40872.phpt30
-rw-r--r--ext/spl/tests/bug41528.phpt37
-rw-r--r--ext/spl/tests/bug41691.phpt29
-rw-r--r--ext/spl/tests/bug41692.phpt64
-rw-r--r--ext/spl/tests/bug41828.phpt21
-rw-r--r--ext/spl/tests/bug42364.phpt24
-rw-r--r--ext/spl/tests/bug42654.phpt158
-rw-r--r--ext/spl/tests/bug42703.phpt41
-rw-r--r--ext/spl/tests/bug44144.phpt27
-rw-r--r--ext/spl/tests/bug44615.phpt32
-rw-r--r--ext/spl/tests/bug45216.phpt22
-rw-r--r--ext/spl/tests/bug45614.phpt56
-rw-r--r--ext/spl/tests/bug45622.phpt51
-rw-r--r--ext/spl/tests/bug45622b.phpt33
-rw-r--r--ext/spl/tests/bug45826.phpt88
-rw-r--r--ext/spl/tests/bug46031.phpt9
-rw-r--r--ext/spl/tests/bug46051.phpt14
-rw-r--r--ext/spl/tests/bug46053.phpt12
-rw-r--r--ext/spl/tests/bug46088.phpt11
-rw-r--r--ext/spl/tests/bug46115.phpt11
-rw-r--r--ext/spl/tests/bug46160.phpt14
-rw-r--r--ext/spl/tests/bug47534.phpt14
-rw-r--r--ext/spl/tests/bug48023.phpt12
-rw-r--r--ext/spl/tests/bug48361.phpt14
-rw-r--r--ext/spl/tests/bug48493.phpt26
-rw-r--r--ext/spl/tests/bug49263.phpt54
-rw-r--r--ext/spl/tests/bug49723.phpt16
-rw-r--r--ext/spl/tests/bug49972.phpt11
-rw-r--r--ext/spl/tests/bug50579.phpt40
-rw-r--r--ext/spl/tests/bug51119.phpt34
-rw-r--r--ext/spl/tests/bug51374.phpt19
-rw-r--r--ext/spl/tests/bug51532.phpt14
-rw-r--r--ext/spl/tests/bug52238.phpt24
-rw-r--r--ext/spl/tests/bug52573.phpt18
-rw-r--r--ext/spl/tests/bug52861.phpt22
-rw-r--r--ext/spl/tests/bug53071.phpt27
-rw-r--r--ext/spl/tests/bug53144.phpt20
-rw-r--r--ext/spl/tests/bug53362.phpt22
-rw-r--r--ext/spl/tests/bug53515.phpt27
-rw-r--r--ext/spl/tests/bug54281.phpt15
-rw-r--r--ext/spl/tests/bug54291.phpt13
-rw-r--r--ext/spl/tests/bug54292.phpt14
-rw-r--r--ext/spl/tests/bug54304.phpt26
-rw-r--r--ext/spl/tests/bug54323.phpt24
-rw-r--r--ext/spl/tests/bug54384.phpt171
-rw-r--r--ext/spl/tests/bug54970.phpt33
-rw-r--r--ext/spl/tests/bug54971.phpt37
-rw-r--r--ext/spl/tests/bug60201.phpt30
-rw-r--r--ext/spl/tests/bug61326.phpt17
-rw-r--r--ext/spl/tests/bug61347.phpt40
-rw-r--r--ext/spl/tests/bug61418.phpt23
-rw-r--r--ext/spl/tests/bug61453.phpt19
-rw-r--r--ext/spl/tests/bug61527.phpt92
-rw-r--r--ext/spl/tests/bug62073.phpt22
-rw-r--r--ext/spl/tests/bug62262.phpt10
-rw-r--r--ext/spl/tests/bug62328.phpt24
-rw-r--r--ext/spl/tests/bug62433.phpt18
-rw-r--r--ext/spl/tests/bug62616.phpt15
-rw-r--r--ext/spl/tests/bug62904.phpt19
-rw-r--r--ext/spl/tests/bug62978.phpt50
-rw-r--r--ext/spl/tests/bug63680.phpt16
-rw-r--r--ext/spl/tests/bug64023.phpt20
-rw-r--r--ext/spl/tests/bug64106.phpt15
-rw-r--r--ext/spl/tests/bug64228.phpt25
-rw-r--r--ext/spl/tests/bug64264.phpt29
-rw-r--r--ext/spl/tests/class_implements_basic.phpt33
-rw-r--r--ext/spl/tests/class_implements_basic2.phpt74
-rw-r--r--ext/spl/tests/class_implements_variation.phpt45
-rw-r--r--ext/spl/tests/class_implements_variation1.phpt221
-rw-r--r--ext/spl/tests/class_implements_variation2.phpt259
-rw-r--r--ext/spl/tests/class_uses_basic.phpt33
-rw-r--r--ext/spl/tests/class_uses_basic2.phpt69
-rw-r--r--ext/spl/tests/class_uses_variation.phpt45
-rw-r--r--ext/spl/tests/class_uses_variation1.phpt221
-rw-r--r--ext/spl/tests/class_uses_variation2.phpt261
-rw-r--r--ext/spl/tests/countable_class_basic1.phpt37
-rw-r--r--ext/spl/tests/countable_count_variation1.phpt68
-rw-r--r--ext/spl/tests/dit_001.phpt28
-rw-r--r--ext/spl/tests/dit_001_noglob.phpt27
-rw-r--r--ext/spl/tests/dit_002.phpt77
-rw-r--r--ext/spl/tests/dit_003.phpt15
-rw-r--r--ext/spl/tests/dit_004.phpt24
-rw-r--r--ext/spl/tests/dit_005.phpt22
-rw-r--r--ext/spl/tests/dit_006.phpt50
-rw-r--r--ext/spl/tests/dllist_001.phpt63
-rw-r--r--ext/spl/tests/dllist_002.phpt60
-rw-r--r--ext/spl/tests/dllist_003.phpt43
-rw-r--r--ext/spl/tests/dllist_004.phpt61
-rw-r--r--ext/spl/tests/dllist_005.phpt61
-rw-r--r--ext/spl/tests/dllist_006.phpt62
-rw-r--r--ext/spl/tests/dllist_007.phpt24
-rw-r--r--ext/spl/tests/dllist_008.phpt21
-rw-r--r--ext/spl/tests/dllist_010.phpt33
-rw-r--r--ext/spl/tests/dllist_011.phpt13
-rw-r--r--ext/spl/tests/dllist_012.phpt21
-rw-r--r--ext/spl/tests/dllist_memleak.phpt24
-rw-r--r--ext/spl/tests/fileobject_001.phpt88
-rwxr-xr-xext/spl/tests/fileobject_001a.txt6
-rwxr-xr-xext/spl/tests/fileobject_001b.txt6
-rw-r--r--ext/spl/tests/fileobject_002.phpt122
-rw-r--r--ext/spl/tests/fileobject_003.phpt114
-rw-r--r--ext/spl/tests/fileobject_004.phpt22
-rw-r--r--ext/spl/tests/fileobject_005.phpt42
-rw-r--r--ext/spl/tests/fileobject_checktype_basic.phpt16
-rw-r--r--ext/spl/tests/fileobject_getbasename_basic.phpt13
-rw-r--r--ext/spl/tests/fileobject_getcurrentline_basic.phpt19
-rw-r--r--ext/spl/tests/fileobject_getfileinfo_basic.phpt44
-rw-r--r--ext/spl/tests/fileobject_getmaxlinelen_basic.phpt15
-rw-r--r--ext/spl/tests/fileobject_getmaxlinelen_error001.phpt14
-rw-r--r--ext/spl/tests/fileobject_getsize_basic.phpt22
-rw-r--r--ext/spl/tests/fileobject_setmaxlinelen_basic.phpt15
-rw-r--r--ext/spl/tests/fileobject_setmaxlinelen_error001.phpt17
-rw-r--r--ext/spl/tests/fileobject_setmaxlinelen_error002.phpt12
-rw-r--r--ext/spl/tests/fileobject_setmaxlinelen_error003.phpt12
-rw-r--r--ext/spl/tests/filesystemiterator_flags.phpt40
-rw-r--r--ext/spl/tests/fixedarray_001.phpt60
-rw-r--r--ext/spl/tests/fixedarray_002.phpt100
-rw-r--r--ext/spl/tests/fixedarray_003.phpt86
-rw-r--r--ext/spl/tests/fixedarray_004.phpt18
-rw-r--r--ext/spl/tests/fixedarray_005.phpt12
-rw-r--r--ext/spl/tests/fixedarray_006.phpt22
-rw-r--r--ext/spl/tests/fixedarray_007.phpt26
-rw-r--r--ext/spl/tests/fixedarray_008.phpt30
-rw-r--r--ext/spl/tests/fixedarray_009.phpt10
-rw-r--r--ext/spl/tests/fixedarray_010.phpt50
-rw-r--r--ext/spl/tests/fixedarray_011.phpt14
-rw-r--r--ext/spl/tests/fixedarray_012.phpt19
-rw-r--r--ext/spl/tests/fixedarray_013.phpt21
-rw-r--r--ext/spl/tests/fixedarray_014.phpt15
-rw-r--r--ext/spl/tests/fixedarray_015.phpt49
-rw-r--r--ext/spl/tests/fixedarray_016.phpt17
-rw-r--r--ext/spl/tests/fixedarray_017.phpt17
-rw-r--r--ext/spl/tests/fixedarray_018.phpt17
-rw-r--r--ext/spl/tests/fixedarray_019.phpt51
-rw-r--r--ext/spl/tests/fixedarray_020.phpt36
-rw-r--r--ext/spl/tests/fixedarray_021.phpt78
-rw-r--r--ext/spl/tests/heap_001.phpt53
-rw-r--r--ext/spl/tests/heap_002.phpt50
-rw-r--r--ext/spl/tests/heap_003.phpt44
-rw-r--r--ext/spl/tests/heap_004.phpt67
-rw-r--r--ext/spl/tests/heap_005.phpt121
-rw-r--r--ext/spl/tests/heap_006.phpt121
-rw-r--r--ext/spl/tests/heap_007.phpt32
-rw-r--r--ext/spl/tests/heap_008.phpt34
-rw-r--r--ext/spl/tests/heap_009.phpt56
-rw-r--r--ext/spl/tests/heap_010.phpt21
-rw-r--r--ext/spl/tests/heap_011.phpt31
-rw-r--r--ext/spl/tests/heap_012.phpt22
-rw-r--r--ext/spl/tests/heap_corruption.phpt62
-rw-r--r--ext/spl/tests/heap_current_variation_001.phpt22
-rw-r--r--ext/spl/tests/heap_isempty_variation_001.phpt16
-rw-r--r--ext/spl/tests/heap_it_current_empty.phpt12
-rw-r--r--ext/spl/tests/heap_top_variation_001.phpt14
-rw-r--r--ext/spl/tests/heap_top_variation_002.phpt31
-rw-r--r--ext/spl/tests/heap_top_variation_003.phpt16
-rw-r--r--ext/spl/tests/iterator_001.phpt171
-rw-r--r--ext/spl/tests/iterator_002.phpt55
-rw-r--r--ext/spl/tests/iterator_003.phpt95
-rw-r--r--ext/spl/tests/iterator_004.phpt142
-rw-r--r--ext/spl/tests/iterator_005.phpt52
-rw-r--r--ext/spl/tests/iterator_006.phpt24
-rw-r--r--ext/spl/tests/iterator_007.phpt166
-rw-r--r--ext/spl/tests/iterator_008.phpt89
-rw-r--r--ext/spl/tests/iterator_009.phpt45
-rw-r--r--ext/spl/tests/iterator_010.phpt18
-rw-r--r--ext/spl/tests/iterator_011.phpt51
-rw-r--r--ext/spl/tests/iterator_012.phpt33
-rw-r--r--ext/spl/tests/iterator_013.phpt66
-rw-r--r--ext/spl/tests/iterator_014.phpt138
-rw-r--r--ext/spl/tests/iterator_015.phpt62
-rw-r--r--ext/spl/tests/iterator_016.phpt76
-rw-r--r--ext/spl/tests/iterator_017.phpt18
-rw-r--r--ext/spl/tests/iterator_018.phpt51
-rw-r--r--ext/spl/tests/iterator_019.phpt33
-rw-r--r--ext/spl/tests/iterator_020.phpt66
-rw-r--r--ext/spl/tests/iterator_021.phpt180
-rw-r--r--ext/spl/tests/iterator_022.phpt186
-rw-r--r--ext/spl/tests/iterator_023.phpt193
-rw-r--r--ext/spl/tests/iterator_024.phpt49
-rw-r--r--ext/spl/tests/iterator_025.phpt92
-rw-r--r--ext/spl/tests/iterator_026.phpt38
-rw-r--r--ext/spl/tests/iterator_027.phpt83
-rw-r--r--ext/spl/tests/iterator_028.phpt112
-rw-r--r--ext/spl/tests/iterator_029.phpt38
-rw-r--r--ext/spl/tests/iterator_030.phpt44
-rw-r--r--ext/spl/tests/iterator_031.phpt116
-rw-r--r--ext/spl/tests/iterator_032.phpt50
-rw-r--r--ext/spl/tests/iterator_033.phpt44
-rw-r--r--ext/spl/tests/iterator_034.phpt188
-rw-r--r--ext/spl/tests/iterator_035.phpt15
-rw-r--r--ext/spl/tests/iterator_036.phpt22
-rw-r--r--ext/spl/tests/iterator_037.phpt131
-rw-r--r--ext/spl/tests/iterator_038.phpt19
-rw-r--r--ext/spl/tests/iterator_039.phpt121
-rw-r--r--ext/spl/tests/iterator_040.phpt47
-rw-r--r--ext/spl/tests/iterator_041.phpt117
-rw-r--r--ext/spl/tests/iterator_041a.phpt107
-rw-r--r--ext/spl/tests/iterator_041b.phpt123
-rw-r--r--ext/spl/tests/iterator_042.phpt123
-rw-r--r--ext/spl/tests/iterator_043.phpt18
-rw-r--r--ext/spl/tests/iterator_044.phpt165
-rw-r--r--ext/spl/tests/iterator_045.phpt169
-rw-r--r--ext/spl/tests/iterator_046.phpt51
-rw-r--r--ext/spl/tests/iterator_047.phpt125
-rw-r--r--ext/spl/tests/iterator_048.phpt36
-rw-r--r--ext/spl/tests/iterator_049.phpt25
-rw-r--r--ext/spl/tests/iterator_049b.phptbin0 -> 633 bytes
-rw-r--r--ext/spl/tests/iterator_050.phpt98
-rw-r--r--ext/spl/tests/iterator_051.phpt96
-rw-r--r--ext/spl/tests/iterator_052.phpt319
-rw-r--r--ext/spl/tests/iterator_053.phpt315
-rw-r--r--ext/spl/tests/iterator_054.phpt87
-rw-r--r--ext/spl/tests/iterator_055.phpt62
-rw-r--r--ext/spl/tests/iterator_056.phpt19
-rw-r--r--ext/spl/tests/iterator_057.phpt21
-rw-r--r--ext/spl/tests/iterator_058.phpt24
-rw-r--r--ext/spl/tests/iterator_059.phpt17
-rw-r--r--ext/spl/tests/iterator_060.phpt17
-rw-r--r--ext/spl/tests/iterator_061.phpt17
-rw-r--r--ext/spl/tests/iterator_062.phpt18
-rw-r--r--ext/spl/tests/iterator_063.phpt17
-rw-r--r--ext/spl/tests/iterator_064.phpt15
-rw-r--r--ext/spl/tests/iterator_065.phpt15
-rw-r--r--ext/spl/tests/iterator_066.phpt15
-rw-r--r--ext/spl/tests/iterator_067.phpt16
-rw-r--r--ext/spl/tests/iterator_068.phpt34
-rw-r--r--ext/spl/tests/iterator_069.phpt17
-rw-r--r--ext/spl/tests/iterator_070.phpt20
-rw-r--r--ext/spl/tests/iterator_071.phpt32
-rw-r--r--ext/spl/tests/iterator_count.phpt26
-rw-r--r--ext/spl/tests/iterator_to_array.phpt25
-rw-r--r--ext/spl/tests/limititerator_seek.phpt18
-rw-r--r--ext/spl/tests/multiple_iterator_001.phpt345
-rw-r--r--ext/spl/tests/observer_001.phpt116
-rw-r--r--ext/spl/tests/observer_002.phpt199
-rw-r--r--ext/spl/tests/observer_003.phpt58
-rw-r--r--ext/spl/tests/observer_004.phpt122
-rw-r--r--ext/spl/tests/observer_005.phpt212
-rw-r--r--ext/spl/tests/observer_006.phpt310
-rw-r--r--ext/spl/tests/observer_007.phpt22
-rw-r--r--ext/spl/tests/observer_008.phpt35
-rw-r--r--ext/spl/tests/observer_009.phpt30
-rw-r--r--ext/spl/tests/pqueue_001.phpt96
-rw-r--r--ext/spl/tests/pqueue_002.phpt67
-rw-r--r--ext/spl/tests/pqueue_003.phpt31
-rw-r--r--ext/spl/tests/pqueue_004.phpt54
-rw-r--r--ext/spl/tests/pqueue_compare_basic.phpt19
-rw-r--r--ext/spl/tests/pqueue_compare_error.phpt19
-rw-r--r--ext/spl/tests/pqueue_current_error.phpt12
-rw-r--r--ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt36
-rw-r--r--ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt36
-rw-r--r--ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt42
-rw-r--r--ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt36
-rw-r--r--ext/spl/tests/recursive_tree_iterator_001.phpt102
-rw-r--r--ext/spl/tests/recursive_tree_iterator_002.phpt16
-rw-r--r--ext/spl/tests/recursive_tree_iterator_003.phpt16
-rw-r--r--ext/spl/tests/recursive_tree_iterator_004.phpt43
-rw-r--r--ext/spl/tests/recursive_tree_iterator_005.phpt116
-rw-r--r--ext/spl/tests/recursive_tree_iterator_006.phpt112
-rw-r--r--ext/spl/tests/recursive_tree_iterator_007.phpt33
-rw-r--r--ext/spl/tests/recursive_tree_iterator_008.phpt41
-rw-r--r--ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt32
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_beginiteration_basic.phpt32
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_enditeration_basic.phpt32
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_getsubiterator_basic.phpt20
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt15
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation.phpt42
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_002.phpt20
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_003.phpt42
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_nextelement_basic.phpt39
-rw-r--r--ext/spl/tests/regexIterator_flags_basic.phpt24
-rw-r--r--ext/spl/tests/regexIterator_mode_basic.phpt32
-rw-r--r--ext/spl/tests/regexIterator_setMode_error.phpt28
-rw-r--r--ext/spl/tests/regexiterator_getpregflags.phpt33
-rw-r--r--ext/spl/tests/regexiterator_getregex.phpt29
-rw-r--r--ext/spl/tests/regexiterator_setflags_exception.phpt35
-rw-r--r--ext/spl/tests/regexiterator_setpregflags.phpt34
-rw-r--r--ext/spl/tests/regexiterator_setpregflags_exception.phpt36
-rw-r--r--ext/spl/tests/splDoublyLinkedList_shift_noParams.phpt15
-rw-r--r--ext/spl/tests/spl_001.phpt34
-rw-r--r--ext/spl/tests/spl_002.phpt22
-rw-r--r--ext/spl/tests/spl_003.phpt74
-rw-r--r--ext/spl/tests/spl_004.phpt84
-rw-r--r--ext/spl/tests/spl_005.phpt21
-rw-r--r--ext/spl/tests/spl_006.phpt39
-rw-r--r--ext/spl/tests/spl_007.phpt24
-rw-r--r--ext/spl/tests/spl_autoload_001.phpt136
-rw-r--r--ext/spl/tests/spl_autoload_002.phpt70
-rw-r--r--ext/spl/tests/spl_autoload_003.phpt45
-rw-r--r--ext/spl/tests/spl_autoload_004.phpt43
-rw-r--r--ext/spl/tests/spl_autoload_005.phpt55
-rw-r--r--ext/spl/tests/spl_autoload_006.phpt37
-rw-r--r--ext/spl/tests/spl_autoload_007.phpt138
-rw-r--r--ext/spl/tests/spl_autoload_008.phpt129
-rw-r--r--ext/spl/tests/spl_autoload_009.phpt26
-rw-r--r--ext/spl/tests/spl_autoload_010.phpt30
-rw-r--r--ext/spl/tests/spl_autoload_011.phpt31
-rw-r--r--ext/spl/tests/spl_autoload_012.phpt65
-rw-r--r--ext/spl/tests/spl_autoload_013.phpt51
-rw-r--r--ext/spl/tests/spl_autoload_014.phpt47
-rw-r--r--ext/spl/tests/spl_autoload_bug48541.phpt39
-rw-r--r--ext/spl/tests/spl_autoload_call_basic.phpt18
-rw-r--r--ext/spl/tests/spl_caching_iterator_constructor_flags.phpt25
-rw-r--r--ext/spl/tests/spl_cachingiterator___toString_basic.phpt16
-rw-r--r--ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt16
-rw-r--r--ext/spl/tests/spl_classes.phpt13
-rw-r--r--ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt22
-rw-r--r--ext/spl/tests/spl_heap_count_basic.phpt35
-rw-r--r--ext/spl/tests/spl_heap_count_error.phpt12
-rw-r--r--ext/spl/tests/spl_heap_extract_parameter_error.phpt27
-rw-r--r--ext/spl/tests/spl_heap_insert_basic.phpt20
-rw-r--r--ext/spl/tests/spl_heap_is_empty_basic.phpt31
-rw-r--r--ext/spl/tests/spl_heap_isempty.phpt21
-rw-r--r--ext/spl/tests/spl_heap_iteration_error.phpt53
-rw-r--r--ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt15
-rw-r--r--ext/spl/tests/spl_iterator_apply_error.phpt26
-rw-r--r--ext/spl/tests/spl_iterator_apply_error_001.phpt20
-rw-r--r--ext/spl/tests/spl_iterator_caching_count_basic.phpt21
-rw-r--r--ext/spl/tests/spl_iterator_caching_count_error.phpt21
-rw-r--r--ext/spl/tests/spl_iterator_caching_getcache_error.phpt21
-rw-r--r--ext/spl/tests/spl_iterator_getcallchildren.phpt39
-rw-r--r--ext/spl/tests/spl_iterator_iterator_constructor.phpt30
-rw-r--r--ext/spl/tests/spl_iterator_recursive_getiterator_error.phpt16
-rw-r--r--ext/spl/tests/spl_iterator_to_array_basic.phpt13
-rw-r--r--ext/spl/tests/spl_iterator_to_array_error.phpt33
-rw-r--r--ext/spl/tests/spl_limit_iterator_check_limits.phpt37
-rw-r--r--ext/spl/tests/spl_maxheap_compare_basic.phpt22
-rw-r--r--ext/spl/tests/spl_minheap_compare_error.phpt31
-rw-r--r--ext/spl/tests/spl_pq_top_basic.phpt42
-rw-r--r--ext/spl/tests/spl_pq_top_error_args.phpt12
-rw-r--r--ext/spl/tests/spl_pq_top_error_corrupt.phpt38
-rw-r--r--ext/spl/tests/spl_pq_top_error_empty.phpt19
-rw-r--r--ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt31
-rw-r--r--ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt28
-rw-r--r--ext/spl/tests/spl_recursive_iterator_iterator_key_case.phpt33
-rw-r--r--ext/spl/tests/splfixedarray_offsetExists_larger.phpt15
-rw-r--r--ext/spl/tests/splpriorityqueue_extract.phpt19
-rw-r--r--ext/spl/tests/splpriorityqueue_setextractflags.phpt17
-rwxr-xr-xext/spl/tests/testclass5
-rw-r--r--ext/spl/tests/testclass.class.inc9
-rw-r--r--ext/spl/tests/testclass.inc5
-rw-r--r--ext/spl/tests/testclass.php.inc5
623 files changed, 33830 insertions, 0 deletions
diff --git a/ext/spl/tests/ArrayObject_unserialize_empty_string.phpt b/ext/spl/tests/ArrayObject_unserialize_empty_string.phpt
new file mode 100644
index 0000000..75d8a41
--- /dev/null
+++ b/ext/spl/tests/ArrayObject_unserialize_empty_string.phpt
@@ -0,0 +1,16 @@
+--TEST--
+ArrayObject: test that you cannot unserialize a empty string
+--CREDITS--
+Havard Eide <nucleuz@gmail.com>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--FILE--
+<?php
+$a = new ArrayObject(array());
+$a->unserialize("");
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Empty serialized string cannot be empty' in %s.php:%d
+Stack trace:
+#0 %s(%d): ArrayObject->unserialize('')
+#1 {main}
+ thrown in %s.php on line %d
diff --git a/ext/spl/tests/CallbackFilterIteratorTest-002.phpt b/ext/spl/tests/CallbackFilterIteratorTest-002.phpt
new file mode 100644
index 0000000..cbad2e3
--- /dev/null
+++ b/ext/spl/tests/CallbackFilterIteratorTest-002.phpt
@@ -0,0 +1,50 @@
+--TEST--
+CallbackFilterIterator 002
+--FILE--
+<?php
+
+set_error_handler(function($errno, $errstr){
+ echo $errstr . "\n";
+ return true;
+});
+
+try {
+ new CallbackFilterIterator();
+} catch(InvalidArgumentException $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ new CallbackFilterIterator(null);
+} catch(InvalidArgumentException $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ new CallbackFilterIterator(new ArrayIterator(array()), null);
+} catch(InvalidArgumentException $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ new CallbackFilterIterator(new ArrayIterator(array()), array());
+} catch(InvalidArgumentException $e) {
+ echo $e->getMessage() . "\n";
+}
+
+$it = new CallbackFilterIterator(new ArrayIterator(array(1)), function() {
+ throw new Exception("some message");
+});
+try {
+ foreach($it as $e);
+} catch(Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+--EXPECT--
+CallbackFilterIterator::__construct() expects exactly 2 parameters, 0 given
+Argument 1 passed to CallbackFilterIterator::__construct() must implement interface Iterator, null given
+CallbackFilterIterator::__construct() expects exactly 2 parameters, 1 given
+CallbackFilterIterator::__construct() expects parameter 2 to be a valid callback, no array or string given
+CallbackFilterIterator::__construct() expects parameter 2 to be a valid callback, array must have exactly two members
+some message
diff --git a/ext/spl/tests/CallbackFilterIteratorTest.phpt b/ext/spl/tests/CallbackFilterIteratorTest.phpt
new file mode 100644
index 0000000..36bc770
--- /dev/null
+++ b/ext/spl/tests/CallbackFilterIteratorTest.phpt
@@ -0,0 +1,133 @@
+--TEST--
+CallbackFilterIterator
+--FILE--
+<?php
+
+class A {
+ function test($value, $key, $inner) {
+ return test($value, $key, $inner);
+ }
+}
+
+class B {
+ static function test($value, $key, $inner) {
+ return test($value, $key, $inner);
+ }
+}
+
+function test($value, $key, $inner) {
+ printf("%s / %s / %d / %d\n"
+ , $value
+ , $key
+ , $value == $inner->current()
+ , $key == $inner->key()
+ );
+ return $value === 1 || $value === 4;
+}
+
+$tests = array(
+ 'instance method' => function() { return array(new A, 'test'); },
+ 'static method' => function() { return array('B', 'test'); },
+ 'static method (2)' => function() { return 'B::test'; },
+ 'function' => function() { return 'test'; },
+ 'anonymous function' => function() { return function($value, $key, $inner) { return test($value, $key, $inner); }; },
+);
+
+foreach($tests as $name => $test) {
+
+ $callback = $test();
+ $it = new ArrayIterator(range(1, 5));
+ $it = new CallbackFilterIterator($it, $callback);
+
+ echo " = $name =\n";
+
+ foreach($it as $value) {
+ echo "=> $value\n";
+ }
+
+ // same test, with no reference to callback
+
+ $it = new ArrayIterator(range(1, 5));
+ $it = new CallbackFilterIterator($it, $test());
+ unset($callback);
+
+ foreach($it as $value) {
+ echo "=> $value\n";
+ }
+}
+--EXPECT--
+= instance method =
+1 / 0 / 1 / 1
+=> 1
+2 / 1 / 1 / 1
+3 / 2 / 1 / 1
+4 / 3 / 1 / 1
+=> 4
+5 / 4 / 1 / 1
+1 / 0 / 1 / 1
+=> 1
+2 / 1 / 1 / 1
+3 / 2 / 1 / 1
+4 / 3 / 1 / 1
+=> 4
+5 / 4 / 1 / 1
+ = static method =
+1 / 0 / 1 / 1
+=> 1
+2 / 1 / 1 / 1
+3 / 2 / 1 / 1
+4 / 3 / 1 / 1
+=> 4
+5 / 4 / 1 / 1
+1 / 0 / 1 / 1
+=> 1
+2 / 1 / 1 / 1
+3 / 2 / 1 / 1
+4 / 3 / 1 / 1
+=> 4
+5 / 4 / 1 / 1
+ = static method (2) =
+1 / 0 / 1 / 1
+=> 1
+2 / 1 / 1 / 1
+3 / 2 / 1 / 1
+4 / 3 / 1 / 1
+=> 4
+5 / 4 / 1 / 1
+1 / 0 / 1 / 1
+=> 1
+2 / 1 / 1 / 1
+3 / 2 / 1 / 1
+4 / 3 / 1 / 1
+=> 4
+5 / 4 / 1 / 1
+ = function =
+1 / 0 / 1 / 1
+=> 1
+2 / 1 / 1 / 1
+3 / 2 / 1 / 1
+4 / 3 / 1 / 1
+=> 4
+5 / 4 / 1 / 1
+1 / 0 / 1 / 1
+=> 1
+2 / 1 / 1 / 1
+3 / 2 / 1 / 1
+4 / 3 / 1 / 1
+=> 4
+5 / 4 / 1 / 1
+ = anonymous function =
+1 / 0 / 1 / 1
+=> 1
+2 / 1 / 1 / 1
+3 / 2 / 1 / 1
+4 / 3 / 1 / 1
+=> 4
+5 / 4 / 1 / 1
+1 / 0 / 1 / 1
+=> 1
+2 / 1 / 1 / 1
+3 / 2 / 1 / 1
+4 / 3 / 1 / 1
+=> 4
+5 / 4 / 1 / 1
diff --git a/ext/spl/tests/DirectoryIterator_by_reference.phpt b/ext/spl/tests/DirectoryIterator_by_reference.phpt
new file mode 100644
index 0000000..06127ec
--- /dev/null
+++ b/ext/spl/tests/DirectoryIterator_by_reference.phpt
@@ -0,0 +1,14 @@
+--TEST--
+DirectoryIterator: test that you cannot use iterator with reference
+--CREDITS--
+Havard Eide <nucleuz@gmail.com>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--FILE--
+<?php
+$it = new DirectoryIterator(__DIR__);
+foreach( $it as &$file ) {
+ echo $file . "\n";
+}
+?>
+--EXPECTF--
+Fatal error: An iterator cannot be used with foreach by reference in %s on line %d
diff --git a/ext/spl/tests/DirectoryIterator_empty_constructor.phpt b/ext/spl/tests/DirectoryIterator_empty_constructor.phpt
new file mode 100644
index 0000000..da5276c
--- /dev/null
+++ b/ext/spl/tests/DirectoryIterator_empty_constructor.phpt
@@ -0,0 +1,15 @@
+--TEST--
+DirectoryIterator: Test empty value to DirectoryIterator constructor
+--CREDITS--
+Havard Eide <nucleuz@gmail.com>
+#PHPTestFest2009 Norway 2009-06-09 \o/
+--FILE--
+<?php
+$it = new DirectoryIterator("");
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'RuntimeException' with message 'Directory name must not be empty.' in %s:%d
+Stack trace:
+#0 %s(%d): DirectoryIterator->__construct('')
+#1 {main}
+ thrown in %s on line %d \ No newline at end of file
diff --git a/ext/spl/tests/DirectoryIterator_getBasename_basic_test.phpt b/ext/spl/tests/DirectoryIterator_getBasename_basic_test.phpt
new file mode 100644
index 0000000..ed1f473
--- /dev/null
+++ b/ext/spl/tests/DirectoryIterator_getBasename_basic_test.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DirectoryIterator::getBasename() - Basic Test
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+ $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename');
+ mkdir($targetDir);
+ touch($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt');
+ $dir = new DirectoryIterator($targetDir.DIRECTORY_SEPARATOR);
+ while(!$dir->isFile()) {
+ $dir->next();
+ }
+ echo $dir->getBasename('.txt');
+?>
+--CLEAN--
+<?php
+ $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename');
+ unlink($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt');
+ rmdir($targetDir);
+?>
+--EXPECTF--
+getBasename_test
diff --git a/ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt b/ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt
new file mode 100644
index 0000000..b2df8a5
--- /dev/null
+++ b/ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DirectoryIterator::getBasename() - Pass unexpected array
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+ $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename');
+ mkdir($targetDir);
+ touch($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt');
+ $dir = new DirectoryIterator($targetDir.DIRECTORY_SEPARATOR);
+ while(!$dir->isFile()) {
+ $dir->next();
+ }
+ echo $dir->getBasename(array());
+?>
+--CLEAN--
+<?php
+ $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename');
+ unlink($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt');
+ rmdir($targetDir);
+?>
+--EXPECTF--
+Warning: DirectoryIterator::getBasename() expects parameter 1 to be %binary_string_optional%, array given in %s on line %d
diff --git a/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt b/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
new file mode 100644
index 0000000..7398d4b
--- /dev/null
+++ b/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
@@ -0,0 +1,57 @@
+--TEST--
+SPL: DirectoryIterator::getExtension() basic test
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Unix');
+}
+?>
+--FILE--
+<?php
+$dir = __DIR__ . DIRECTORY_SEPARATOR . md5('DirectoryIterator::getExtension') . DIRECTORY_SEPARATOR;
+mkdir($dir);
+
+$files = array('test.txt', 'test.extension', 'test..', 'test.', 'test');
+foreach ($files as $file) {
+ touch($dir . $file);
+}
+
+$dit_exts = array();
+$nfo_exts = array();
+$skip = array('.', '..');
+
+foreach (new DirectoryIterator($dir) as $file) {
+ if (in_array($file->getFilename(), $skip)) {
+ continue;
+ }
+ $dit_exts[] = $file->getExtension();
+ $nfo_exts[] = pathinfo($file->getFilename(), PATHINFO_EXTENSION);
+}
+var_dump($dit_exts === $nfo_exts);
+sort($dit_exts);
+var_dump($dit_exts);
+?>
+--CLEAN--
+<?php
+$dir = __DIR__ . DIRECTORY_SEPARATOR . md5('DirectoryIterator::getExtension') . DIRECTORY_SEPARATOR;
+$files = array('test.txt', 'test.extension', 'test..', 'test.', 'test');
+foreach ($files as $file) {
+ unlink($dir . $file);
+}
+rmdir($dir);
+?>
+--EXPECTF--
+bool(true)
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(9) "extension"
+ [4]=>
+ string(3) "txt"
+}
+
diff --git a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
new file mode 100644
index 0000000..0c75bf4
--- /dev/null
+++ b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
@@ -0,0 +1,29 @@
+--TEST--
+SPL: DirectoryIterator test getGroup
+--SKIPIF--
+<?php
+if (posix_geteuid() == 0) die('SKIP Cannot run test as root.');
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--FILE--
+<?php
+$dirname = 'DirectoryIterator_getGroup_basic';
+mkdir($dirname);
+$dir = new DirectoryIterator($dirname);
+$expected = filegroup($dirname);
+$actual = $dir->getGroup();
+var_dump($expected == $actual);
+?>
+--CLEAN--
+<?php
+$dirname = 'DirectoryIterator_getGroup_basic';
+rmdir($dirname);
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/spl/tests/DirectoryIterator_getInode_basic.phpt b/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
new file mode 100644
index 0000000..4fd7e8d
--- /dev/null
+++ b/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
@@ -0,0 +1,29 @@
+--TEST--
+SPL: Spl Directory Iterator test getInode
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+
+//file
+mkdir('test_dir_ptfi');
+$dirIterator = new DirectoryIterator('test_dir_ptfi');
+var_dump(decoct($dirIterator->getInode()));
+
+?>
+--CLEAN--
+<?php
+rmdir('test_dir_ptfi');
+?>
+--EXPECTF--
+string(%d) "%d"
diff --git a/ext/spl/tests/DirectoryIterator_getInode_error.phpt b/ext/spl/tests/DirectoryIterator_getInode_error.phpt
new file mode 100644
index 0000000..c3641f9
--- /dev/null
+++ b/ext/spl/tests/DirectoryIterator_getInode_error.phpt
@@ -0,0 +1,28 @@
+--TEST--
+SPL: Spl File Info test getInode
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+
+//file
+$fileInfo = new SplFileInfo('not_existing');
+var_dump($fileInfo->getInode());
+?>
+
+--EXPECTF--
+Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileInfo::getInode(): stat failed for %s' in %s
+Stack trace:
+#0 %s: SplFileInfo->getInode()
+#1 {main}
+ thrown in %s
diff --git a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
new file mode 100644
index 0000000..a1092c2
--- /dev/null
+++ b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
@@ -0,0 +1,29 @@
+--TEST--
+SPL: DirectoryIterator test getOwner
+--SKIPIF--
+<?php
+if (posix_geteuid() == 0) die('SKIP Cannot run test as root.');
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--FILE--
+<?php
+$dirname = 'DirectoryIterator_getOwner_basic';
+mkdir($dirname);
+$dir = new DirectoryIterator($dirname);
+$expected = fileowner($dirname);
+$actual = $dir->getOwner();
+var_dump($expected == $actual);
+?>
+--CLEAN--
+<?php
+$dirname = 'DirectoryIterator_getOwner_basic';
+rmdir($dirname);
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/spl/tests/RecursiveCallbackFilterIteratorTest.phpt b/ext/spl/tests/RecursiveCallbackFilterIteratorTest.phpt
new file mode 100644
index 0000000..f55afd8
--- /dev/null
+++ b/ext/spl/tests/RecursiveCallbackFilterIteratorTest.phpt
@@ -0,0 +1,138 @@
+--TEST--
+RecursiveCallbackFilterIterator
+--FILE--
+<?php
+
+class A {
+ function test($value, $key, $inner) {
+ return test($value, $key, $inner);
+ }
+}
+
+class B {
+ static function test($value, $key, $inner) {
+ return test($value, $key, $inner);
+ }
+}
+
+function test($value, $key, $inner) {
+ if ($inner->hasChildren()) {
+ return true;
+ }
+ printf("%s / %s / %d / %d\n"
+ , print_r($value, true)
+ , $key
+ , $value == $inner->current()
+ , $key == $inner->key()
+ );
+ return $value === 1 || $value === 4;
+}
+
+$tests = array(
+ 'instance method' => function() { return array(new A, 'test'); },
+ 'static method' => function() { return array('B', 'test'); },
+ 'static method (2)' => function() { return 'B::test'; },
+ 'function' => function() { return 'test'; },
+ 'anonymous function' => function() { return function($value, $key, $inner) { return test($value, $key, $inner); }; },
+);
+
+foreach($tests as $name => $test) {
+
+ $callback = $test();
+ $it = new RecursiveArrayIterator(array(1, array(2, 3), array(4, 5)));
+ $it = new RecursiveCallbackFilterIterator($it, $callback);
+ $it = new RecursiveIteratorIterator($it);
+
+ echo " = $name =\n";
+
+ foreach($it as $value) {
+ echo "=> $value\n";
+ }
+
+ // same test, with no reference to callback
+
+ $it = new RecursiveArrayIterator(array(1, array(2, 3), array(4, 5)));
+ $it = new RecursiveCallbackFilterIterator($it, $test());
+ $it = new RecursiveIteratorIterator($it);
+ unset($callback);
+
+ foreach($it as $value) {
+ echo "=> $value\n";
+ }
+}
+--EXPECT--
+= instance method =
+1 / 0 / 1 / 1
+=> 1
+2 / 0 / 1 / 1
+3 / 1 / 1 / 1
+4 / 0 / 1 / 1
+=> 4
+5 / 1 / 1 / 1
+1 / 0 / 1 / 1
+=> 1
+2 / 0 / 1 / 1
+3 / 1 / 1 / 1
+4 / 0 / 1 / 1
+=> 4
+5 / 1 / 1 / 1
+ = static method =
+1 / 0 / 1 / 1
+=> 1
+2 / 0 / 1 / 1
+3 / 1 / 1 / 1
+4 / 0 / 1 / 1
+=> 4
+5 / 1 / 1 / 1
+1 / 0 / 1 / 1
+=> 1
+2 / 0 / 1 / 1
+3 / 1 / 1 / 1
+4 / 0 / 1 / 1
+=> 4
+5 / 1 / 1 / 1
+ = static method (2) =
+1 / 0 / 1 / 1
+=> 1
+2 / 0 / 1 / 1
+3 / 1 / 1 / 1
+4 / 0 / 1 / 1
+=> 4
+5 / 1 / 1 / 1
+1 / 0 / 1 / 1
+=> 1
+2 / 0 / 1 / 1
+3 / 1 / 1 / 1
+4 / 0 / 1 / 1
+=> 4
+5 / 1 / 1 / 1
+ = function =
+1 / 0 / 1 / 1
+=> 1
+2 / 0 / 1 / 1
+3 / 1 / 1 / 1
+4 / 0 / 1 / 1
+=> 4
+5 / 1 / 1 / 1
+1 / 0 / 1 / 1
+=> 1
+2 / 0 / 1 / 1
+3 / 1 / 1 / 1
+4 / 0 / 1 / 1
+=> 4
+5 / 1 / 1 / 1
+ = anonymous function =
+1 / 0 / 1 / 1
+=> 1
+2 / 0 / 1 / 1
+3 / 1 / 1 / 1
+4 / 0 / 1 / 1
+=> 4
+5 / 1 / 1 / 1
+1 / 0 / 1 / 1
+=> 1
+2 / 0 / 1 / 1
+3 / 1 / 1 / 1
+4 / 0 / 1 / 1
+=> 4
+5 / 1 / 1 / 1
diff --git a/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt b/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt
new file mode 100644
index 0000000..f0b2b01
--- /dev/null
+++ b/ext/spl/tests/RecursiveDirectoryIterator_getSubPath_basic.phpt
@@ -0,0 +1,50 @@
+--TEST--
+RecursiveDirectoryIterator::getBasePath() - basic test
+--CREDITS--
+Pawel Krynicki <pawel [dot] krynicki [at] xsolve [dot] pl>
+#testfest AmsterdamPHP 2012-06-23
+--FILE--
+<?php
+$depth0 = "depth0";
+$depth1 = 'depth1';
+$depth2 = 'depth2';
+$targetDir = __DIR__ . DIRECTORY_SEPARATOR . $depth0 . DIRECTORY_SEPARATOR . $depth1 . DIRECTORY_SEPARATOR . $depth2;
+mkdir($targetDir, 0777, true);
+touch($targetDir . DIRECTORY_SEPARATOR . 'getSubPath_test.tmp');
+$iterator = new RecursiveDirectoryIterator(__DIR__ . DIRECTORY_SEPARATOR . $depth0);
+$it = new RecursiveIteratorIterator($iterator);
+
+$list = [];
+while($it->valid()) {
+ $list[] = $it->getSubPath();
+ $it->next();
+}
+asort($list);
+foreach ($list as $item) {
+ echo $item . "\n";
+}
+?>
+--CLEAN--
+<?php
+function rrmdir($dir) {
+ foreach(glob($dir . '/*') as $file) {
+ if(is_dir($file)) {
+ rrmdir($file);
+ } else {
+ unlink($file);
+ }
+ }
+
+ rmdir($dir);
+}
+
+$targetDir = __DIR__.DIRECTORY_SEPARATOR . "depth0";
+rrmdir($targetDir);
+?>
+
+--EXPECTF--
+depth1
+depth1
+depth1%cdepth2
+depth1%cdepth2
+depth1%cdepth2
diff --git a/ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt b/ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt
new file mode 100644
index 0000000..7b12672
--- /dev/null
+++ b/ext/spl/tests/RecursiveDirectoryIterator_getSubPathname_basic.phpt
@@ -0,0 +1,56 @@
+--TEST--
+RecursiveDirectoryIterator::getBasePathname() - basic test
+--CREDITS--
+Pawel Krynicki <pawel [dot] krynicki [at] xsolve [dot] pl>
+#testfest AmsterdamPHP 2012-06-23
+--FILE--
+<?php
+$depth0 = "depth0";
+$depth1 = "depth1";
+$depth2 = "depth2";
+$targetDir = __DIR__ . DIRECTORY_SEPARATOR . $depth0 . DIRECTORY_SEPARATOR . $depth1 . DIRECTORY_SEPARATOR . $depth2;
+mkdir($targetDir, 0777, true);
+touch($targetDir . DIRECTORY_SEPARATOR . 'getSubPathname_test_2.tmp');
+touch(__DIR__ . DIRECTORY_SEPARATOR . $depth0 . DIRECTORY_SEPARATOR . $depth1 . DIRECTORY_SEPARATOR . 'getSubPathname_test_3.tmp');
+touch(__DIR__ . DIRECTORY_SEPARATOR . $depth0 . DIRECTORY_SEPARATOR . 'getSubPathname_test_1.tmp');
+$iterator = new RecursiveDirectoryIterator(__DIR__ . DIRECTORY_SEPARATOR . $depth0);
+$it = new RecursiveIteratorIterator($iterator);
+
+$list = [];
+$it->rewind(); //see https://bugs.php.net/bug.php?id=62914
+while($it->valid()) {
+ $list[] = $it->getSubPathname();
+ $it->next();
+}
+asort($list);
+foreach ($list as $item) {
+ echo $item . "\n";
+}
+?>
+--CLEAN--
+<?php
+function rrmdir($dir) {
+ foreach(glob($dir . '/*') as $file) {
+ if(is_dir($file)) {
+ rrmdir($file);
+ } else {
+ unlink($file);
+ }
+ }
+
+ rmdir($dir);
+}
+
+$targetDir = __DIR__ . DIRECTORY_SEPARATOR . "depth0";
+rrmdir($targetDir);
+?>
+--EXPECTF--
+.
+..
+depth1%c.
+depth1%c..
+depth1%cdepth2%c.
+depth1%cdepth2%c..
+depth1%cdepth2%cgetSubPathname_test_2.tmp
+depth1%cgetSubPathname_test_3.tmp
+getSubPathname_test_1.tmp
diff --git a/ext/spl/tests/SplArray_fromArray.phpt b/ext/spl/tests/SplArray_fromArray.phpt
new file mode 100644
index 0000000..1144f5f
--- /dev/null
+++ b/ext/spl/tests/SplArray_fromArray.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Check that SplArray::fromArray will not allow integer overflows
+--CREDITS--
+Rob Knight <themanhimself@robknight.org.uk> PHPNW Test Fest 2009
+--FILE--
+<?php
+$array = array(PHP_INT_MAX => 'foo');
+$splArray = new SplFixedArray();
+
+try {
+ $splArray->fromArray($array);
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+?>
+--EXPECT--
+integer overflow detected \ No newline at end of file
diff --git a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_array.phpt b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_array.phpt
new file mode 100644
index 0000000..36b186d
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_array.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SplDoublyLinkedList::bottom() - pass in an unexpected array parameter
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+
+$list = new SplDoublyLinkedList();
+$list->push("top");
+$list->bottom(array());
+
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_float.phpt b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_float.phpt
new file mode 100644
index 0000000..94312a0
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_float.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SplDoublyLinkedList::bottom() - pass in an unexpected float parameter
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+
+$list = new SplDoublyLinkedList();
+$list->push("top");
+$list->bottom(3.14159);
+
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_integer.phpt b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_integer.phpt
new file mode 100644
index 0000000..651f1e4
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_integer.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SplDoublyLinkedList::bottom() - pass in an unexpected integer parameter
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+
+$list = new SplDoublyLinkedList();
+$list->push("top");
+$list->bottom(45);
+
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_null.phpt b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_null.phpt
new file mode 100644
index 0000000..efc6b8a
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_null.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SplDoublyLinkedList::bottom() - pass in an unexpected null parameter
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+
+$list = new SplDoublyLinkedList();
+$list->push("top");
+$list->bottom(null);
+
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_count.phpt b/ext/spl/tests/SplDoublyLinkedList_count.phpt
new file mode 100644
index 0000000..72b029c
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_count.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Check that SplDoublyLinkedList::count fails if parameter passed in
+--CREDITS--
+Rob Knight <themanhimself@robknight.org.uk> PHPNW Test Fest 2009
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+
+$c = $list->count('foo');
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::count() expects exactly 0 parameters, 1 given in %s on line 4
diff --git a/ext/spl/tests/SplDoublyLinkedList_count_param_SplDoublyLinkedList.phpt b/ext/spl/tests/SplDoublyLinkedList_count_param_SplDoublyLinkedList.phpt
new file mode 100644
index 0000000..36c72de
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_count_param_SplDoublyLinkedList.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Create a SplDoublyLinkedList, call count() and pass a SplDoublyLinkedList object as the parameter.
+--CREDITS--
+Philip Norton philipnorton42@gmail.com
+--FILE--
+<?php
+$dll = new SplDoublyLinkedList(2);
+$dll->count(new SplDoublyLinkedList(2));
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::count() expects exactly 0 parameters, 1 given in %s on line %d \ No newline at end of file
diff --git a/ext/spl/tests/SplDoublyLinkedList_current.phpt b/ext/spl/tests/SplDoublyLinkedList_current.phpt
new file mode 100644
index 0000000..3e13a6b
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_current.phpt
@@ -0,0 +1,11 @@
+--TEST--
+SplDoublyLinkedList getIteratorMode
+--CREDITS--
+PHPNW Testfest 2009 - Lorna Mitchell
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+var_dump($list->current());
+?>
+--EXPECT--
+NULL
diff --git a/ext/spl/tests/SplDoublyLinkedList_current_empty.phpt b/ext/spl/tests/SplDoublyLinkedList_current_empty.phpt
new file mode 100644
index 0000000..558504b
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_current_empty.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Run current() function on an empty SplDoublyLinkedList.
+--CREDITS--
+Philip Norton philipnorton42@gmail.com
+--FILE--
+<?php
+
+$list = new SplDoublyLinkedList();
+var_dump($list->current());
+
+?>
+--EXPECT--
+NULL \ No newline at end of file
diff --git a/ext/spl/tests/SplDoublyLinkedList_debug-info.phpt b/ext/spl/tests/SplDoublyLinkedList_debug-info.phpt
new file mode 100644
index 0000000..3164b42
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_debug-info.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Check that SplDoublyLinkedList returns debug info when print_r is used.
+--CREDITS--
+PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
+--FILE--
+<?php
+ // Create a new Doubly Linked List
+ $dll = new SplDoublyLinkedList();
+
+ // Add some items to the list
+ $dll->push(1);
+ $dll->push(2);
+ $dll->push(3);
+
+ // Check the debug info
+ print_r($dll);
+?>
+--EXPECT--
+SplDoublyLinkedList Object
+(
+ [flags:SplDoublyLinkedList:private] => 0
+ [dllist:SplDoublyLinkedList:private] => Array
+ (
+ [0] => 1
+ [1] => 2
+ [2] => 3
+ )
+
+)
diff --git a/ext/spl/tests/SplDoublyLinkedList_getIteratorMode.phpt b/ext/spl/tests/SplDoublyLinkedList_getIteratorMode.phpt
new file mode 100644
index 0000000..d1bfb46
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_getIteratorMode.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SplDoublyLinkedList getIteratorMode
+--CREDITS--
+PHPNW Testfest 2009 - Lorna Mitchell
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+$list->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP);
+echo $list->getIteratorMode();
+?>
+--EXPECT--
+0
diff --git a/ext/spl/tests/SplDoublyLinkedList_getIteratorMode_error.phpt b/ext/spl/tests/SplDoublyLinkedList_getIteratorMode_error.phpt
new file mode 100644
index 0000000..cb43bee
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_getIteratorMode_error.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SplDoublyLinkedList getIteratorMode with an unexpected parameter
+--CREDITS--
+PHPNW Testfest 2009 - Lorna Mitchell
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+$list->getIteratorMode(24);
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::getIteratorMode() expects exactly 0 parameters, 1 given in %s on line %d
+
diff --git a/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty-with-parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty-with-parameter.phpt
new file mode 100644
index 0000000..8d7aaf8
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty-with-parameter.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Check that SplDoublyLinkedList->isEmpty() returns an error message when a parameter is passed.
+--CREDITS--
+PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
+--FILE--
+<?php
+ // Create a new Doubly Linked List
+ $dll = new SplDoublyLinkedList();
+
+ var_dump($dll->isEmpty("test"));
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::isEmpty() expects exactly 0 parameters, %d given in %s
+NULL \ No newline at end of file
diff --git a/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty.phpt b/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty.phpt
new file mode 100644
index 0000000..f129385
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Check that SplDoublyLinkedList->isEmpty() correctly returns true for an empty list.
+--CREDITS--
+PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
+--FILE--
+<?php
+ // Create a new Doubly Linked List
+ $dll = new SplDoublyLinkedList();
+
+ var_dump($dll->isEmpty());
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty-with-parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty-with-parameter.phpt
new file mode 100644
index 0000000..6ea9198
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty-with-parameter.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Check that SplDoublyLinkedList->isEmpty() returns an error message when a parameter is passed.
+--CREDITS--
+PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
+--FILE--
+<?php
+ // Create a new Doubly Linked List
+ $dll = new SplDoublyLinkedList();
+
+ // Add some items to the list
+ $dll->push(1);
+ $dll->push(2);
+ $dll->push(3);
+ //var_dump($dll);
+
+ var_dump($dll->isEmpty("test"));
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::isEmpty() expects exactly 0 parameters, %d given in %s
+NULL \ No newline at end of file
diff --git a/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty.phpt b/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty.phpt
new file mode 100644
index 0000000..cac1866
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Check that SplDoublyLinkedList->isEmpty() correctly returns true for a non-empty list.
+--CREDITS--
+PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
+--FILE--
+<?php
+ // Create a new Doubly Linked List
+ $dll = new SplDoublyLinkedList();
+
+ // Add some items to the list
+ $dll->push(1);
+ $dll->push(2);
+ $dll->push(3);
+ //var_dump($dll);
+
+ var_dump($dll->isEmpty());
+?>
+--EXPECT--
+bool(false)
diff --git a/ext/spl/tests/SplDoublyLinkedList_lifoMode.phpt b/ext/spl/tests/SplDoublyLinkedList_lifoMode.phpt
new file mode 100644
index 0000000..86a8456
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_lifoMode.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Check that SplDoublyLinkedList can traverse backwards
+--CREDITS--
+Rob Knight <themanhimself@robknight.org.uk> PHPNW Test Fest 2009
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+
+$list->push('o');
+$list->push('o');
+$list->push('f');
+
+$list->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
+
+$list->rewind();
+
+while ($tmp = $list->current()) {
+ echo $tmp;
+ $list->next();
+}
+?>
+--EXPECT--
+foo \ No newline at end of file
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetExists_invalid_parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetExists_invalid_parameter.phpt
new file mode 100644
index 0000000..f0e1b8b
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_offsetExists_invalid_parameter.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL SplDoublyLinkedList offsetExists displays warning and returns null on no parameters
+--CREDITS--
+PHPNW TestFest 2009 - Ben Longden
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+$a = $list->offsetExists();
+if(is_null($a)) {
+ echo 'PASS';
+}
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::offsetExists() expects exactly 1 parameter, 0 given in %s on line %d
+PASS
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetExists_success.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetExists_success.phpt
new file mode 100644
index 0000000..0399b49
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_offsetExists_success.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL SplDoublyLinkedList offsetExists returns correct values
+--CREDITS--
+PHPNW TestFest 2009 - Ben Longden
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+
+// Push two values onto the list
+$list->push('abc');
+$list->push('def');
+
+// Validate that we can see the first value
+if($list->offsetExists(0) === true) {
+ echo "PASS\n";
+}
+
+// Validate that we can see the second value
+if($list->offsetExists(1) === true) {
+ echo "PASS\n";
+}
+
+// Check that there is no third value
+if($list->offsetExists(2) === false) {
+ echo "PASS\n";
+}
+?>
+--EXPECTF--
+PASS
+PASS
+PASS
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetGet_empty.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetGet_empty.phpt
new file mode 100644
index 0000000..36c47fe
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_offsetGet_empty.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SplDoublyLinkedList::offsetGet() with no parameter passed.
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplDoublyLinkedList( );
+
+$get = $array->offsetGet();
+
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::offsetGet() expects exactly 1 parameter, 0 given in %s on line %d \ No newline at end of file
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetGet_missing_param.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetGet_missing_param.phpt
new file mode 100644
index 0000000..beffe7a
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_offsetGet_missing_param.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Tests that the offsetGet() method throws an error when no argument is sent
+--CREDITS--
+PHPNW Test Fest 2009 - Rick Ogden
+--FILE--
+<?php
+$dll = new SplDoublyLinkedList();
+$dll->push(1);
+$dll->push(2);
+
+var_dump($dll->offsetGet());
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::offsetGet() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_array.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_array.phpt
new file mode 100644
index 0000000..5df4ab5
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_array.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SplDoublyLinkedList::offsetGet() with 1st parameter passed as array.
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplDoublyLinkedList( );
+
+$get = $array->offsetGet( array( 'fail' ) );
+
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'OutOfRangeException' with message 'Offset invalid or out of range' in %s
+Stack trace:
+#0 %s
+#1 {main}
+ thrown in %s on line %d \ No newline at end of file
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_string.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_string.phpt
new file mode 100644
index 0000000..fcff762
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_offsetGet_param_string.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SplDoublyLinkedList::offsetGet() with 1st parameter passed as string.
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplDoublyLinkedList( );
+
+$get = $array->offsetGet( 'fail' );
+
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'OutOfRangeException' with message 'Offset invalid or out of range' in %s
+Stack trace:
+#0 %s
+#1 {main}
+ thrown in %s on line %d \ No newline at end of file
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetSet_invalid_parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetSet_invalid_parameter.phpt
new file mode 100644
index 0000000..2447e79
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_offsetSet_invalid_parameter.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SplDoublyLinkedList offsetSet throws error on no parameters
+--CREDITS--
+PHPNW TestFest 2009 - Ben Longden
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+$a = $list->offsetSet();
+if(is_null($a)) {
+ echo 'PASS';
+}
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::offsetSet() expects exactly 2 parameters, 0 given in %s on line %d
+PASS
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetSet_one_invalid_parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetSet_one_invalid_parameter.phpt
new file mode 100644
index 0000000..244dcd5
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_offsetSet_one_invalid_parameter.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SplDoublyLinkedList offsetSet throws error only one parameter
+--CREDITS--
+PHPNW TestFest 2009 - Ben Longden
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+$a = $list->offsetSet(2);
+if(is_null($a)) {
+ echo 'PASS';
+}
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::offsetSet() expects exactly 2 parameters, 1 given in %s on line %d
+PASS
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_greater_than_elements.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_greater_than_elements.phpt
new file mode 100644
index 0000000..687fcad
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_greater_than_elements.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Doubly Linked List - offsetUnset > number elements
+
+--CREDITS--
+PHPNW Test Fest 2009 - Mat Griffin
+
+--FILE--
+<?php
+$ll = new SplDoublyLinkedList();
+
+$ll->push('1');
+$ll->push('2');
+$ll->push('3');
+
+try {
+
+$ll->offsetUnset($ll->count() + 1);
+
+var_dump($ll);
+
+} catch(Exception $e) {
+echo $e->getMessage();
+}
+
+?>
+--EXPECT--
+Offset out of range
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt
new file mode 100644
index 0000000..d3d1d7d
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_negative-parameter.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Check that SplDoublyLinkedList->offsetUnset() returns an error message when the offset is < 0.
+--CREDITS--
+PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
+--FILE--
+<?php
+ // Create a new Doubly Linked List
+ $dll = new SplDoublyLinkedList();
+
+ // Add some items to the list
+ $dll->push(1);
+ $dll->push(2);
+ $dll->push(3);
+
+ try {
+ $dll->offsetUnset(-1);
+ }
+ catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+ }
+?>
+--EXPECT--
+Offset out of range
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt
new file mode 100644
index 0000000..aea73b9
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_offsetUnset_parameter-larger-num-elements.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Check that SplDoublyLinkedList->offsetUnset() returns an error message when the offset is > elements.
+--CREDITS--
+PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
+--FILE--
+<?php
+ // Create a new Doubly Linked List
+ $dll = new SplDoublyLinkedList();
+
+ // Add some items to the list
+ $dll->push(1);
+ $dll->push(2);
+ $dll->push(3);
+
+ try {
+ $dll->offsetUnset(3);
+ }
+ catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+ }
+?>
+--EXPECT--
+Offset out of range
diff --git a/ext/spl/tests/SplDoublyLinkedList_pop_noParams.phpt b/ext/spl/tests/SplDoublyLinkedList_pop_noParams.phpt
new file mode 100644
index 0000000..64f3a48
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_pop_noParams.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Checks that the pop() method of DoublyLinkedList does not accept args.
+--CREDITS--
+PHPNW Test Fest 2009 - Rick Ogden
+--FILE--
+<?php
+$ll = new SplDoublyLinkedList();
+$ll->push(1);
+$ll->push(2);
+
+var_dump($ll->pop(1));
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::pop() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
diff --git a/ext/spl/tests/SplDoublyLinkedList_pop_params.phpt b/ext/spl/tests/SplDoublyLinkedList_pop_params.phpt
new file mode 100644
index 0000000..11ab343
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_pop_params.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SplDoublyLinkedList::offsetGet() with no parameter passed.
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplDoublyLinkedList( );
+
+$get = $array->pop( 'param' );
+
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::pop() expects exactly 0 parameters, 1 given in %s on line %d \ No newline at end of file
diff --git a/ext/spl/tests/SplDoublyLinkedList_push_missing_parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_push_missing_parameter.phpt
new file mode 100644
index 0000000..057751c
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_push_missing_parameter.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Check that SplDoublyLinkedList::push generate a warning and return NULL with missing param
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+$dll = new SplDoublyLinkedList();
+var_dump($dll->push());
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::push() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplDoublyLinkedList_serialization.phpt b/ext/spl/tests/SplDoublyLinkedList_serialization.phpt
new file mode 100644
index 0000000..7ab7d78
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_serialization.phpt
@@ -0,0 +1,67 @@
+--TEST--
+Check Serialization/unserialization
+--FILE--
+<?php
+$q = new SplQueue();
+
+$q->enqueue("a");
+$q->enqueue("b");
+
+var_dump($q, $ss = serialize($q), unserialize($ss));
+
+$s = new SplStack();
+
+$s->push("a");
+$s->push("b");
+
+var_dump($s, $ss = serialize($s), unserialize($ss));
+?>
+==END==
+--EXPECTF--
+object(SplQueue)#%d (2) {
+ ["flags":"SplDoublyLinkedList":private]=>
+ int(4)
+ ["dllist":"SplDoublyLinkedList":private]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ }
+}
+string(42) "C:8:"SplQueue":22:{i:4;:s:1:"a";:s:1:"b";}"
+object(SplQueue)#%d (2) {
+ ["flags":"SplDoublyLinkedList":private]=>
+ int(4)
+ ["dllist":"SplDoublyLinkedList":private]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ }
+}
+object(SplStack)#%d (2) {
+ ["flags":"SplDoublyLinkedList":private]=>
+ int(6)
+ ["dllist":"SplDoublyLinkedList":private]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ }
+}
+string(42) "C:8:"SplStack":22:{i:6;:s:1:"a";:s:1:"b";}"
+object(SplStack)#%d (2) {
+ ["flags":"SplDoublyLinkedList":private]=>
+ int(6)
+ ["dllist":"SplDoublyLinkedList":private]=>
+ array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+ }
+}
+==END==
diff --git a/ext/spl/tests/SplDoublyLinkedList_setIteratorMode_param_SplDoublyLinkedList.phpt b/ext/spl/tests/SplDoublyLinkedList_setIteratorMode_param_SplDoublyLinkedList.phpt
new file mode 100644
index 0000000..9bf7a32
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_setIteratorMode_param_SplDoublyLinkedList.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Create a SplDoublyLinkedList, call setIteratorMode() and pass a SplDoublyLinkedList object as the parameter.
+--CREDITS--
+Philip Norton philipnorton42@gmail.com
+--FILE--
+<?php
+$dll = new SplDoublyLinkedList(2);
+$dll->setIteratorMode(new SplDoublyLinkedList(2));
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::setIteratorMode() expects parameter 1 to be long, object given in %s on line %d \ No newline at end of file
diff --git a/ext/spl/tests/SplDoublyLinkedList_top_pass_array.phpt b/ext/spl/tests/SplDoublyLinkedList_top_pass_array.phpt
new file mode 100644
index 0000000..2e2632d
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_top_pass_array.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SplDoublyLinkedList::top() - pass in an unexpected array
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+
+$list = new SplDoublyLinkedList();
+$list->push("top");
+$list->top(array());
+
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::top() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_top_pass_float.phpt b/ext/spl/tests/SplDoublyLinkedList_top_pass_float.phpt
new file mode 100644
index 0000000..0a481b8
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_top_pass_float.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SplDoublyLinkedList::top() - pass in an unexpected float parameter
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+
+$list = new SplDoublyLinkedList();
+$list->push("top");
+$list->top(3.14159);
+
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::top() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_top_pass_integer.phpt b/ext/spl/tests/SplDoublyLinkedList_top_pass_integer.phpt
new file mode 100644
index 0000000..72bdbab
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_top_pass_integer.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SplDoublyLinkedList::top() - pass in an unexpected integer parameter
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+
+$list = new SplDoublyLinkedList();
+$list->push("top");
+$list->top(45);
+
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::top() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_top_pass_null.phpt b/ext/spl/tests/SplDoublyLinkedList_top_pass_null.phpt
new file mode 100644
index 0000000..6a92399
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_top_pass_null.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SplDoublyLinkedList::top() - pass in an unexpected null parameter
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+
+$list = new SplDoublyLinkedList();
+$list->push("top");
+$list->top(null);
+
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::top() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_unshift_missing_parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_unshift_missing_parameter.phpt
new file mode 100644
index 0000000..18afa03
--- /dev/null
+++ b/ext/spl/tests/SplDoublyLinkedList_unshift_missing_parameter.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Check that SplDoublyLinkedList::unshift generate a warning and return NULL with missing param
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+$dll = new SplDoublyLinkedList();
+var_dump($dll->unshift());
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::unshift() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt b/ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt
new file mode 100644
index 0000000..4dce4db
--- /dev/null
+++ b/ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt
@@ -0,0 +1,25 @@
+--TEST--
+SPL: SplDoublyLinkedList : offsetUnset - first element
+--CREDITS--
+PHPNW TestFest2009 - Rowan Merewood <rowan@merewood.org>
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+$list->push('oh');
+$list->push('hai');
+$list->push('thar');
+$list->offsetUnset(0);
+var_dump($list);
+?>
+--EXPECTF--
+object(SplDoublyLinkedList)#1 (2) {
+ [%u|b%"flags":%u|b%"SplDoublyLinkedList":private]=>
+ int(0)
+ [%u|b%"dllist":%u|b%"SplDoublyLinkedList":private]=>
+ array(2) {
+ [0]=>
+ %string|unicode%(3) "hai"
+ [1]=>
+ %string|unicode%(4) "thar"
+ }
+}
diff --git a/ext/spl/tests/SplDoublylinkedlist_offsetunset_first002.phpt b/ext/spl/tests/SplDoublylinkedlist_offsetunset_first002.phpt
new file mode 100644
index 0000000..a42e6f9
--- /dev/null
+++ b/ext/spl/tests/SplDoublylinkedlist_offsetunset_first002.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: SplDoublyLinkedList : offsetUnset - first element
+--CREDITS--
+PHPNW TestFest2009 - Rowan Merewood <rowan@merewood.org>
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+$list->push('oh');
+$list->push('hai');
+$list->push('thar');
+echo $list->bottom() . "\n";
+$list->offsetUnset(0);
+echo $list->bottom() . "\n";
+?>
+--EXPECT--
+oh
+hai
diff --git a/ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt b/ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt
new file mode 100644
index 0000000..0f5dac1
--- /dev/null
+++ b/ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt
@@ -0,0 +1,25 @@
+--TEST--
+SPL: SplDoublyLinkedList : offsetUnset - last element
+--CREDITS--
+PHPNW TestFest2009 - Rowan Merewood <rowan@merewood.org>
+--FILE--
+<?php
+$list = new SplDoublyLinkedList();
+$list->push('oh');
+$list->push('hai');
+$list->push('thar');
+$list->offsetUnset(2);
+var_dump($list);
+?>
+--EXPECTF--
+object(SplDoublyLinkedList)#1 (2) {
+ [%u|b%"flags":%u|b%"SplDoublyLinkedList":private]=>
+ int(0)
+ [%u|b%"dllist":%u|b%"SplDoublyLinkedList":private]=>
+ array(2) {
+ [0]=>
+ %string|unicode%(2) "oh"
+ [1]=>
+ %string|unicode%(3) "hai"
+ }
+}
diff --git a/ext/spl/tests/SplFileInfo_001.phpt b/ext/spl/tests/SplFileInfo_001.phpt
new file mode 100644
index 0000000..72060f0
--- /dev/null
+++ b/ext/spl/tests/SplFileInfo_001.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Testing SplFileInfo calling the constructor twice
+--FILE--
+<?php
+$x = new splfileinfo(1);
+$x->__construct(1);
+
+echo "done!\n";
+?>
+--EXPECT--
+done!
diff --git a/ext/spl/tests/SplFileInfo_getExtension_basic.phpt b/ext/spl/tests/SplFileInfo_getExtension_basic.phpt
new file mode 100644
index 0000000..b47b6bb
--- /dev/null
+++ b/ext/spl/tests/SplFileInfo_getExtension_basic.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: SplFileInfo::getExtension() basic test
+--FILE--
+<?php
+$file = md5('SplFileInfo::getExtension');
+$exts = array('.txt', '.extension', '..', '.', '');
+foreach ($exts as $ext) {
+ touch($file . $ext);
+ $info = new SplFileInfo($file . $ext);
+ var_dump($info->getExtension(), pathinfo($file . $ext, PATHINFO_EXTENSION));
+}
+?>
+--CLEAN--
+<?php
+$file = md5('SplFileInfo::getExtension');
+$exts = array('.txt', '.extension', '..', '.', '');
+foreach ($exts as $ext) {
+ unlink($file . $ext);
+}
+?>
+--EXPECTF--
+string(3) "txt"
+string(3) "txt"
+string(9) "extension"
+string(9) "extension"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
diff --git a/ext/spl/tests/SplFileInfo_getGroup_basic.phpt b/ext/spl/tests/SplFileInfo_getGroup_basic.phpt
new file mode 100644
index 0000000..d279935
--- /dev/null
+++ b/ext/spl/tests/SplFileInfo_getGroup_basic.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SPL: SplFileInfo test getGroup
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--FILE--
+<?php
+$filename = __DIR__ . "/SplFileInfo_getGroup_basic";
+touch($filename);
+$fileInfo = new SplFileInfo($filename);
+$expected = filegroup($filename);
+$actual = $fileInfo->getGroup();
+var_dump($expected == $actual);
+?>
+--CLEAN--
+<?php
+$filename = __DIR__ . "/SplFileInfo_getGroup_basic";
+unlink($filename);
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/spl/tests/SplFileInfo_getGroup_error.phpt b/ext/spl/tests/SplFileInfo_getGroup_error.phpt
new file mode 100644
index 0000000..f0db00d
--- /dev/null
+++ b/ext/spl/tests/SplFileInfo_getGroup_error.phpt
@@ -0,0 +1,28 @@
+--TEST--
+SPL: Spl File Info test getGroup
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+
+//file
+$fileInfo = new SplFileInfo('not_existing');
+var_dump($fileInfo->getGroup());
+?>
+
+--EXPECTF--
+Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileInfo::getGroup(): stat failed for not_existing' in %s
+Stack trace:
+#0 %s: SplFileInfo->getGroup()
+#1 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/SplFileInfo_getInode_basic.phpt b/ext/spl/tests/SplFileInfo_getInode_basic.phpt
new file mode 100644
index 0000000..902cbb3
--- /dev/null
+++ b/ext/spl/tests/SplFileInfo_getInode_basic.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: Spl File Info test getInode
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+
+//file
+touch ('test_file_ptfi');
+$fileInfo = new SplFileInfo('test_file_ptfi');
+$result = shell_exec('ls -i test_file_ptfi');
+var_dump($fileInfo->getInode() == $result);
+
+?>
+--CLEAN--
+<?php
+unlink('test_file_ptfi');
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/spl/tests/SplFileInfo_getInode_error.phpt b/ext/spl/tests/SplFileInfo_getInode_error.phpt
new file mode 100644
index 0000000..bf8efae
--- /dev/null
+++ b/ext/spl/tests/SplFileInfo_getInode_error.phpt
@@ -0,0 +1,28 @@
+--TEST--
+SPL: Spl File Info test getPerms
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+
+//file
+$fileInfo = new SplFileInfo('not_existing');
+var_dump($fileInfo->getInode());
+?>
+
+--EXPECTF--
+Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileInfo::getInode(): stat failed for not_existing' in %s
+Stack trace:
+#0 %s: SplFileInfo->getInode()
+#1 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/SplFileInfo_getOwner_basic.phpt b/ext/spl/tests/SplFileInfo_getOwner_basic.phpt
new file mode 100644
index 0000000..3df8e48
--- /dev/null
+++ b/ext/spl/tests/SplFileInfo_getOwner_basic.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SPL: SplFileInfo test getOwner
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--FILE--
+<?php
+$filename = __DIR__ . "/SplFileInfo_getOwner_basic";
+touch($filename);
+$fileInfo = new SplFileInfo($filename);
+$expected = fileowner($filename);
+$actual = $fileInfo->getOwner();
+var_dump($expected == $actual);
+?>
+--CLEAN--
+<?php
+$filename = __DIR__ . "/SplFileInfo_getOwner_basic";
+unlink($filename);
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/spl/tests/SplFileInfo_getOwner_error.phpt b/ext/spl/tests/SplFileInfo_getOwner_error.phpt
new file mode 100644
index 0000000..d5d4678
--- /dev/null
+++ b/ext/spl/tests/SplFileInfo_getOwner_error.phpt
@@ -0,0 +1,28 @@
+--TEST--
+SPL: Spl File Info test getOwner
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+
+//file
+$fileInfo = new SplFileInfo('not_existing');
+var_dump($fileInfo->getOwner());
+?>
+
+--EXPECTF--
+Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileInfo::getOwner(): stat failed for not_existing' in %s
+Stack trace:
+#0 %s: SplFileInfo->getOwner()
+#1 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/SplFileInfo_getPerms_basic.phpt b/ext/spl/tests/SplFileInfo_getPerms_basic.phpt
new file mode 100644
index 0000000..e9b7bea
--- /dev/null
+++ b/ext/spl/tests/SplFileInfo_getPerms_basic.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: Spl File Info test getPerms
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+
+//file
+touch ('test_file_ptfi');
+chmod('test_file_ptfi', 0557);
+$fileInfo = new SplFileInfo('test_file_ptfi');
+var_dump($fileInfo->getPerms() == 0100557);
+
+?>
+--CLEAN--
+<?php
+unlink('test_file_ptfi');
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/spl/tests/SplFileInfo_getPerms_error.phpt b/ext/spl/tests/SplFileInfo_getPerms_error.phpt
new file mode 100644
index 0000000..8e05cdf
--- /dev/null
+++ b/ext/spl/tests/SplFileInfo_getPerms_error.phpt
@@ -0,0 +1,28 @@
+--TEST--
+SPL: Spl File Info test getPerms
+--CREDITS--
+Cesare D'Amico <cesare.damico@gruppovolta.it>
+Andrea Giorgini <agiorg@gmail.com>
+Filippo De Santis <fd@ideato.it>
+Daniel Londero <daniel.londero@gmail.com>
+Francesco Trucchia <ft@ideato.it>
+Jacopo Romei <jacopo@sviluppoagile.it>
+#Test Fest Cesena (Italy) on 2009-06-20
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+
+//file
+$fileInfo = new SplFileInfo('not_existing');
+var_dump($fileInfo->getPerms() == 0100557);
+?>
+
+--EXPECTF--
+Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileInfo::getPerms(): stat failed for %s' in %s
+Stack trace:
+#0 %s: SplFileInfo->getPerms()
+#1 {main}
+ thrown in %s
diff --git a/ext/spl/tests/SplFileObject_current_basic.phpt b/ext/spl/tests/SplFileObject_current_basic.phpt
new file mode 100644
index 0000000..d3f4802
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_current_basic.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SPL: SplFileObject::current basic
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+echo $s->current();
+
+?>
+--EXPECT--
+<?php
diff --git a/ext/spl/tests/SplFileObject_current_error001.phpt b/ext/spl/tests/SplFileObject_current_error001.phpt
new file mode 100644
index 0000000..23c1266
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_current_error001.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: SplFileObject::current variation error
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+$s->seek(2);
+
+echo $s->current('foo');
+?>
+--EXPECTF--
+Warning: SplFileObject::current() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_current_variation001.phpt b/ext/spl/tests/SplFileObject_current_variation001.phpt
new file mode 100644
index 0000000..0cc588a
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_current_variation001.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: SplFileObject::current variation
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+$s->seek(2);
+
+echo $s->current();
+echo $s->current();
+?>
+--EXPECT--
+//line 3
+//line 3
diff --git a/ext/spl/tests/SplFileObject_fflush_basic_001.phpt b/ext/spl/tests/SplFileObject_fflush_basic_001.phpt
new file mode 100644
index 0000000..2d8a9c8
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fflush_basic_001.phpt
@@ -0,0 +1,38 @@
+--TEST--
+SplFileObject::fflush function - basic test
+--FILE--
+<?php
+/*
+ * test a successful flush
+*/
+$obj = New SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv');
+var_dump($obj->fflush());
+
+/*
+ * test a unsuccessful flush
+*/
+//create a basic stream class
+class VariableStream {
+ var $position;
+ var $varname;
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ return true;
+ }
+
+ function url_stat() {
+ }
+}
+stream_wrapper_register("SPLtest", "VariableStream");
+$ftruncate_test = "";
+//end creating stream
+
+//open an SplFileObject using the above test stream
+$obj = New SplFileObject("SPLtest://ftruncate_test");
+var_dump($obj->fflush());
+
+?>
+--EXPECTF--
+bool(true)
+bool(false)
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt b/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt
new file mode 100644
index 0000000..abfe5f2
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fgetcsv_basic.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SplFileObject::fgetcsv default path
+--FILE--
+<?php
+$fp = fopen('SplFileObject__fgetcsv.csv', 'w+');
+fputcsv($fp, array(
+ 'field1',
+ 'field2',
+ 'field3',
+ 5
+));
+fclose($fp);
+
+$fo = new SplFileObject('SplFileObject__fgetcsv.csv');
+var_dump($fo->fgetcsv());
+?>
+--CLEAN--
+<?php
+unlink('SplFileObject__fgetcsv.csv');
+?>
+--EXPECTF--
+array(4) {
+ [0]=>
+ string(6) "field1"
+ [1]=>
+ string(6) "field2"
+ [2]=>
+ string(6) "field3"
+ [3]=>
+ string(1) "5"
+}
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_delimiter_basic.phpt b/ext/spl/tests/SplFileObject_fgetcsv_delimiter_basic.phpt
new file mode 100644
index 0000000..32705f0
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fgetcsv_delimiter_basic.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SplFileObject::fgetcsv with alternative delimeter
+--FILE--
+<?php
+$fp = fopen('SplFileObject__fgetcsv.csv', 'w+');
+fputcsv($fp, array(
+ 'field1',
+ 'field2',
+ 'field3',
+ 5
+), '|');
+fclose($fp);
+
+$fo = new SplFileObject('SplFileObject__fgetcsv.csv');
+var_dump($fo->fgetcsv('|'));
+?>
+--CLEAN--
+<?php
+unlink('SplFileObject__fgetcsv.csv');
+?>
+--EXPECTF--
+array(4) {
+ [0]=>
+ string(6) "field1"
+ [1]=>
+ string(6) "field2"
+ [2]=>
+ string(6) "field3"
+ [3]=>
+ string(1) "5"
+}
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_delimiter_error.phpt b/ext/spl/tests/SplFileObject_fgetcsv_delimiter_error.phpt
new file mode 100644
index 0000000..942c761
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fgetcsv_delimiter_error.phpt
@@ -0,0 +1,23 @@
+--TEST--
+SplFileObject::fgetcsv with alternative delimeter
+--FILE--
+<?php
+$fp = fopen('SplFileObject__fgetcsv.csv', 'w+');
+fputcsv($fp, array(
+ 'field1',
+ 'field2',
+ 'field3',
+ 5
+), '|');
+fclose($fp);
+
+$fo = new SplFileObject('SplFileObject__fgetcsv.csv');
+var_dump($fo->fgetcsv('invalid'));
+?>
+--CLEAN--
+<?php
+unlink('SplFileObject__fgetcsv.csv');
+?>
+--EXPECTF--
+Warning: SplFileObject::fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_enclosure_basic.phpt b/ext/spl/tests/SplFileObject_fgetcsv_enclosure_basic.phpt
new file mode 100644
index 0000000..ee24972
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fgetcsv_enclosure_basic.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SplFileObject::fgetcsv with alternative delimeter
+--FILE--
+<?php
+$fp = fopen('SplFileObject__fgetcsv.csv', 'w+');
+fputcsv($fp, array(
+ 'field1',
+ 'field2',
+ 'field3',
+ 5
+), ',', '"');
+fclose($fp);
+
+$fo = new SplFileObject('SplFileObject__fgetcsv.csv');
+var_dump($fo->fgetcsv(',', '"'));
+?>
+--CLEAN--
+<?php
+unlink('SplFileObject__fgetcsv.csv');
+?>
+--EXPECTF--
+array(4) {
+ [0]=>
+ string(6) "field1"
+ [1]=>
+ string(6) "field2"
+ [2]=>
+ string(6) "field3"
+ [3]=>
+ string(1) "5"
+}
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_enclosure_error.phpt b/ext/spl/tests/SplFileObject_fgetcsv_enclosure_error.phpt
new file mode 100644
index 0000000..5430e53
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fgetcsv_enclosure_error.phpt
@@ -0,0 +1,23 @@
+--TEST--
+SplFileObject::fgetcsv with alternative delimeter
+--FILE--
+<?php
+$fp = fopen('SplFileObject__fgetcsv.csv', 'w+');
+fputcsv($fp, array(
+ 'field1',
+ 'field2',
+ 'field3',
+ 5
+), ',', '"');
+fclose($fp);
+
+$fo = new SplFileObject('SplFileObject__fgetcsv.csv');
+var_dump($fo->fgetcsv(',', 'invalid'));
+?>
+--CLEAN--
+<?php
+unlink('SplFileObject__fgetcsv.csv');
+?>
+--EXPECTF--
+Warning: SplFileObject::fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_basic.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_basic.phpt
new file mode 100644
index 0000000..96c0290
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_basic.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SplFileObject::fgetcsv with alternative delimeter
+--FILE--
+<?php
+$fp = fopen('SplFileObject__fgetcsv.csv', 'w+');
+fwrite($fp, '"aaa","b""bb","ccc"');
+fclose($fp);
+
+$fo = new SplFileObject('SplFileObject__fgetcsv.csv');
+var_dump($fo->fgetcsv(',', '"', '"'));
+?>
+--CLEAN--
+<?php
+unlink('SplFileObject__fgetcsv.csv');
+?>
+--EXPECTF--
+array(3) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(4) "b"bb"
+ [2]=>
+ string(3) "ccc"
+}
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt
new file mode 100644
index 0000000..c628ac0
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SplFileObject::fgetcsv with default escape character
+--FILE--
+<?php
+$fp = fopen('SplFileObject__fgetcsv.csv', 'w+');
+fwrite($fp, '"aa\"","bb","\"c"');
+fclose($fp);
+
+$fo = new SplFileObject('SplFileObject__fgetcsv.csv');
+var_dump($fo->fgetcsv());
+?>
+--CLEAN--
+<?php
+unlink('SplFileObject__fgetcsv.csv');
+?>
+--EXPECTF--
+array(3) {
+ [0]=>
+ string(4) "aa\""
+ [1]=>
+ string(2) "bb"
+ [2]=>
+ string(3) "\"c"
+}
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt
new file mode 100644
index 0000000..a570318
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SplFileObject::fgetcsv with alternative delimeter
+--FILE--
+<?php
+$fp = fopen('SplFileObject__fgetcsv.csv', 'w+');
+fwrite($fp, '"aaa","b""bb","ccc"');
+fclose($fp);
+
+$fo = new SplFileObject('SplFileObject__fgetcsv.csv');
+var_dump($fo->fgetcsv(',', '"', 'invalid'));
+?>
+--CLEAN--
+<?php
+unlink('SplFileObject__fgetcsv.csv');
+?>
+--EXPECTF--
+Warning: SplFileObject::fgetcsv(): escape must be a character in %s on line %d
+bool(false)
diff --git a/ext/spl/tests/SplFileObject_fpassthru_basic.phpt b/ext/spl/tests/SplFileObject_fpassthru_basic.phpt
new file mode 100644
index 0000000..55b7481
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fpassthru_basic.phpt
@@ -0,0 +1,13 @@
+--TEST--
+SplFileObject::fpassthru function - basic functionality test
+--FILE--
+<?php
+$obj = New SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv');
+$obj->fpassthru();
+?>
+--EXPECT--
+first,second,third
+1,2,3
+4,5,6
+7,8,9
+0,0,0
diff --git a/ext/spl/tests/SplFileObject_fputcsv.phpt b/ext/spl/tests/SplFileObject_fputcsv.phpt
new file mode 100644
index 0000000..66fdbfd
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv.phpt
@@ -0,0 +1,106 @@
+--TEST--
+SplFileObject::fputcsv(): functionality tests
+--FILE--
+<?php
+$file = __DIR__ . '/SplFileObject_fputcsv.csv';
+$fo = new SplFileObject($file, 'w');
+
+$list = array (
+ 0 => 'aaa,bbb',
+ 1 => 'aaa,"bbb"',
+ 2 => '"aaa","bbb"',
+ 3 => 'aaa,bbb',
+ 4 => '"aaa",bbb',
+ 5 => '"aaa", "bbb"',
+ 6 => ',',
+ 7 => 'aaa,',
+ 8 => ',"aaa"',
+ 9 => '"",""',
+ 10 => '"""""",',
+ 11 => '""""",aaa',
+ 12 => 'aaa,bbb ',
+ 13 => 'aaa,"bbb "',
+ 14 => 'aaa"aaa","bbb"bbb',
+ 15 => 'aaa"aaa""",bbb',
+ 16 => 'aaa,"\\"bbb,ccc',
+ 17 => 'aaa"\\"a","bbb"',
+ 18 => '"\\"","aaa"',
+ 19 => '"\\""",aaa',
+);
+
+foreach ($list as $v) {
+ $fo->fputcsv(explode(',', $v));
+}
+unset($fo);
+
+$res = file($file);
+foreach($res as &$val)
+{
+ $val = substr($val, 0, -1);
+}
+echo '$list = ';var_export($res);echo ";\n";
+
+$fp = fopen($file, "r");
+$res = array();
+while($l=fgetcsv($fp))
+{
+ $res[] = join(',',$l);
+}
+fclose($fp);
+
+echo '$list = ';var_export($res);echo ";\n";
+
+?>
+===DONE===
+<?php exit(0); ?>
+--CLEAN--
+<?php
+$file = __DIR__ . '/SplFileObject_fputcsv.csv';
+unlink($file);
+?>
+--EXPECT--
+$list = array (
+ 0 => 'aaa,bbb',
+ 1 => 'aaa,"""bbb"""',
+ 2 => '"""aaa""","""bbb"""',
+ 3 => 'aaa,bbb',
+ 4 => '"""aaa""",bbb',
+ 5 => '"""aaa"""," ""bbb"""',
+ 6 => ',',
+ 7 => 'aaa,',
+ 8 => ',"""aaa"""',
+ 9 => '"""""",""""""',
+ 10 => '"""""""""""""",',
+ 11 => '"""""""""""",aaa',
+ 12 => 'aaa,"bbb "',
+ 13 => 'aaa,"""bbb """',
+ 14 => '"aaa""aaa""","""bbb""bbb"',
+ 15 => '"aaa""aaa""""""",bbb',
+ 16 => 'aaa,"""\\"bbb",ccc',
+ 17 => '"aaa""\\"a""","""bbb"""',
+ 18 => '"""\\"""","""aaa"""',
+ 19 => '"""\\"""""",aaa',
+);
+$list = array (
+ 0 => 'aaa,bbb',
+ 1 => 'aaa,"bbb"',
+ 2 => '"aaa","bbb"',
+ 3 => 'aaa,bbb',
+ 4 => '"aaa",bbb',
+ 5 => '"aaa", "bbb"',
+ 6 => ',',
+ 7 => 'aaa,',
+ 8 => ',"aaa"',
+ 9 => '"",""',
+ 10 => '"""""",',
+ 11 => '""""",aaa',
+ 12 => 'aaa,bbb ',
+ 13 => 'aaa,"bbb "',
+ 14 => 'aaa"aaa","bbb"bbb',
+ 15 => 'aaa"aaa""",bbb',
+ 16 => 'aaa,"\\"bbb,ccc',
+ 17 => 'aaa"\\"a","bbb"',
+ 18 => '"\\"","aaa"',
+ 19 => '"\\""",aaa',
+);
+===DONE===
diff --git a/ext/spl/tests/SplFileObject_fputcsv_002.phpt b/ext/spl/tests/SplFileObject_fputcsv_002.phpt
new file mode 100644
index 0000000..db17493
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_002.phpt
@@ -0,0 +1,42 @@
+--TEST--
+SplFileObject::fputcsv(): Checking data after calling the function
+--FILE--
+<?php
+$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w');
+
+$data = array(1, 2, 'foo', 'haha', array(4, 5, 6), 1.3, null);
+
+$fo->fputcsv($data);
+
+var_dump($data);
+?>
+--CLEAN--
+<?php
+$file = __DIR__ . '/SplFileObject_fputcsv.csv';
+unlink($file);
+?>
+--EXPECTF--
+Notice: Array to string conversion in %s on line %d
+array(7) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ string(3) "foo"
+ [3]=>
+ string(4) "haha"
+ [4]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [5]=>
+ float(1.3)
+ [6]=>
+ NULL
+}
diff --git a/ext/spl/tests/SplFileObject_fputcsv_error.phpt b/ext/spl/tests/SplFileObject_fputcsv_error.phpt
new file mode 100644
index 0000000..8368e42
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_error.phpt
@@ -0,0 +1,35 @@
+--TEST--
+SplFileObject::fputcsv(): error conditions
+--FILE--
+<?php
+$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w');
+
+echo "*** Testing error conditions ***\n";
+// zero argument
+echo "-- Testing fputcsv() with zero argument --\n";
+var_dump( $fo->fputcsv() );
+
+// more than expected no. of args
+echo "-- Testing fputcsv() with more than expected number of arguments --\n";
+$fields = array("fld1", "fld2");
+$delim = ";";
+$enclosure ="\"";
+var_dump( $fo->fputcsv($fields, $delim, $enclosure, $fo) );
+
+echo "Done\n";
+--CLEAN--
+<?php
+$file = __DIR__ . '/SplFileObject_fputcsv.csv';
+unlink($file);
+?>
+--EXPECTF--
+*** Testing error conditions ***
+-- Testing fputcsv() with zero argument --
+
+Warning: SplFileObject::fputcsv() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+-- Testing fputcsv() with more than expected number of arguments --
+
+Warning: SplFileObject::fputcsv() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+Done
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation1.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation1.phpt
new file mode 100644
index 0000000..6780b24
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation1.phpt
@@ -0,0 +1,826 @@
+--TEST--
+Test fputcsv() : usage variations - with all parameters specified
+--FILE--
+<?php
+
+/* Testing fputcsv() to write to a file when all its parameters are provided */
+
+echo "*** Testing fputcsv() : with all parameters specified ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water','fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$file = "$file_path/fputcsv_variation1.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $fo = new SplFileObject($file, 'w');
+ } else {
+ $fo = new SplFileObject($file, $file_modes[$mode_counter]);
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+
+ var_dump( $fo->fputcsv($csv_field, $delimiter, $enclosure) );
+ // check the file pointer position and eof
+ var_dump( $fo->ftell() );
+ var_dump( $fo->eof() );
+ //close the file
+ unset($fo);
+
+ // print the file contents
+ var_dump( file_get_contents($file) );
+
+ //delete file
+ unlink($file);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with all parameters specified ***
+
+-- file opened in r+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in a+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in w+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in x+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in r+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in r+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in a+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in a+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in a+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in w+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in w+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in w+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in x+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in x+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in x+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in r+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in r+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in r+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in a+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in a+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in a+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in w+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in w+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in w+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in x+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in x+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in x+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+Done
+
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation10.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation10.phpt
new file mode 100644
index 0000000..08a2461
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation10.phpt
@@ -0,0 +1,327 @@
+--TEST--
+SplFileObject::fputcsv(): Usage variations -- with line without any CSV fields
+--FILE--
+<?php
+
+/* Testing fputcsv() to write to a file when the field has no CSV format */
+
+echo "*** Testing fputcsv() : with no CSV format in the field ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+
+$fields = array( array('water_fruit\n'),
+ array("water_fruit\n"),
+ array("")
+ );
+
+$file_path = dirname(__FILE__);
+$file = "$file_path/fputcsv_variation10.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($fields as $field) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $fo = new SplFileObject($file, 'w');
+ } else {
+ $fo = new SplFileObject($file, $file_modes[$mode_counter]);
+ }
+ $csv_field = $field;
+
+ // write to a file in csv format
+ var_dump( $fo->fputcsv($csv_field) );
+
+ // check the file pointer position and eof
+ var_dump( $fo->ftell() );
+ var_dump( $fo->eof() );
+ //close the file
+ unset($fo);
+
+ // print the file contents
+ var_dump( file_get_contents($file) );
+
+ //delete file
+ unlink($file);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with no CSV format in the field ***
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water_fruit\n"
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water_fruit\n"
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water_fruit\n"
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water_fruit\n"
+"
+
+-- file opened in r+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in r+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in r+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water_fruit
+"
+"
+
+-- file opened in a+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in a+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in a+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water_fruit
+"
+"
+
+-- file opened in w+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in w+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in w+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water_fruit
+"
+"
+
+-- file opened in x+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in x+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in x+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water_fruit
+"
+"
+
+-- file opened in r+ --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in r+b --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in r+t --
+int(1)
+int(1)
+bool(false)
+string(%d) "
+"
+
+-- file opened in a+ --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in a+b --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in a+t --
+int(1)
+int(1)
+bool(false)
+string(%d) "
+"
+
+-- file opened in w+ --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in w+b --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in w+t --
+int(1)
+int(1)
+bool(false)
+string(%d) "
+"
+
+-- file opened in x+ --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in x+b --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in x+t --
+int(1)
+int(1)
+bool(false)
+string(%d) "
+"
+Done
+
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation11.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation11.phpt
new file mode 100644
index 0000000..c85dd0a
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation11.phpt
@@ -0,0 +1,826 @@
+--TEST--
+SplFileObject::fputcsv(): Usage variations -- with default enclosure value
+--FILE--
+<?php
+
+/* Testing fputcsv() to write to a file when default enclosure value is provided */
+
+echo "*** Testing fputcsv() : with default enclosure value ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water,fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$file = "$file_path/fputcsv_variation11.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $fo = new SplFileObject($file, 'w');
+ } else {
+ $fo = new SplFileObject($file, $file_modes[$mode_counter]);
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( $fo->fputcsv($csv_field, $delimiter) );
+ // check the file pointer position and eof
+ var_dump( $fo->ftell() );
+ var_dump( $fo->eof() );
+ //close the file
+ unset($fo);
+
+ // print the file contents
+ var_dump( file_get_contents($file) );
+
+ //delete file
+ unlink($file);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with default enclosure value ***
+
+-- file opened in r+ --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in r+b --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in r+t --
+int(14)
+int(14)
+bool(false)
+string(%d) ""water,fruit"
+"
+
+-- file opened in a+ --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in a+b --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in a+t --
+int(14)
+int(14)
+bool(false)
+string(%d) ""water,fruit"
+"
+
+-- file opened in w+ --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in w+b --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in w+t --
+int(14)
+int(14)
+bool(false)
+string(%d) ""water,fruit"
+"
+
+-- file opened in x+ --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in x+b --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in x+t --
+int(14)
+int(14)
+bool(false)
+string(%d) ""water,fruit"
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""&water&:&fruit&"
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""&water&:&fruit&"
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""&water&:&fruit&"
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""&water&:&fruit&"
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""=water===fruit="
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""=water===fruit="
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""=water===fruit="
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""=water===fruit="
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) ""-water--fruit-air"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) ""-water--fruit-air"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) ""-water--fruit-air"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) ""-water--fruit-air"
+"
+
+-- file opened in r+ --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in r+b --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in r+t --
+int(24)
+int(24)
+bool(false)
+string(%d) ""-water---fruit---air-"
+"
+
+-- file opened in a+ --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in a+b --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in a+t --
+int(24)
+int(24)
+bool(false)
+string(%d) ""-water---fruit---air-"
+"
+
+-- file opened in w+ --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in w+b --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in w+t --
+int(24)
+int(24)
+bool(false)
+string(%d) ""-water---fruit---air-"
+"
+
+-- file opened in x+ --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in x+b --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in x+t --
+int(24)
+int(24)
+bool(false)
+string(%d) ""-water---fruit---air-"
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+Done
+
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation12.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation12.phpt
new file mode 100644
index 0000000..8bb47d3
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation12.phpt
@@ -0,0 +1,827 @@
+--TEST--
+SplFileObject::fputcsv(): Usage variations -- with default enclosure and different delimiter
+--FILE--
+<?php
+
+/* Testing fputcsv() to write to a file when default enclosure value and delimiter value
+ other than that in the field is provided */
+
+echo "*** Testing fputcsv() : with default enclosure and different delimiter value ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water,fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$file = "$file_path/fputcsv_variation12.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $fo = new SplFileObject($file, 'w');
+ } else {
+ $fo = new SplFileObject($file, $file_modes[$mode_counter]);
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( $fo->fputcsv($csv_field, '+') );
+ // check the file pointer position and eof
+ var_dump( $fo->ftell() );
+ var_dump( $fo->eof() );
+ //close the file
+ unset($fo);
+
+ // print the file contents
+ var_dump( file_get_contents($file) );
+
+ //delete file
+ unlink($file);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with default enclosure and different delimiter value ***
+
+-- file opened in r+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in a+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in w+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in x+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+Done
+
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation13.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation13.phpt
new file mode 100644
index 0000000..b7c2a63
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation13.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test fputcsv() : usage variations - with default enclosure & delimiter of two chars
+--FILE--
+<?php
+
+/* Testing fputcsv() to write to a file when default enclosure value and delimiter
+ of two chars is provided */
+
+echo "*** Testing fputcsv() : with default enclosure & delimiter of two chars ***\n";
+
+$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w');
+
+var_dump($fo->fputcsv(array('water', 'fruit'), ',,', '"'));
+
+unset($fo);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file = __DIR__ . '/SplFileObject_fputcsv.csv';
+unlink($file);
+?>
+--EXPECTF--
+*** Testing fputcsv() : with default enclosure & delimiter of two chars ***
+
+Warning: SplFileObject::fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+Done
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation14.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation14.phpt
new file mode 100644
index 0000000..f8cda0e
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation14.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test fputcsv() : usage variations - with enclosure & delimiter of two chars
+--FILE--
+<?php
+
+/* Testing fputcsv() to write to a file when default enclosure value and delimiter
+ of two chars is provided and file is opened in read only mode */
+
+echo "*** Testing fputcsv() : with enclosure & delimiter of two chars and file opened in read mode ***\n";
+
+$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w');
+
+var_dump($fo->fputcsv(array('water', 'fruit'), ',,', '""'));
+
+unset($fo);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file = __DIR__ . '/SplFileObject_fputcsv.csv';
+unlink($file);
+?>
+--EXPECTF--
+*** Testing fputcsv() : with enclosure & delimiter of two chars and file opened in read mode ***
+
+Warning: SplFileObject::fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+Done
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation5.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation5.phpt
new file mode 100644
index 0000000..9c4c01f
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation5.phpt
@@ -0,0 +1,826 @@
+--TEST--
+Test fputcsv() : usage variations - with default arguments value
+--FILE--
+<?php
+
+/* Testing fputcsv() to write to a file when default arguments values are considered */
+
+echo "*** Testing fputcsv() : with default arguments value ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water','fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$file = "$file_path/fputcsv_variation5.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $fo = new SplFileObject($file, 'w');
+ } else {
+ $fo = new SplFileObject($file, $file_modes[$mode_counter]);
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( $fo->fputcsv($csv_field) );
+ // check the file pointer position and eof
+ var_dump( $fo->ftell() );
+ var_dump( $fo->eof() );
+ //close the file
+ unset($fo);
+
+ // print the file contents
+ var_dump( file_get_contents($file) );
+
+ //delete file
+ unlink($file);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with default arguments value ***
+
+-- file opened in r+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in a+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in w+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in x+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+Done
+
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation6.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation6.phpt
new file mode 100644
index 0000000..6cbb880
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation6.phpt
@@ -0,0 +1,829 @@
+--TEST--
+Test fputcsv() : usage variations - with different delimiter and enclosure
+--FILE--
+<?php
+
+/*
+ Testing fputcsv() to write to a file when delimiter are different from those
+ present in the field to be written to the file
+ */
+
+echo "*** Testing fputcsv() : with different delimiter and enclosure ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water,fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$file = "$file_path/fputcsv_variation6.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $fo = new SplFileObject($file, 'w');
+ } else {
+ $fo = new SplFileObject($file, $file_modes[$mode_counter]);
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( $fo->fputcsv($csv_field, '+', '%') );
+ // check the file pointer position and eof
+ var_dump( $fo->ftell() );
+ var_dump( $fo->eof() );
+ //close the file
+ unset($fo);
+
+ // print the file contents
+ var_dump( file_get_contents($file) );
+
+ //delete file
+ unlink($file);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with different delimiter and enclosure ***
+
+-- file opened in r+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in a+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in w+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in x+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in r+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in r+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in r+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in a+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in a+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in a+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in w+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in w+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in w+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in x+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in x+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in x+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in r+ --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in r+b --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in r+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in a+ --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in a+b --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in a+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in w+ --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in w+b --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in w+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in x+ --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in x+b --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in x+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+Done
+
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation7.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation7.phpt
new file mode 100644
index 0000000..ceb438a
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation7.phpt
@@ -0,0 +1,829 @@
+--TEST--
+Test fputcsv() : usage variations - with different delimiter and same enclosure
+--FILE--
+<?php
+
+/*
+ Testing fputcsv() to write to a file when enclosure is same but delimiter is different from those
+ present in the field to be written to the file
+ */
+
+echo "*** Testing fputcsv() : with different delimiter and same enclosure ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water','fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$file = "$file_path/fputcsv_variation7.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $fo = new SplFileObject($file, 'w');
+ } else {
+ $fo = new SplFileObject($file, $file_modes[$mode_counter]);
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( $fo->fputcsv($csv_field, '+', $enclosure) );
+ // check the file pointer position and eof
+ var_dump( $fo->ftell() );
+ var_dump( $fo->eof() );
+ //close the file
+ unset($fo);
+
+ // print the file contents
+ var_dump( file_get_contents($file) );
+
+ //delete file
+ unlink($file);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with different delimiter and same enclosure ***
+
+-- file opened in r+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in r+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in r+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water+fruit
+"
+
+-- file opened in a+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in a+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in a+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water+fruit
+"
+
+-- file opened in w+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in w+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in w+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water+fruit
+"
+
+-- file opened in x+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in x+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in x+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water+fruit
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in r+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in r+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in a+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in a+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in a+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in w+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in w+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in w+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in x+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in x+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in x+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in r+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in r+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in r+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in a+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in a+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in a+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in w+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in w+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in w+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in x+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in x+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in x+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+Done
+
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation8.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation8.phpt
new file mode 100644
index 0000000..f1a8cbf
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation8.phpt
@@ -0,0 +1,829 @@
+--TEST--
+Test fputcsv() : usage variations - with same delimiter and different enclosure
+--FILE--
+<?php
+
+/*
+ Testing fputcsv() to write to a file when delimiter is same but enclosure is different from those
+ present in the field to be written to the file
+ */
+
+echo "*** Testing fputcsv() : with same delimiter and different enclosure ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water,fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$file = "$file_path/fputcsv_variation8.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $fo = new SplFileObject($file, 'w');
+ } else {
+ $fo = new SplFileObject($file, $file_modes[$mode_counter]);
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( $fo->fputcsv($csv_field, $delimiter, '+') );
+ // check the file pointer position and eof
+ var_dump( $fo->ftell() );
+ var_dump( $fo->eof() );
+ //close the file
+ unset($fo);
+
+ // print the file contents
+ var_dump( file_get_contents($file) );
+
+ //delete file
+ unlink($file);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with same delimiter and different enclosure ***
+
+-- file opened in r+ --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in r+b --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in r+t --
+int(14)
+int(14)
+bool(false)
+string(%d) "+water,fruit+
+"
+
+-- file opened in a+ --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in a+b --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in a+t --
+int(14)
+int(14)
+bool(false)
+string(%d) "+water,fruit+
+"
+
+-- file opened in w+ --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in w+b --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in w+t --
+int(14)
+int(14)
+bool(false)
+string(%d) "+water,fruit+
+"
+
+-- file opened in x+ --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in x+b --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in x+t --
+int(14)
+int(14)
+bool(false)
+string(%d) "+water,fruit+
+"
+
+-- file opened in r+ --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in r+b --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in r+t --
+int(17)
+int(17)
+bool(false)
+string(%d) "+"water","fruit+
+"
+
+-- file opened in a+ --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in a+b --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in a+t --
+int(17)
+int(17)
+bool(false)
+string(%d) "+"water","fruit+
+"
+
+-- file opened in w+ --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in w+b --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in w+t --
+int(17)
+int(17)
+bool(false)
+string(%d) "+"water","fruit+
+"
+
+-- file opened in x+ --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in x+b --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in x+t --
+int(17)
+int(17)
+bool(false)
+string(%d) "+"water","fruit+
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+"water","fruit"+
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+"water","fruit"+
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+"water","fruit"+
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+"water","fruit"+
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+^water^ ^fruit^+
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+^water^ ^fruit^+
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+^water^ ^fruit^+
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+^water^ ^fruit^+
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+&water&:&fruit&+
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+&water&:&fruit&+
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+&water&:&fruit&+
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+&water&:&fruit&+
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+=water===fruit=+
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+=water===fruit=+
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+=water===fruit=+
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+=water===fruit=+
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) "+-water--fruit-air+
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) "+-water--fruit-air+
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) "+-water--fruit-air+
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) "+-water--fruit-air+
+"
+
+-- file opened in r+ --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in r+b --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in r+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "+-water---fruit---air-+
+"
+
+-- file opened in a+ --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in a+b --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in a+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "+-water---fruit---air-+
+"
+
+-- file opened in w+ --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in w+b --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in w+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "+-water---fruit---air-+
+"
+
+-- file opened in x+ --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in x+b --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in x+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "+-water---fruit---air-+
+"
+
+-- file opened in r+ --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in r+b --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in r+t --
+int(26)
+int(26)
+bool(false)
+string(%d) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in a+ --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in a+b --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in a+t --
+int(26)
+int(26)
+bool(false)
+string(%d) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in w+ --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in w+b --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in w+t --
+int(26)
+int(26)
+bool(false)
+string(%d) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in x+ --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in x+b --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in x+t --
+int(26)
+int(26)
+bool(false)
+string(%d) "+&""""&:&"&:,:":&,&:,,,,+
+"
+Done
+
diff --git a/ext/spl/tests/SplFileObject_fscanf_basic.phpt b/ext/spl/tests/SplFileObject_fscanf_basic.phpt
new file mode 100644
index 0000000..5279039
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fscanf_basic.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SplFileObject::fscanf function - basic functionality test
+--FILE--
+<?php
+$obj = New SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv');
+var_dump($obj->fscanf('%s'));
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(18) "first,second,third"
+}
diff --git a/ext/spl/tests/SplFileObject_fseek_error_001.phpt b/ext/spl/tests/SplFileObject_fseek_error_001.phpt
new file mode 100644
index 0000000..0efeb98
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fseek_error_001.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SplFileObject::fseek function - parameters test
+--FILE--
+<?php
+$obj = New SplFileObject(__FILE__);
+$obj->fseek(1,2,3);
+$obj->fseek();
+?>
+--EXPECTF--
+Warning: SplFileObject::fseek() expects at most 2 parameters, 3 given %s
+
+Warning: SplFileObject::fseek() expects at least 1 parameter, 0 given %s
diff --git a/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt b/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt
new file mode 100644
index 0000000..a2eef60
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_ftruncate_error_001.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SplFileObject::ftruncate function - truncating with stream that does not support truncation
+--FILE--
+<?php
+
+//create a basic stream class
+class VariableStream {
+ var $position;
+ var $varname;
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ return true;
+ }
+
+ function url_stat() {
+ }
+}
+stream_wrapper_register("SPLtest", "VariableStream");
+$ftruncate_test = "";
+//end creating stream
+
+//open an SplFileObject using the above test stream
+$obj = New SplFileObject("SPLtest://ftruncate_test");
+try {
+ $obj->ftruncate(1);
+} catch (LogicException $e) {
+ echo($e->getMessage());
+}
+?>
+--EXPECTF--
+Can't truncate file %s
diff --git a/ext/spl/tests/SplFileObject_fwrite_error_001.phpt b/ext/spl/tests/SplFileObject_fwrite_error_001.phpt
new file mode 100644
index 0000000..296a1f3
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fwrite_error_001.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SplFileObject::fpassthru function - parameters test
+--FILE--
+<?php
+$obj = New SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv');
+$obj->fwrite();
+$obj->fwrite('6,6,6',25,null);
+?>
+--EXPECTF--
+Warning: SplFileObject::fwrite() expects at least 1 parameter, 0 given in %s
+
+Warning: SplFileObject::fwrite() expects at most 2 parameters, 3 given in %s
diff --git a/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt b/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt
new file mode 100644
index 0000000..61741a8
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SplFileObject::fwrite function - writing with two parameters length < input string length
+--FILE--
+<?php
+$file = dirname(__FILE__).'/SplFileObject_fwrite_variation_001.txt';
+if(file_exists($file)) {
+ unlink($file);
+}
+$obj = New SplFileObject($file,'w');
+$obj->fwrite('test_write',4);
+var_dump(file_get_contents($file));
+?>
+--CLEAN--
+<?php
+$file = dirname(__FILE__).'/SplFileObject_fwrite_variation_001.txt';
+if(file_exists($file)) {
+ unlink($file);
+}
+?>
+--EXPECT--
+string(4) "test"
diff --git a/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt b/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt
new file mode 100644
index 0000000..31399a0
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SplFileObject::fwrite function - writing with two parameters, length > input string length
+--FILE--
+<?php
+$file = dirname(__FILE__).'/SplFileObject_fwrite_variation_002.txt';
+if(file_exists($file)) {
+ unlink($file);
+}
+$obj = New SplFileObject($file,'w');
+$obj->fwrite('test_write',12);
+var_dump(file_get_contents($file));
+?>
+--CLEAN--
+<?php
+$file = dirname(__FILE__).'/SplFileObject_fwrite_variation_002.txt';
+if(file_exists($file)) {
+ unlink($file);
+}
+?>
+--EXPECT--
+string(10) "test_write"
diff --git a/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt b/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt
new file mode 100644
index 0000000..e21f08f
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SplFileObject::getCsvControl function - basic test
+--FILE--
+<?php
+$obj = New SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv');
+var_dump($obj->getCsvControl());
+
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ %unicode|string%(1) ","
+ [1]=>
+ %unicode|string%(1) """
+}
diff --git a/ext/spl/tests/SplFileObject_getchildren_basic.phpt b/ext/spl/tests/SplFileObject_getchildren_basic.phpt
new file mode 100644
index 0000000..065e8ea
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_getchildren_basic.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplFileObject::getchildren basic
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--FILE--
+<?php
+$s = new SplFileObject( __FILE__ );
+var_dump($s->getChildren());
+
+?>
+--EXPECT--
+NULL
diff --git a/ext/spl/tests/SplFileObject_getchildren_error001.phpt b/ext/spl/tests/SplFileObject_getchildren_error001.phpt
new file mode 100644
index 0000000..9c17a82
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_getchildren_error001.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplFileObject::getchildren error 001
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--FILE--
+<?php
+$s = new SplFileObject( __FILE__ );
+$s->getChildren('string');
+
+?>
+--EXPECTF--
+Warning: SplFileObject::getChildren() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_getflags_basic.phpt b/ext/spl/tests/SplFileObject_getflags_basic.phpt
new file mode 100644
index 0000000..5addadf
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_getflags_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplFileObject::getFlags basic
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+
+file_put_contents('testdata.csv', 'eerste;tweede;derde');
+
+$fo = new SplFileObject('testdata.csv');
+
+$fo->setFlags(SplFileObject::DROP_NEW_LINE);
+var_dump($fo->getFlags());
+?>
+--CLEAN--
+<?php
+unlink('testdata.csv');
+?>
+--EXPECT--
+int(1)
diff --git a/ext/spl/tests/SplFileObject_getflags_error001.phpt b/ext/spl/tests/SplFileObject_getflags_error001.phpt
new file mode 100644
index 0000000..1602f88
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_getflags_error001.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SPL: SplFileObject::getFlags error 001
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+
+file_put_contents('testdata.csv', 'eerste;tweede;derde');
+
+
+$fo = new SplFileObject('testdata.csv');
+$fo->setFlags(SplFileObject::READ_CSV);
+
+$fo->setFlags(SplFileObject::DROP_NEW_LINE);
+
+var_dump($fo->getFlags());
+
+?>
+--CLEAN--
+<?php
+unlink('testdata.csv');
+?>
+--EXPECT--
+int(1)
diff --git a/ext/spl/tests/SplFileObject_getflags_error002.phpt b/ext/spl/tests/SplFileObject_getflags_error002.phpt
new file mode 100644
index 0000000..e2c8255
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_getflags_error002.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: SplFileObject::getFlags error 001
+--CREDITS--
+Erwin Poeze <erwin.poeze@gmail.com>
+--FILE--
+<?php
+
+file_put_contents('testdata.csv', 'eerste;tweede;derde');
+
+$fo = new SplFileObject('testdata.csv');
+$fo->setFlags(SplFileObject::READ_CSV);
+
+$fo->getFlags('fake');
+
+?>
+--CLEAN--
+<?php
+unlink('testdata.csv');
+?>
+--EXPECTF--
+Warning: SplFileObject::getFlags() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_getflags_variation001.phpt b/ext/spl/tests/SplFileObject_getflags_variation001.phpt
new file mode 100644
index 0000000..640de03
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_getflags_variation001.phpt
@@ -0,0 +1,29 @@
+--TEST--
+SPL: SplFileObject::getFlags
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+
+$fo = new SplFileObject(__FILE__);
+
+$fo->setFlags(SplFileObject::DROP_NEW_LINE);
+var_dump($fo->getFlags());
+
+$fo->setFlags(SplFileObject::READ_AHEAD);
+var_dump($fo->getFlags());
+
+$fo->setFlags(SplFileObject::SKIP_EMPTY);
+var_dump($fo->getFlags());
+
+$fo->setFlags(SplFileObject::READ_CSV);
+var_dump($fo->getFlags());
+
+?>
+--EXPECT--
+int(1)
+int(2)
+int(4)
+int(8)
diff --git a/ext/spl/tests/SplFileObject_haschildren_basic.phpt b/ext/spl/tests/SplFileObject_haschildren_basic.phpt
new file mode 100644
index 0000000..1ce00bf
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_haschildren_basic.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplFileObject::haschildren basic
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--FILE--
+<?php
+$s = new SplFileObject( __FILE__ );
+var_dump($s->hasChildren());
+
+?>
+--EXPECT--
+bool(false)
diff --git a/ext/spl/tests/SplFileObject_haschildren_error001.phpt b/ext/spl/tests/SplFileObject_haschildren_error001.phpt
new file mode 100644
index 0000000..0c4e1de
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_haschildren_error001.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplFileObject::haschildren error 001
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--FILE--
+<?php
+$s = new SplFileObject( __FILE__ );
+$s->hasChildren('string');
+
+?>
+--EXPECTF--
+Warning: SplFileObject::hasChildren() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_key_basic.phpt b/ext/spl/tests/SplFileObject_key_basic.phpt
new file mode 100644
index 0000000..4081d31
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_key_basic.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: SplFileObject::key basic
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+
+$s->seek(3);
+echo $s->key();
+?>
+--EXPECT--
+3
diff --git a/ext/spl/tests/SplFileObject_key_error001.phpt b/ext/spl/tests/SplFileObject_key_error001.phpt
new file mode 100644
index 0000000..b0834f0
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_key_error001.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplFileObject::key error
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+
+$s->seek(12);
+$s->next();
+var_dump($s->key());
+var_dump($s->valid());
+?>
+--EXPECT--
+int(13)
+bool(false)
diff --git a/ext/spl/tests/SplFileObject_key_error002.phpt b/ext/spl/tests/SplFileObject_key_error002.phpt
new file mode 100644
index 0000000..8fc9b7f
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_key_error002.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplFileObject::key error
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+
+$s->seek(120);
+$s->next();
+var_dump($s->key());
+var_dump($s->valid());
+?>
+--EXPECT--
+int(13)
+bool(false)
diff --git a/ext/spl/tests/SplFileObject_key_error003.phpt b/ext/spl/tests/SplFileObject_key_error003.phpt
new file mode 100644
index 0000000..7568cf5
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_key_error003.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: SplFileObject::key error
+--CREDITS--
+Erwin Poeze <erwin.poeze AT gmail.com>
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+$s->key(3);
+?>
+--EXPECTF--
+Warning: SplFileObject::key() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_next_basic.phpt b/ext/spl/tests/SplFileObject_next_basic.phpt
new file mode 100644
index 0000000..59dc7ab
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_next_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplFileObject::next basic
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+echo $s->current();
+$s->next();
+
+echo $s->current();
+
+?>
+--EXPECT--
+<?php
+//line 2
diff --git a/ext/spl/tests/SplFileObject_next_variation001.phpt b/ext/spl/tests/SplFileObject_next_variation001.phpt
new file mode 100644
index 0000000..34771dd
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_next_variation001.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: SplFileObject::next variation 001
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+
+$s->seek(13);
+echo $s->current();
+
+$s->next();
+echo $s->current();
+var_dump($s->valid());
+?>
+--EXPECT--
+?>
+bool(false)
diff --git a/ext/spl/tests/SplFileObject_next_variation002.phpt b/ext/spl/tests/SplFileObject_next_variation002.phpt
new file mode 100644
index 0000000..d48ff8c
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_next_variation002.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: SplFileObject::next variation 002, read ahead
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+$s->seek(2);
+echo $s->current();
+$s->next();
+echo $s->current();
+
+$s->setFlags(SplFileObject::READ_AHEAD);
+
+$s->seek(2);
+echo $s->current();
+$s->next();
+echo $s->current();
+?>
+--EXPECT--
+//line 3
+//line 4
+//line 3
+//line 4
diff --git a/ext/spl/tests/SplFileObject_rewind_basic.phpt b/ext/spl/tests/SplFileObject_rewind_basic.phpt
new file mode 100644
index 0000000..331c587
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_rewind_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: SplFileObject::rewind basic
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+
+$s->seek(3);
+
+$s->rewind();
+echo $s->current();
+?>
+--EXPECT--
+<?php
diff --git a/ext/spl/tests/SplFileObject_rewind_error001.phpt b/ext/spl/tests/SplFileObject_rewind_error001.phpt
new file mode 100644
index 0000000..bdb3301
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_rewind_error001.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SPL: SplFileObject::rewind() with a parameter.
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+
+file_put_contents('testdata.csv', 'eerste;tweede;derde');
+
+$fo = new SplFileObject('testdata.csv');
+
+$fo->rewind( "invalid" );
+
+?>
+--EXPECTF--
+Warning: SplFileObject::rewind() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_rewind_variation001.phpt b/ext/spl/tests/SplFileObject_rewind_variation001.phpt
new file mode 100644
index 0000000..d835c44
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_rewind_variation001.phpt
@@ -0,0 +1,28 @@
+--TEST--
+SPL: SplFileObject::rewind variation 001
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+
+$s->seek(15);
+echo $s->current();
+$s->next();
+echo $s->current();
+var_dump($s->valid());
+$s->rewind();
+var_dump($s->valid());
+echo $s->current();
+?>
+--EXPECT--
+?>
+bool(false)
+bool(true)
+<?php
diff --git a/ext/spl/tests/SplFileObject_seek_basic.phpt b/ext/spl/tests/SplFileObject_seek_basic.phpt
new file mode 100644
index 0000000..7106f70
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_seek_basic.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: SplFileObject::seek basic
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+
+$s->seek(2);
+echo $s->current();
+?>
+--EXPECT--
+//line 3
diff --git a/ext/spl/tests/SplFileObject_seek_error002.phpt b/ext/spl/tests/SplFileObject_seek_error002.phpt
new file mode 100644
index 0000000..057c8d3
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_seek_error002.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SPL: SplFileObject::seek error 001
+--CREDITS--
+Ricardo Oedietram <ricardo@odracir.nl>
+Erwin Poeze <erwin.poeze@gmail.com>
+#PFZ June PHP TestFest 2012
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+
+$s->seek(20);
+echo $s->current();
+?>
+--EXPECT--
diff --git a/ext/spl/tests/SplFileObject_seek_error_001.phpt b/ext/spl/tests/SplFileObject_seek_error_001.phpt
new file mode 100644
index 0000000..bcf44b0
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_seek_error_001.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SplFileObject::seek function - test parameters
+--FILE--
+<?php
+$obj = New SplFileObject(__FILE__);
+$obj->seek(1,2);
+$obj->seek();
+try {
+ $obj->seek(-1);
+} catch (LogicException $e) {
+ echo($e->getMessage());
+}
+?>
+--EXPECTF--
+
+Warning: SplFileObject::seek() expects exactly 1 parameter, 2 given in %s
+
+Warning: SplFileObject::seek() expects exactly 1 parameter, 0 given in %s
+Can't seek file %s to negative line %s
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt
new file mode 100644
index 0000000..b263060
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: SplFileObject::setCsvControl basic
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--FILE--
+<?php
+file_put_contents('csv_control_data.csv',
+<<<CDATA
+'groene appelen'|10
+'gele bananen'|20
+'rode kersen'|30
+CDATA
+);
+$s = new SplFileObject('csv_control_data.csv');
+$s->setFlags(SplFileObject::READ_CSV);
+$s->setCsvControl('|', '\'', '/');
+foreach ($s as $row) {
+ list($fruit, $quantity) = $row;
+ echo "$fruit : $quantity\n";
+}
+?>
+--CLEAN--
+<?php
+unlink('csv_control_data.csv');
+?>
+--EXPECT--
+groene appelen : 10
+gele bananen : 20
+rode kersen : 30
+
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt
new file mode 100644
index 0000000..f582a4a
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: SplFileObject::setCsvControl error 001
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--FILE--
+<?php
+file_put_contents('csv_control_data.csv',
+<<<CDATA
+'groene appelen'|10
+'gele bananen'|20
+'rode kersen'|30
+CDATA
+);
+$s = new SplFileObject('csv_control_data.csv');
+$s->setFlags(SplFileObject::READ_CSV);
+$s->setCsvControl('||');
+?>
+--CLEAN--
+<?php
+unlink('csv_control_data.csv');
+?>
+--EXPECTF--
+Warning: SplFileObject::setCsvControl(): delimiter must be a character in %s on line %d
+
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt
new file mode 100644
index 0000000..bcfd9c4
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: SplFileObject::setCsvControl error 002
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--FILE--
+<?php
+file_put_contents('csv_control_data.csv',
+<<<CDATA
+'groene appelen'|10
+'gele bananen'|20
+'rode kersen'|30
+CDATA
+);
+$s = new SplFileObject('csv_control_data.csv');
+$s->setFlags(SplFileObject::READ_CSV);
+$s->setCsvControl('|', 'two');
+?>
+--CLEAN--
+<?php
+unlink('csv_control_data.csv');
+?>
+--EXPECTF--
+Warning: SplFileObject::setCsvControl(): enclosure must be a character in %s on line %d
+
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt
new file mode 100644
index 0000000..8b1f54d
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SPL: SplFileObject::setCsvControl error 003
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--INI--
+include_path=.
+--FILE--
+<?php
+file_put_contents('csv_control_data.csv',
+<<<CDATA
+'groene appelen'|10
+'gele bananen'|20
+'rode kersen'|30
+CDATA
+);
+$s = new SplFileObject('csv_control_data.csv');
+$s->setFlags(SplFileObject::READ_CSV);
+$s->setCsvControl('|', '\'', 'three');
+?>
+--CLEAN--
+<?php
+unlink('csv_control_data.csv');
+?>
+--EXPECTF--
+Warning: SplFileObject::setCsvControl(): escape must be a character in %s on line %d
+
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt
new file mode 100644
index 0000000..7aaf8a3
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: SplFileObject::setCsvControl variation 001
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--FILE--
+<?php
+file_put_contents('csv_control_data.csv',
+<<<CDATA
+"groene appelen",10
+"gele bananen",20
+"rode kersen",30
+CDATA
+);
+$s = new SplFileObject('csv_control_data.csv');
+$s->setFlags(SplFileObject::READ_CSV);
+$s->setCsvControl();
+foreach ($s as $row) {
+ list($fruit, $quantity) = $row;
+ echo "$fruit : $quantity\n";
+}
+?>
+--CLEAN--
+<?php
+unlink('csv_control_data.csv');
+?>
+--EXPECT--
+groene appelen : 10
+gele bananen : 20
+rode kersen : 30
+
diff --git a/ext/spl/tests/SplFileObject_testinput.csv b/ext/spl/tests/SplFileObject_testinput.csv
new file mode 100644
index 0000000..41a9e31
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_testinput.csv
@@ -0,0 +1,5 @@
+first,second,third
+1,2,3
+4,5,6
+7,8,9
+0,0,0
diff --git a/ext/spl/tests/SplFixedArray__construct_param_array.phpt b/ext/spl/tests/SplFixedArray__construct_param_array.phpt
new file mode 100644
index 0000000..d63d7cc
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray__construct_param_array.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SplFixedArray::__construct() with array passed as integer.
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplFixedArray( array("string", 1) );
+
+?>
+--EXPECTF--
+Warning: SplFixedArray::__construct() expects parameter 1 to be long, array given in %s on line %d \ No newline at end of file
diff --git a/ext/spl/tests/SplFixedArray__construct_param_float.phpt b/ext/spl/tests/SplFixedArray__construct_param_float.phpt
new file mode 100644
index 0000000..670a109
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray__construct_param_float.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SplFixedArray::__construct() with float passed as parameter.
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplFixedArray( 3.141 );
+
+echo $array->getSize();
+
+?>
+--EXPECT--
+3 \ No newline at end of file
diff --git a/ext/spl/tests/SplFixedArray__construct_param_null.phpt b/ext/spl/tests/SplFixedArray__construct_param_null.phpt
new file mode 100644
index 0000000..3b1543d
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray__construct_param_null.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SplFixedArray::__construct() with null passed as parameter.
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplFixedArray( NULL );
+
+print_r( $array );
+
+?>
+--EXPECTF--
+SplFixedArray Object
+(
+) \ No newline at end of file
diff --git a/ext/spl/tests/SplFixedArray__construct_param_string.phpt b/ext/spl/tests/SplFixedArray__construct_param_string.phpt
new file mode 100644
index 0000000..3a7e734
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray__construct_param_string.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SplFixedArray::__construct() with string passed as parameter.
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplFixedArray( "string" );
+
+?>
+--EXPECTF--
+Warning: SplFixedArray::__construct() expects parameter 1 to be long, %unicode_string_optional% given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt b/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt
new file mode 100644
index 0000000..6582f84
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_construct_param_SplFixedArray.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Create an SplFixedArray using an SplFixedArray object.
+--CREDITS--
+Philip Norton philipnorton42@gmail.com
+--FILE--
+<?php
+$array = new SplFixedArray(new SplFixedArray(3));
+var_dump($array);
+?>
+--EXPECTF--
+Warning: SplFixedArray::__construct() expects parameter 1 to be long, object given in %s on line %d
+object(SplFixedArray)#1 (0) {
+} \ No newline at end of file
diff --git a/ext/spl/tests/SplFixedArray_count_checkParams.phpt b/ext/spl/tests/SplFixedArray_count_checkParams.phpt
new file mode 100644
index 0000000..5cbe2e8
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_count_checkParams.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Makes sure that an integer cannot be passed into the count() method of the splFixedArray.
+--CREDITS--
+PHPNW Test Fest 2009 - Rick Ogden
+--FILE--
+<?php
+$ar = new SplFixedArray(3);
+$ar[0] = 1;
+$ar[1] = 2;
+$ar[2] = 3;
+
+echo $ar->count(3);
+?>
+--EXPECTF--
+Warning: SplFixedArray::count() expects exactly 0 parameters, 1 given in %s on line %d
+
diff --git a/ext/spl/tests/SplFixedArray_count_param_int.phpt b/ext/spl/tests/SplFixedArray_count_param_int.phpt
new file mode 100644
index 0000000..108bb2d
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_count_param_int.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Creates array, uses the count function to get the size of the array, but passes a parameter.
+--CREDITS--
+Philip Norton philipnorton42@gmail.com
+--FILE--
+<?php
+$array = new SplFixedArray(5);
+echo $array->count(3);
+?>
+--EXPECTF--
+Warning: SplFixedArray::count() expects exactly 0 parameters, 1 given in %s on line %d \ No newline at end of file
diff --git a/ext/spl/tests/SplFixedArray_current_param.phpt b/ext/spl/tests/SplFixedArray_current_param.phpt
new file mode 100644
index 0000000..71f5d3a
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_current_param.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SplFixedArray::current() with a parameter. *BUG*
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplFixedArray( 3 );
+
+$array[0] = "Hello";
+$array[1] = "world";
+$array[2] = "elePHPant";
+
+foreach ( $array as $value ) {
+ echo $array->current( array("this","should","not","execute") );
+}
+
+?>
+--EXPECTF--
+Warning: SplFixedArray::current() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: SplFixedArray::current() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: SplFixedArray::current() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_001.phpt b/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_001.phpt
new file mode 100644
index 0000000..36ecf46
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_001.phpt
@@ -0,0 +1,10 @@
+--TEST--
+pass an integer into fromArray()
+--CREDITS--
+PHPNW Testfest 2009 - Lorna Mitchell
+--FILE--
+<?php
+echo SplFixedArray::fromArray(17954);
+?>
+--EXPECTF--
+Warning: SplFixedArray::fromArray() expects parameter 1 to be array, integer given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_002.phpt b/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_002.phpt
new file mode 100644
index 0000000..ba81428
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_002.phpt
@@ -0,0 +1,10 @@
+--TEST--
+pass a string into fromArray()
+--CREDITS--
+PHPNW Testfest 2009 - Lorna Mitchell
+--FILE--
+<?php
+echo SplFixedArray::fromArray('hello');
+?>
+--EXPECTF--
+Warning: SplFixedArray::fromArray() expects parameter 1 to be array, %unicode_string_optional% given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt b/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt
new file mode 100644
index 0000000..034d457
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Create a SplFixedArray from an array using the fromArray() function use the default behaviour of preserve the indexes.
+--CREDITS--
+Philip Norton philipnorton42@gmail.com
+--FILE--
+<?php
+$array = SplFixedArray::fromArray(array(1 => 1,
+ 2 => '2',
+ 3 => false));
+var_dump($array);
+?>
+--EXPECTF--
+object(SplFixedArray)#1 (4) {
+ [0]=>
+ NULL
+ [1]=>
+ int(1)
+ [2]=>
+ %string|unicode%(1) "2"
+ [3]=>
+ bool(false)
+}
diff --git a/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt b/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt
new file mode 100644
index 0000000..ecae2ab
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Create a SplFixedArray from an array using the fromArray() function don't try to preserve the indexes.
+--CREDITS--
+Philip Norton philipnorton42@gmail.com
+--FILE--
+<?php
+$array = SplFixedArray::fromArray(array(1 => 1,
+ 2 => '2',
+ 3 => false),
+ false);
+var_dump($array);
+?>
+--EXPECTF--
+object(SplFixedArray)#1 (3) {
+ [0]=>
+ int(1)
+ [1]=>
+ %string|unicode%(1) "2"
+ [2]=>
+ bool(false)
+}
diff --git a/ext/spl/tests/SplFixedArray_fromarray_param_boolean.phpt b/ext/spl/tests/SplFixedArray_fromarray_param_boolean.phpt
new file mode 100644
index 0000000..80d9669
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_fromarray_param_boolean.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Tries to create a SplFixedArray using a boolean value.
+--CREDITS--
+Philip Norton philipnorton42@gmail.com
+--FILE--
+<?php
+$array = SplFixedArray::fromArray(true);
+?>
+--EXPECTF--
+Warning: SplFixedArray::fromArray() expects parameter 1 to be array, boolean given in %s on line %d \ No newline at end of file
diff --git a/ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt b/ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt
new file mode 100644
index 0000000..f57fe78
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Tries to create a SplFixedArray using the fromArray() function and a multi dimentional array.
+--CREDITS--
+Philip Norton philipnorton42@gmail.com
+--FILE--
+<?php
+$array = SplFixedArray::fromArray(array(array('1')));
+var_dump($array);
+?>
+--EXPECTF--
+object(SplFixedArray)#1 (1) {
+ [0]=>
+ array(1) {
+ [0]=>
+ %string|unicode%(1) "1"
+ }
+}
diff --git a/ext/spl/tests/SplFixedArray_getSize_pass_param.phpt b/ext/spl/tests/SplFixedArray_getSize_pass_param.phpt
new file mode 100644
index 0000000..ef4f40c
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_getSize_pass_param.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SplFixedArray::getSize() pass a parameter when none are expected
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+$fixed_array = new SplFixedArray(2);
+echo "*test* ".$fixed_array->getSize(3);
+?>
+--EXPECTF--
+Warning: SplFixedArray::getSize() expects exactly 0 parameters, 1 given in %s on line %d
+*test*
diff --git a/ext/spl/tests/SplFixedArray_key_param.phpt b/ext/spl/tests/SplFixedArray_key_param.phpt
new file mode 100644
index 0000000..300e6df
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_key_param.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SplFixedArray::key() with a parameter passed. This is a bug and an error should be called.
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplFixedArray( 3 );
+
+$array[0] = "Hello";
+$array[1] = "world";
+$array[2] = "elePHPant";
+
+foreach ( $array as $value ) {
+ echo $array->key( array("this","should","not","execute") );
+}
+
+?>
+--EXPECTF--
+Warning: SplFixedArray::key() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: SplFixedArray::key() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: SplFixedArray::key() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_key_setsize.phpt b/ext/spl/tests/SplFixedArray_key_setsize.phpt
new file mode 100644
index 0000000..97e4811
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_key_setsize.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SplFixedArray::key() when the array has a size higher than the amount of values specified.
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplFixedArray( 4 );
+
+$array[0] = "Hello";
+$array[1] = "world";
+$array[2] = "elePHPant";
+
+foreach ( $array as $value ) {
+ echo $array->key( );
+}
+
+?>
+--EXPECT--
+0123 \ No newline at end of file
diff --git a/ext/spl/tests/SplFixedArray_next_param.phpt b/ext/spl/tests/SplFixedArray_next_param.phpt
new file mode 100644
index 0000000..5e8cb63
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_next_param.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SplFixedArray::next() with a parameter. *BUG*
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplFixedArray( 4 );
+
+$array[0] = "Hello";
+$array[1] = "world";
+$array[2] = "elePHPant";
+
+$array->next( "invalid" );
+
+?>
+--EXPECTF--
+Warning: SplFixedArray::next() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_offsetExists_invalid_parameter.phpt b/ext/spl/tests/SplFixedArray_offsetExists_invalid_parameter.phpt
new file mode 100644
index 0000000..76ee2f5
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_offsetExists_invalid_parameter.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL FixedArray offsetExists throws error only one parameter
+--CREDITS--
+PHPNW TestFest 2009 - Ben Longden
+--FILE--
+<?php
+$array = new SplFixedArray(5);
+$a = $array->offsetExists();
+if(is_null($a)) {
+ echo 'PASS';
+}
+?>
+--EXPECTF--
+Warning: SplFixedArray::offsetExists() expects exactly 1 parameter, 0 given in %s on line %d
+PASS
diff --git a/ext/spl/tests/SplFixedArray_offsetExists_less_than_zero.phpt b/ext/spl/tests/SplFixedArray_offsetExists_less_than_zero.phpt
new file mode 100644
index 0000000..9bfda34
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_offsetExists_less_than_zero.phpt
@@ -0,0 +1,13 @@
+--TEST--
+SPL FixedArray offsetExists behaviour on a negative index
+--CREDITS--
+PHPNW TestFest 2009 - Ben Longden
+--FILE--
+<?php
+$array = new SplFixedArray(5);
+if($array->offsetExists(-10) === false) {
+ echo 'PASS';
+}
+?>
+--EXPECT--
+PASS
diff --git a/ext/spl/tests/SplFixedArray_offsetGet_invalid_parameter.phpt b/ext/spl/tests/SplFixedArray_offsetGet_invalid_parameter.phpt
new file mode 100644
index 0000000..71a1bf8
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_offsetGet_invalid_parameter.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL FixedArray offsetGet throws error on no parameter
+--CREDITS--
+PHPNW TestFest 2009 - Ben Longden
+--FILE--
+<?php
+$array = new SplFixedArray(5);
+$array[0] = 'a';
+$a = $array->offsetGet();
+if(is_null($a)) {
+ echo 'PASS';
+}
+?>
+--EXPECTF--
+Warning: SplFixedArray::offsetGet() expects exactly 1 parameter, 0 given in %s on line %d
+PASS
diff --git a/ext/spl/tests/SplFixedArray_offsetSet_invalid_parameter.phpt b/ext/spl/tests/SplFixedArray_offsetSet_invalid_parameter.phpt
new file mode 100644
index 0000000..4e43a52
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_offsetSet_invalid_parameter.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL FixedArray offsetSet throws error on no parameters
+--CREDITS--
+PHPNW TestFest 2009 - Ben Longden
+--FILE--
+<?php
+$array = new SplFixedArray(5);
+$a = $array->offsetSet();
+if(is_null($a)) {
+ echo 'PASS';
+}
+?>
+--EXPECTF--
+Warning: SplFixedArray::offsetSet() expects exactly 2 parameters, 0 given in %s on line %d
+PASS
diff --git a/ext/spl/tests/SplFixedArray_offsetSet_one_invalid_parameter.phpt b/ext/spl/tests/SplFixedArray_offsetSet_one_invalid_parameter.phpt
new file mode 100644
index 0000000..c19cd01
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_offsetSet_one_invalid_parameter.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL FixedArray offsetSet throws error only one parameter
+--CREDITS--
+PHPNW TestFest 2009 - Ben Longden
+--FILE--
+<?php
+$array = new SplFixedArray(5);
+$a = $array->offsetSet(2);
+if(is_null($a)) {
+ echo 'PASS';
+}
+?>
+--EXPECTF--
+Warning: SplFixedArray::offsetSet() expects exactly 2 parameters, 1 given in %s on line %d
+PASS
diff --git a/ext/spl/tests/SplFixedArray_offsetUnset_invalid_parameter.phpt b/ext/spl/tests/SplFixedArray_offsetUnset_invalid_parameter.phpt
new file mode 100644
index 0000000..40a372b
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_offsetUnset_invalid_parameter.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL FixedArray offsetUnset throws error on no parameter
+--CREDITS--
+PHPNW TestFest 2009 - Ben Longden
+--FILE--
+<?php
+$array = new SplFixedArray(5);
+$a = $array->offsetUnset();
+if(is_null($a)) {
+ echo 'PASS';
+}
+?>
+--EXPECTF--
+Warning: SplFixedArray::offsetUnset() expects exactly 1 parameter, 0 given in %s on line %d
+PASS
diff --git a/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt b/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt
new file mode 100644
index 0000000..21976b5
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Check removing an item from an array when the offset is not an integer.
+--CREDITS--
+PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
+--FILE--
+<?php
+ // Create a fixed array
+ $fixedArray = new SplFixedArray(5);
+
+ // Fill it up
+ for ($i=0; $i < 5; $i++) {
+ $fixedArray[$i] = "PHPNW Testfest";
+ }
+
+ // remove an item
+ $fixedArray->offsetUnset("4");
+
+ var_dump($fixedArray);
+
+?>
+--EXPECTF--
+object(SplFixedArray)#1 (5) {
+ [0]=>
+ %string|unicode%(14) "PHPNW Testfest"
+ [1]=>
+ %string|unicode%(14) "PHPNW Testfest"
+ [2]=>
+ %string|unicode%(14) "PHPNW Testfest"
+ [3]=>
+ %string|unicode%(14) "PHPNW Testfest"
+ [4]=>
+ NULL
+}
diff --git a/ext/spl/tests/SplFixedArray_rewind_param.phpt b/ext/spl/tests/SplFixedArray_rewind_param.phpt
new file mode 100644
index 0000000..7002efb
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_rewind_param.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SplFixedArray::rewind() with a parameter. *BUG*
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+$array = new SplFixedArray( 4 );
+
+$array[0] = "Hello";
+$array[1] = "world";
+$array[2] = "elePHPant";
+
+$array->rewind( "invalid" );
+
+?>
+--EXPECTF--
+Warning: SplFixedArray::rewind() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_setSize_filled_to_smaller.phpt b/ext/spl/tests/SplFixedArray_setSize_filled_to_smaller.phpt
new file mode 100644
index 0000000..a460747
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_setSize_filled_to_smaller.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Create array, fills it with and resizes it to lower value.
+--CREDITS--
+Philip Norton philipnorton42@gmail.com
+--FILE--
+<?php
+$array = new SplFixedArray(5);
+$array[0] = 1;
+$array[1] = 1;
+$array[2] = 1;
+$array[3] = 1;
+$array[4] = 1;
+$array->setSize(2);
+var_dump($array);
+?>
+--EXPECT--
+object(SplFixedArray)#1 (2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+} \ No newline at end of file
diff --git a/ext/spl/tests/SplFixedArray_setSize_param_array.phpt b/ext/spl/tests/SplFixedArray_setSize_param_array.phpt
new file mode 100644
index 0000000..269a45d
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_setSize_param_array.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SplFixedArray::setSize() with an array parameter
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+$fixed_array = new SplFixedArray(2);
+$fixed_array->setSize(array());
+var_dump($fixed_array);
+?>
+--EXPECTF--
+Warning: SplFixedArray::setSize() expects parameter 1 to be long, array given in %s on line %d
+object(SplFixedArray)#1 (2) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+}
diff --git a/ext/spl/tests/SplFixedArray_setSize_param_float.phpt b/ext/spl/tests/SplFixedArray_setSize_param_float.phpt
new file mode 100644
index 0000000..c65686c
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_setSize_param_float.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SplFixedArray::setSize() with a float param
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+$fixed_array = new SplFixedArray(2);
+$fixed_array->setSize(3.14159);
+var_dump($fixed_array);
+?>
+--EXPECTF--
+object(SplFixedArray)#1 (3) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+ [2]=>
+ NULL
+}
diff --git a/ext/spl/tests/SplFixedArray_setSize_param_null.phpt b/ext/spl/tests/SplFixedArray_setSize_param_null.phpt
new file mode 100644
index 0000000..ddb37be
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_setSize_param_null.phpt
@@ -0,0 +1,13 @@
+--TEST--
+SplFixedArray::setSize() with a null parameter
+--CREDITS--
+PHPNW Testfest 2009 - Adrian Hardy
+--FILE--
+<?php
+$fixed_array = new SplFixedArray(2);
+$fixed_array->setSize(null);
+var_dump($fixed_array);
+?>
+--EXPECT--
+object(SplFixedArray)#1 (0) {
+}
diff --git a/ext/spl/tests/SplFixedArray_setSize_reduce.phpt b/ext/spl/tests/SplFixedArray_setSize_reduce.phpt
new file mode 100644
index 0000000..eb8e1d9
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_setSize_reduce.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL FixedArray can reduce size of array
+--CREDITS--
+PHPNW TestFest 2009 - Ben Longden
+--FILE--
+<?php
+$array = new SplFixedArray(5);
+$array[0] = 'a';
+$array[1] = 'b';
+$array[2] = 'c';
+$array[3] = 'd';
+$array[4] = 'e';
+$array->setSize(3);
+print_r($array);
+?>
+--EXPECT--
+SplFixedArray Object
+(
+ [0] => a
+ [1] => b
+ [2] => c
+)
diff --git a/ext/spl/tests/SplFixedArray_setsize_001.phpt b/ext/spl/tests/SplFixedArray_setsize_001.phpt
new file mode 100644
index 0000000..925912c
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_setsize_001.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: FixedArray: setsize - populate array, then shrink
+--CREDITS--
+PHPNW TestFest2009 - Rowan Merewood <rowan@merewood.org>
+--FILE--
+<?php
+$array = new SplFixedArray(5);
+$array[0] = 'one';
+$array[1] = 'two';
+$array[2] = 'three';
+$array[3] = 'four';
+$array[4] = 'five';
+$array->setSize(2);
+var_dump($array);
+?>
+--EXPECTF--
+object(SplFixedArray)#1 (2) {
+ [0]=>
+ %string|unicode%(3) "one"
+ [1]=>
+ %string|unicode%(3) "two"
+}
diff --git a/ext/spl/tests/SplFixedArray_setsize_grow.phpt b/ext/spl/tests/SplFixedArray_setsize_grow.phpt
new file mode 100644
index 0000000..418d1ac
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_setsize_grow.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SplFixedArray::setSize() grow
+--CREDITS--
+PHPNW Test Fest 2009 - Jordan Hatch
+--FILE--
+<?php
+
+echo "\n";
+
+$array = new SplFixedArray(2);
+
+$array[0] = "Value 1";
+$array[1] = "Value 2";
+
+$array->setSize(4);
+
+$array[2] = "Value 3";
+$array[3] = "Value 4";
+
+print_r($array);
+
+?>
+--EXPECT--
+SplFixedArray Object
+(
+ [0] => Value 1
+ [1] => Value 2
+ [2] => Value 3
+ [3] => Value 4
+) \ No newline at end of file
diff --git a/ext/spl/tests/SplFixedArray_setsize_shrink.phpt b/ext/spl/tests/SplFixedArray_setsize_shrink.phpt
new file mode 100644
index 0000000..2130cf8
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_setsize_shrink.phpt
@@ -0,0 +1,28 @@
+--TEST--
+shrink a full array of integers
+--CREDITS--
+PHPNW Testfest 2009 - Lorna Mitchell
+--FILE--
+<?php
+$array = new SplFixedArray(5);
+$array[0] = 1;
+$array[1] = 1;
+$array[2] = 1;
+$array[3] = 1;
+$array[4] = 1;
+
+$array->setSize(4);
+var_dump($array);
+
+?>
+--EXPECT--
+object(SplFixedArray)#1 (4) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ [2]=>
+ int(1)
+ [3]=>
+ int(1)
+}
diff --git a/ext/spl/tests/SplFixedArray_toArray_with-params.phpt b/ext/spl/tests/SplFixedArray_toArray_with-params.phpt
new file mode 100644
index 0000000..8864362
--- /dev/null
+++ b/ext/spl/tests/SplFixedArray_toArray_with-params.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Check that passing a parameter to toArray() produces a correct error
+--CREDITS--
+PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
+--FILE--
+<?php
+ // Create a fixed array
+ $fixedArray = new SplFixedArray(5);
+
+ // Fill it up
+ for ($i=0; $i < 5; $i++) {
+ $fixedArray[$i] = "PHPNW Testfest";
+ }
+
+ // Test count() returns correct error when parameters are passed.
+ $fixedArray->count(1);
+?>
+--EXPECTF--
+Warning: SplFixedArray::count() expects exactly 0 parameters, %d given in %s on line %d
diff --git a/ext/spl/tests/SplHeap_count_invalid_parameter.phpt b/ext/spl/tests/SplHeap_count_invalid_parameter.phpt
new file mode 100644
index 0000000..727790e
--- /dev/null
+++ b/ext/spl/tests/SplHeap_count_invalid_parameter.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Check that SplHeap::count generate a warning and returns NULL when param passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ new stdClass,
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $h = new SplMaxHeap();
+
+ var_dump($h->count($input));
+}
+
+?>
+--EXPECTF--
+Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplHeap_extract_invalid_parameter.phpt b/ext/spl/tests/SplHeap_extract_invalid_parameter.phpt
new file mode 100644
index 0000000..ba03976
--- /dev/null
+++ b/ext/spl/tests/SplHeap_extract_invalid_parameter.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Check that SplHeap::extract generate a warning and returns NULL when param passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ new stdClass,
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $h = new SplMaxHeap();
+
+ var_dump($h->extract($input));
+}
+
+?>
+--EXPECTF--
+Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplHeap_insert_invalid_parameter.phpt b/ext/spl/tests/SplHeap_insert_invalid_parameter.phpt
new file mode 100644
index 0000000..86c6b63
--- /dev/null
+++ b/ext/spl/tests/SplHeap_insert_invalid_parameter.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Check that SplHeap::insert generate a warning and returns NULL when $value is missing
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$h = new SplMaxHeap();
+
+var_dump($h->insert());
+
+?>
+--EXPECTF--
+Warning: SplHeap::insert() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplHeap_isEmpty.phpt b/ext/spl/tests/SplHeap_isEmpty.phpt
new file mode 100644
index 0000000..e179dbc
--- /dev/null
+++ b/ext/spl/tests/SplHeap_isEmpty.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Check that SplHeap::isEmpty standard success test
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$h = new SplMaxHeap();
+
+var_dump($h->isEmpty());
+
+?>
+--EXPECTF--
+bool(true)
+
diff --git a/ext/spl/tests/SplHeap_isEmpty_invalid_parameter.phpt b/ext/spl/tests/SplHeap_isEmpty_invalid_parameter.phpt
new file mode 100644
index 0000000..021aff4
--- /dev/null
+++ b/ext/spl/tests/SplHeap_isEmpty_invalid_parameter.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Check that SplHeap::isEmpty generate a warning and returns NULL when param passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ new stdClass,
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $h = new SplMaxHeap();
+
+ var_dump($h->isEmpty($input));
+}
+
+?>
+--EXPECTF--
+Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_addAll_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_addAll_invalid_parameter.phpt
new file mode 100644
index 0000000..62605b1
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_addAll_invalid_parameter.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Check that SplObjectStorage::addAll generate a warning and returns NULL when passed non-object param
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+
+ var_dump($s->addAll($input));
+}
+
+?>
+--EXPECTF--
+Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, array given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, boolean given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, %unicode_string_optional% given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, integer given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, double given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, null given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt
new file mode 100644
index 0000000..d984429
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Check that SplObjectStorage::attach generates a warning and returns NULL when bad params are passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$s = new SplObjectStorage();
+
+var_dump($s->attach(true));
+var_dump($s->attach(new stdClass, true, true));
+
+?>
+--EXPECTF--
+Warning: SplObjectStorage::attach() expects parameter 1 to be object, boolean given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::attach() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt
new file mode 100644
index 0000000..f523928
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Check that SplObjectStorage::contains generate a warning and returns NULL when passed non-object param
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+
+ var_dump($s->contains($input));
+}
+
+?>
+--EXPECTF--
+Warning: SplObjectStorage::contains() expects parameter 1 to be object, array given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::contains() expects parameter 1 to be object, boolean given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::contains() expects parameter 1 to be object, %unicode_string_optional% given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::contains() expects parameter 1 to be object, integer given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::contains() expects parameter 1 to be object, double given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::contains() expects parameter 1 to be object, null given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_current_empty_storage.phpt b/ext/spl/tests/SplObjectStorage_current_empty_storage.phpt
new file mode 100644
index 0000000..65fa691
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_current_empty_storage.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Check that SplObjectStorage::current returns NULL when storage is empty
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$s = new SplObjectStorage();
+
+var_dump($s->current());
+
+?>
+--EXPECT--
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt
new file mode 100644
index 0000000..83b79fc
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Check that SplObjectStorage::detach generate a warning and returns NULL when passed non-object param
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+
+ var_dump($s->detach($input));
+}
+
+?>
+--EXPECTF--
+Warning: SplObjectStorage::detach() expects parameter 1 to be object, array given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::detach() expects parameter 1 to be object, boolean given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::detach() expects parameter 1 to be object, %unicode_string_optional% given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::detach() expects parameter 1 to be object, integer given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::detach() expects parameter 1 to be object, double given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::detach() expects parameter 1 to be object, null given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_getHash.phpt b/ext/spl/tests/SplObjectStorage_getHash.phpt
new file mode 100644
index 0000000..f309b3d
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_getHash.phpt
@@ -0,0 +1,60 @@
+--TEST--
+SplObjectStorage::getHash implementation
+--FILE--
+<?php
+$s = new SplObjectStorage();
+$o1 = new Stdclass;
+$o2 = new Stdclass;
+$s[$o1] = "some_value\n";
+echo $s->offsetGet($o1);
+
+class MySplObjectStorage extends SplObjectStorage {
+ public function getHash($obj) {
+ return 2;
+ }
+}
+
+try {
+ $s1 = new MySplObjectStorage;
+ $s1[$o1] = "foo";
+} catch(Exception $e) {
+ echo "caught\n";
+}
+
+class MySplObjectStorage2 extends SplObjectStorage {
+ public function getHash($obj) {
+ throw new Exception("foo");
+ return "asd";
+ }
+}
+
+try {
+ $s2 = new MySplObjectStorage2;
+ $s2[$o2] = "foo";
+} catch(Exception $e) {
+ echo "caught\n";
+}
+
+class MySplObjectStorage3 extends SplObjectStorage {
+ public function getHash($obj) {
+ return "asd";
+ }
+}
+
+$s3 = new MySplObjectStorage3;
+$s3[$o1] = $o1;
+var_dump($s3[$o1]);
+$s3[$o2] = $o2;
+
+var_dump($s3[$o1] === $s3[$o2]);
+
+?>
+===DONE===
+--EXPECT--
+some_value
+caught
+caught
+object(stdClass)#2 (0) {
+}
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/SplObjectStorage_getInfo_empty_storage.phpt b/ext/spl/tests/SplObjectStorage_getInfo_empty_storage.phpt
new file mode 100644
index 0000000..e6c4de8
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_getInfo_empty_storage.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Check that SplObjectStorage::getInfo returns NULL when storage is empty
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$s = new SplObjectStorage();
+
+var_dump($s->getInfo());
+
+?>
+--EXPECT--
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_offsetGet.phpt b/ext/spl/tests/SplObjectStorage_offsetGet.phpt
new file mode 100644
index 0000000..e73f6b1
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_offsetGet.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Standard success for SplObjectStorage::offsetGet
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$s = new SplObjectStorage();
+$o1 = new stdClass();
+$s[$o1] = 'some_value';
+
+echo $s->offsetGet($o1);
+
+?>
+--EXPECT--
+some_value
+
diff --git a/ext/spl/tests/SplObjectStorage_offsetGet_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_offsetGet_invalid_parameter.phpt
new file mode 100644
index 0000000..3f8bd43
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_offsetGet_invalid_parameter.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Check that SplObjectStorage::offsetGet generate a warning and return NULL when passed non-object param
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+ $o1 = new stdClass();
+ $s[$o1] = 'some_value';
+
+ var_dump($s->offsetGet($input));
+}
+
+?>
+--EXPECTF--
+Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, array given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, boolean given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, %unicode_string_optional% given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, integer given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, double given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, null given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_offsetGet_missing_object.phpt b/ext/spl/tests/SplObjectStorage_offsetGet_missing_object.phpt
new file mode 100644
index 0000000..72b032c
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_offsetGet_missing_object.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Check that SplObjectStorage::offsetGet throws exception when non-existing object is requested
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$s = new SplObjectStorage();
+$o1 = new stdClass();
+
+try {
+ $s->offsetGet($o1);
+} catch (UnexpectedValueException $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECT--
+Object not found
+
diff --git a/ext/spl/tests/SplObjectStorage_removeAllExcept_basic.phpt b/ext/spl/tests/SplObjectStorage_removeAllExcept_basic.phpt
new file mode 100644
index 0000000..7c8cb75
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_removeAllExcept_basic.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Check that SplObjectStorage::removeUncommon functions when receiving proper input
+--CREDITS--
+Matthew Turland (me@matthewturland.com)
+--FILE--
+<?php
+
+ $a = (object) 'a';
+ $b = (object) 'b';
+ $c = (object) 'c';
+
+ $foo = new SplObjectStorage;
+ $foo->attach($a);
+ $foo->attach($b);
+
+ $bar = new SplObjectStorage;
+ $bar->attach($b);
+ $bar->attach($c);
+
+ $foo->removeAllExcept($bar);
+ var_dump($foo->contains($a));
+ var_dump($foo->contains($b));
+
+?>
+--EXPECT--
+bool(false)
+bool(true)
diff --git a/ext/spl/tests/SplObjectStorage_removeAllExcept_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_removeAllExcept_invalid_parameter.phpt
new file mode 100644
index 0000000..62e0dde
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_removeAllExcept_invalid_parameter.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Check that SplObjectStorage::removeAllExcept generate a warning and returns NULL when passed non-object param
+--CREDITS--
+Matthew Turland (me@matthewturland.com)
+Based on work done at PHPNW Testfest 2009 by Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+
+ var_dump($s->removeAllExcept($input));
+}
+
+?>
+--EXPECTF--
+Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, array given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, boolean given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, %unicode_string_optional% given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, integer given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, double given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, null given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_removeAll_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_removeAll_invalid_parameter.phpt
new file mode 100644
index 0000000..ffd3398
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_removeAll_invalid_parameter.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Check that SplObjectStorage::removeAll generate a warning and returns NULL when passed non-object param
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+
+ var_dump($s->removeAll($input));
+}
+
+?>
+--EXPECTF--
+Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, array given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, boolean given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, %unicode_string_optional% given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, integer given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, double given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, null given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_setInfo_empty_storage.phpt b/ext/spl/tests/SplObjectStorage_setInfo_empty_storage.phpt
new file mode 100644
index 0000000..c8c3cd1
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_setInfo_empty_storage.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Check that SplObjectStorage::setInfo returns NULL when storage is empty
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$s = new SplObjectStorage();
+
+var_dump($s->setInfo('some_value'));
+
+?>
+--EXPECT--
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_setInfo_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_setInfo_invalid_parameter.phpt
new file mode 100644
index 0000000..52f8f9b
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_setInfo_invalid_parameter.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Check that SplObjectStorage::setInfo returns NULL when no param is passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$s = new SplObjectStorage();
+
+var_dump($s->setInfo());
+
+?>
+--EXPECTF--
+Warning: SplObjectStorage::setInfo() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_unserialize_bad.phpt b/ext/spl/tests/SplObjectStorage_unserialize_bad.phpt
new file mode 100644
index 0000000..a525317
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_unserialize_bad.phpt
@@ -0,0 +1,45 @@
+--TEST--
+SPL: Test that serialized blob contains unique elements (CVE-2010-2225)
+--FILE--
+<?php
+
+$badblobs = array(
+'x:i:2;i:0;,i:1;;i:0;,i:2;;m:a:0:{}',
+'x:i:3;O:8:"stdClass":0:{},O:8:"stdClass":0:{};R:2;,i:1;;O:8:"stdClass":0:{},r:2;;m:a:0:{}',
+'x:i:3;O:8:"stdClass":0:{},O:8:"stdClass":0:{};r:2;,i:1;;O:8:"stdClass":0:{},r:2;;m:a:0:{}',
+);
+foreach($badblobs as $blob) {
+try {
+ $so = new SplObjectStorage();
+ $so->unserialize($blob);
+ var_dump($so);
+} catch(UnexpectedValueException $e) {
+ echo $e->getMessage()."\n";
+}
+}
+--EXPECTF--
+Error at offset 6 of 34 bytes
+Error at offset 46 of 89 bytes
+object(SplObjectStorage)#2 (1) {
+ ["storage":"SplObjectStorage":private]=>
+ array(2) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(stdClass)#3 (0) {
+ }
+ ["inf"]=>
+ int(1)
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(stdClass)#1 (0) {
+ }
+ ["inf"]=>
+ object(stdClass)#3 (0) {
+ }
+ }
+ }
+}
+
diff --git a/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt
new file mode 100644
index 0000000..dcf43e2
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Check that SplObjectStorage::unserialize returns NULL when non-string param is passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ array(),
+ new stdClass(),
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+
+ var_dump($s->unserialize($input));
+}
+
+?>
+--EXPECTF--
+Warning: SplObjectStorage::unserialize() expects parameter 1 to be %binary_string_optional%, array given in %s on line %d
+NULL
+
+Warning: SplObjectStorage::unserialize() expects parameter 1 to be %binary_string_optional%, object given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt
new file mode 100644
index 0000000..be2bb33
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter2.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Check that SplObjectStorage::unserialize throws exception when numeric value passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ 12345,
+ 1.2345,
+ PHP_INT_MAX,
+ 'x:rubbish', // rubbish after the 'x:' prefix
+ 'x:i:2;O:8:"stdClass":0:{},s:5:"value";;m:a:0:{}',
+);
+
+foreach($data_provider as $input) {
+
+ $s = new SplObjectStorage();
+
+ try {
+ $s->unserialize($input);
+ } catch(UnexpectedValueException $e) {
+ echo $e->getMessage() . PHP_EOL;
+ }
+}
+
+?>
+--EXPECTF--
+Error at offset %d of %d bytes
+Error at offset %d of %d bytes
+Error at offset %d of %d bytes
+Error at offset %d of %d bytes
+Error at offset %d of %d bytes
+
diff --git a/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt
new file mode 100644
index 0000000..4c2dd75
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Check that SplObjectStorage::unserialize throws exception when NULL passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$s = new SplObjectStorage();
+
+try {
+ $s->unserialize(NULL);
+} catch(UnexpectedValueException $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECTF--
+Empty serialized string cannot be empty
+
diff --git a/ext/spl/tests/SplObjectStorage_unserialize_nested.phpt b/ext/spl/tests/SplObjectStorage_unserialize_nested.phpt
new file mode 100644
index 0000000..e96a82a
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_unserialize_nested.phpt
@@ -0,0 +1,47 @@
+--TEST--
+SPL: Test unserializing tested & linked storage
+--FILE--
+<?php
+$o = new StdClass();
+$a = new StdClass();
+
+$o->a = $a;
+
+$so = new SplObjectStorage();
+
+$so[$o] = 1;
+$so[$a] = 2;
+
+$s = serialize($so);
+echo $s."\n";
+
+$so1 = unserialize($s);
+var_dump($so1);
+
+--EXPECTF--
+C:16:"SplObjectStorage":76:{x:i:2;O:8:"stdClass":1:{s:1:"a";O:8:"stdClass":0:{}},i:1;;r:4;,i:2;;m:a:0:{}}
+object(SplObjectStorage)#4 (1) {
+ ["storage":"SplObjectStorage":private]=>
+ array(2) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(stdClass)#5 (1) {
+ ["a"]=>
+ object(stdClass)#6 (0) {
+ }
+ }
+ ["inf"]=>
+ int(1)
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(stdClass)#6 (0) {
+ }
+ ["inf"]=>
+ int(2)
+ }
+ }
+}
+
diff --git a/ext/spl/tests/SplObjectStorage_var_dump.phpt b/ext/spl/tests/SplObjectStorage_var_dump.phpt
new file mode 100644
index 0000000..0439f46
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_var_dump.phpt
@@ -0,0 +1,23 @@
+--TEST--
+SPL: SplObjectStorage: recursive var_dump
+--FILE--
+<?php
+$o = new SplObjectStorage();
+
+$o[new StdClass] = $o;
+
+var_dump($o);
+--EXPECTF--
+object(SplObjectStorage)#%d (1) {
+ ["storage":"SplObjectStorage":private]=>
+ array(1) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(stdClass)#%d (0) {
+ }
+ ["inf"]=>
+ *RECURSION*
+ }
+ }
+}
diff --git a/ext/spl/tests/SplPriorityQueue_extract_invalid_parameter.phpt b/ext/spl/tests/SplPriorityQueue_extract_invalid_parameter.phpt
new file mode 100644
index 0000000..7dda782
--- /dev/null
+++ b/ext/spl/tests/SplPriorityQueue_extract_invalid_parameter.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Check that SplPriorityQueue::extract generate a warning and returns NULL when param passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$data_provider = array(
+ new stdClass,
+ array(),
+ true,
+ "string",
+ 12345,
+ 1.2345,
+ NULL
+);
+
+foreach($data_provider as $input) {
+
+ $h = new SplPriorityQueue();
+
+ var_dump($h->extract($input));
+}
+
+?>
+--EXPECTF--
+Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplPriorityQueue_insert_invalid_parameter.phpt b/ext/spl/tests/SplPriorityQueue_insert_invalid_parameter.phpt
new file mode 100644
index 0000000..7d7b589
--- /dev/null
+++ b/ext/spl/tests/SplPriorityQueue_insert_invalid_parameter.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Check that SplPriorityQueue::insert generate a warning and returns NULL when rubbish params are passed
+--CREDITS--
+PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
+--FILE--
+<?php
+
+$h = new SplPriorityQueue();
+
+var_dump($h->insert(NULL));
+
+?>
+--EXPECTF--
+Warning: SplPriorityQueue::insert() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
diff --git a/ext/spl/tests/SplQueue_setIteratorMode.phpt b/ext/spl/tests/SplQueue_setIteratorMode.phpt
new file mode 100644
index 0000000..172a1d9
--- /dev/null
+++ b/ext/spl/tests/SplQueue_setIteratorMode.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Check that SplQueue can't be set to LIFO
+--CREDITS--
+Rob Knight <themanhimself@robknight.org.uk> PHPNW Test Fest 2009
+--FILE--
+<?php
+$queue = new SplQueue();
+try {
+ $queue->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+?>
+--EXPECTF--
+Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen
diff --git a/ext/spl/tests/SplQueue_setIteratorMode_param_lifo.phpt b/ext/spl/tests/SplQueue_setIteratorMode_param_lifo.phpt
new file mode 100644
index 0000000..c3071f2
--- /dev/null
+++ b/ext/spl/tests/SplQueue_setIteratorMode_param_lifo.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SplQueue setIteratorMode to LIFO produces fail condition in try/catch
+--CREDITS--
+PHPNW Test Fest 2009 - Jeremy Coates jeremy@phpnw.org.uk
+--FILE--
+<?php
+
+try {
+
+ $dll = new SplQueue();
+ $dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
+
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECT--
+Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen
diff --git a/ext/spl/tests/SplStack_setIteratorMode.phpt b/ext/spl/tests/SplStack_setIteratorMode.phpt
new file mode 100644
index 0000000..d70105e
--- /dev/null
+++ b/ext/spl/tests/SplStack_setIteratorMode.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Check that SplStack can't be set to FIFO
+--CREDITS--
+Rob Knight <themanhimself@robknight.org.uk> PHPNW Test Fest 2009
+--FILE--
+<?php
+$stack = new SplStack();
+try {
+ $stack->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+?>
+--EXPECTF--
+Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen
diff --git a/ext/spl/tests/SplTempFileObject_constructor_basic.phpt b/ext/spl/tests/SplTempFileObject_constructor_basic.phpt
new file mode 100644
index 0000000..b2e640c
--- /dev/null
+++ b/ext/spl/tests/SplTempFileObject_constructor_basic.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL SplTempFileObject constructor sets correct defaults when pass 0 arguments
+--FILE--
+<?php
+var_dump(new SplTempFileObject());
+?>
+--EXPECTF--
+object(SplTempFileObject)#1 (5) {
+ ["pathName":"SplFileInfo":private]=>
+ string(10) "php://temp"
+ ["fileName":"SplFileInfo":private]=>
+ string(10) "php://temp"
+ ["openMode":"SplFileObject":private]=>
+ string(1) "w"
+ ["delimiter":"SplFileObject":private]=>
+ string(1) ","
+ ["enclosure":"SplFileObject":private]=>
+ string(1) """
+}
diff --git a/ext/spl/tests/SplTempFileObject_constructor_error.phpt b/ext/spl/tests/SplTempFileObject_constructor_error.phpt
new file mode 100644
index 0000000..d2717ac
--- /dev/null
+++ b/ext/spl/tests/SplTempFileObject_constructor_error.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL SplTempFileObject constructor sets correct defaults when pass 0 arguments
+--FILE--
+<?php
+new SplTempFileObject('invalid');
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'RuntimeException' with message 'SplTempFileObject::__construct() expects parameter 1 to be long, string given' in %s
+Stack trace:
+#0 %s: SplTempFileObject->__construct('invalid')
+#1 {main}
+ thrown in %s
diff --git a/ext/spl/tests/SplTempFileObject_constructor_maxmemory_basic.phpt b/ext/spl/tests/SplTempFileObject_constructor_maxmemory_basic.phpt
new file mode 100644
index 0000000..2ef1b2c
--- /dev/null
+++ b/ext/spl/tests/SplTempFileObject_constructor_maxmemory_basic.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL SplTempFileObject constructor sets correct values when passed fixed memory size
+--FILE--
+<?php
+var_dump(new SplTempFileObject(1024));
+?>
+--EXPECTF--
+object(SplTempFileObject)#1 (5) {
+ ["pathName":"SplFileInfo":private]=>
+ string(25) "php://temp/maxmemory:1024"
+ ["fileName":"SplFileInfo":private]=>
+ string(25) "php://temp/maxmemory:1024"
+ ["openMode":"SplFileObject":private]=>
+ string(1) "w"
+ ["delimiter":"SplFileObject":private]=>
+ string(1) ","
+ ["enclosure":"SplFileObject":private]=>
+ string(1) """
+}
diff --git a/ext/spl/tests/SplTempFileObject_constructor_memory_lt1_variation.phpt b/ext/spl/tests/SplTempFileObject_constructor_memory_lt1_variation.phpt
new file mode 100644
index 0000000..9fe5892
--- /dev/null
+++ b/ext/spl/tests/SplTempFileObject_constructor_memory_lt1_variation.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL SplTempFileObject constructor sets correct defaults when passed a negative value
+--FILE--
+<?php
+var_dump(new SplTempFileObject(-1));
+?>
+--EXPECTF--
+object(SplTempFileObject)#1 (5) {
+ ["pathName":"SplFileInfo":private]=>
+ string(12) "php://memory"
+ ["fileName":"SplFileInfo":private]=>
+ string(12) "php://memory"
+ ["openMode":"SplFileObject":private]=>
+ string(1) "w"
+ ["delimiter":"SplFileObject":private]=>
+ string(1) ","
+ ["enclosure":"SplFileObject":private]=>
+ string(1) """
+}
diff --git a/ext/spl/tests/arrayObject___construct_basic1.phpt b/ext/spl/tests/arrayObject___construct_basic1.phpt
new file mode 100644
index 0000000..f192cca
--- /dev/null
+++ b/ext/spl/tests/arrayObject___construct_basic1.phpt
@@ -0,0 +1,52 @@
+--TEST--
+SPL: ArrayObject::__construct basic usage.
+--FILE--
+<?php
+echo "--> No arguments:\n";
+var_dump(new ArrayObject());
+
+echo "--> Object argument:\n";
+$a = new stdClass;
+$a->p = 'hello';
+var_dump(new ArrayObject($a));
+
+echo "--> Array argument:\n";
+var_dump(new ArrayObject(array('key1' => 'val1')));
+
+echo "--> Nested ArrayObject argument:\n";
+var_dump(new ArrayObject(new ArrayObject($a)));
+?>
+--EXPECTF--
+--> No arguments:
+object(ArrayObject)#1 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(0) {
+ }
+}
+--> Object argument:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(stdClass)#1 (1) {
+ ["p"]=>
+ string(5) "hello"
+ }
+}
+--> Array argument:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ ["key1"]=>
+ string(4) "val1"
+ }
+}
+--> Nested ArrayObject argument:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(ArrayObject)#3 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(stdClass)#1 (1) {
+ ["p"]=>
+ string(5) "hello"
+ }
+ }
+}
diff --git a/ext/spl/tests/arrayObject___construct_basic2.phpt b/ext/spl/tests/arrayObject___construct_basic2.phpt
new file mode 100644
index 0000000..bd27c42
--- /dev/null
+++ b/ext/spl/tests/arrayObject___construct_basic2.phpt
@@ -0,0 +1,104 @@
+--TEST--
+SPL: ArrayObject::__construct basic usage.
+--FILE--
+<?php
+class C {
+ public $prop = 'C::prop.orig';
+}
+
+class MyArrayObject extends ArrayObject {
+ public $prop = 'MyArrayObject::prop.orig';
+}
+
+echo "--> Access prop on instance of ArrayObject:\n";
+$c = new C;
+$ao = new ArrayObject($c);
+testAccess($c, $ao);
+
+echo "\n--> Access prop on instance of MyArrayObject:\n";
+$c = new C;
+$ao = new MyArrayObject($c);
+testAccess($c, $ao);
+
+function testAccess($c, $ao) {
+ echo " - Iteration:\n";
+ foreach ($ao as $key=>$value) {
+ echo " $key=>$value\n";
+ }
+
+ echo " - Read:\n";
+ @var_dump($ao->prop, $ao['prop']);
+
+ echo " - Write:\n";
+ $ao->prop = 'changed1';
+ $ao['prop'] = 'changed2';
+ var_dump($ao->prop, $ao['prop']);
+
+ echo " - Isset:\n";
+ var_dump(isset($ao->prop), isset($ao['prop']));
+
+ echo " - Unset:\n";
+ unset($ao->prop);
+ unset($ao['prop']);
+ var_dump($ao->prop, $ao['prop']);
+
+ echo " - After:\n";
+ var_dump($ao, $c);
+}
+?>
+--EXPECTF--
+--> Access prop on instance of ArrayObject:
+ - Iteration:
+ prop=>C::prop.orig
+ - Read:
+NULL
+string(12) "C::prop.orig"
+ - Write:
+string(8) "changed1"
+string(8) "changed2"
+ - Isset:
+bool(true)
+bool(true)
+ - Unset:
+
+Notice: Undefined property: ArrayObject::$prop in %s on line 40
+
+Notice: Undefined index: prop in %s on line 40
+NULL
+NULL
+ - After:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (0) {
+ }
+}
+object(C)#1 (0) {
+}
+
+--> Access prop on instance of MyArrayObject:
+ - Iteration:
+ prop=>C::prop.orig
+ - Read:
+string(24) "MyArrayObject::prop.orig"
+string(12) "C::prop.orig"
+ - Write:
+string(8) "changed1"
+string(8) "changed2"
+ - Isset:
+bool(true)
+bool(true)
+ - Unset:
+
+Notice: Undefined property: MyArrayObject::$prop in %s on line 40
+
+Notice: Undefined index: prop in %s on line 40
+NULL
+NULL
+ - After:
+object(MyArrayObject)#3 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#4 (0) {
+ }
+}
+object(C)#4 (0) {
+}
diff --git a/ext/spl/tests/arrayObject___construct_basic3.phpt b/ext/spl/tests/arrayObject___construct_basic3.phpt
new file mode 100644
index 0000000..11a17a6
--- /dev/null
+++ b/ext/spl/tests/arrayObject___construct_basic3.phpt
@@ -0,0 +1,104 @@
+--TEST--
+SPL: ArrayObject::__construct basic usage with ArrayObject::STD_PROP_LIST.
+--FILE--
+<?php
+class C {
+ public $prop = 'C::prop.orig';
+}
+
+class MyArrayObject extends ArrayObject {
+ public $prop = 'MyArrayObject::prop.orig';
+}
+
+echo "\n--> Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST:\n";
+$c = new C;
+$ao = new ArrayObject($c, ArrayObject::STD_PROP_LIST);
+testAccess($c, $ao);
+
+echo "\n--> Access prop on instance of MyArrayObject with ArrayObject::STD_PROP_LIST:\n";
+$c = new C;
+$ao = new MyArrayObject($c, ArrayObject::STD_PROP_LIST);
+testAccess($c, $ao);
+
+function testAccess($c, $ao) {
+ echo " - Iteration:\n";
+ foreach ($ao as $key=>$value) {
+ echo " $key=>$value\n";
+ }
+
+ echo " - Read:\n";
+ @var_dump($ao->prop, $ao['prop']);
+
+ echo " - Write:\n";
+ $ao->prop = 'changed1';
+ $ao['prop'] = 'changed2';
+ var_dump($ao->prop, $ao['prop']);
+
+ echo " - Isset:\n";
+ var_dump(isset($ao->prop), isset($ao['prop']));
+
+ echo " - Unset:\n";
+ unset($ao->prop);
+ unset($ao['prop']);
+ var_dump($ao->prop, $ao['prop']);
+
+ echo " - After:\n";
+ var_dump($ao, $c);
+}
+?>
+--EXPECTF--
+--> Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST:
+ - Iteration:
+ prop=>C::prop.orig
+ - Read:
+NULL
+string(12) "C::prop.orig"
+ - Write:
+string(8) "changed1"
+string(8) "changed2"
+ - Isset:
+bool(true)
+bool(true)
+ - Unset:
+
+Notice: Undefined property: ArrayObject::$prop in %s on line 40
+
+Notice: Undefined index: prop in %s on line 40
+NULL
+NULL
+ - After:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (0) {
+ }
+}
+object(C)#1 (0) {
+}
+
+--> Access prop on instance of MyArrayObject with ArrayObject::STD_PROP_LIST:
+ - Iteration:
+ prop=>C::prop.orig
+ - Read:
+string(24) "MyArrayObject::prop.orig"
+string(12) "C::prop.orig"
+ - Write:
+string(8) "changed1"
+string(8) "changed2"
+ - Isset:
+bool(true)
+bool(true)
+ - Unset:
+
+Notice: Undefined property: MyArrayObject::$prop in %s on line 40
+
+Notice: Undefined index: prop in %s on line 40
+NULL
+NULL
+ - After:
+object(MyArrayObject)#3 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#4 (0) {
+ }
+}
+object(C)#4 (0) {
+}
diff --git a/ext/spl/tests/arrayObject___construct_basic4.phpt b/ext/spl/tests/arrayObject___construct_basic4.phpt
new file mode 100644
index 0000000..b0809de
--- /dev/null
+++ b/ext/spl/tests/arrayObject___construct_basic4.phpt
@@ -0,0 +1,106 @@
+--TEST--
+SPL: ArrayObject::__construct basic usage with ArrayObject::ARRAY_AS_PROPS. Currently fails on php.net due to bug 45622.
+--FILE--
+<?php
+class C {
+ public $prop = 'C::prop.orig';
+}
+
+class MyArrayObject extends ArrayObject {
+ public $prop = 'MyArrayObject::prop.orig';
+}
+
+echo "\n--> Access prop on instance of ArrayObject with ArrayObject::ARRAY_AS_PROPS:\n";
+$c = new C;
+$ao = new ArrayObject($c, ArrayObject::ARRAY_AS_PROPS);
+testAccess($c, $ao);
+
+echo "\n--> Access prop on instance of MyArrayObject with ArrayObject::ARRAY_AS_PROPS:\n";
+$c = new C;
+$ao = new MyArrayObject($c, ArrayObject::ARRAY_AS_PROPS);
+testAccess($c, $ao);
+
+function testAccess($c, $ao) {
+ echo " - Iteration:\n";
+ foreach ($ao as $key=>$value) {
+ echo " $key=>$value\n";
+ }
+
+ echo " - Read:\n";
+ @var_dump($ao->prop, $ao['prop']);
+
+ echo " - Write:\n";
+ $ao->prop = 'changed1';
+ $ao['prop'] = 'changed2';
+ var_dump($ao->prop, $ao['prop']);
+
+ echo " - Isset:\n";
+ var_dump(isset($ao->prop), isset($ao['prop']));
+
+ echo " - Unset:\n";
+ unset($ao->prop);
+ unset($ao['prop']);
+ var_dump($ao->prop, $ao['prop']);
+
+ echo " - After:\n";
+ var_dump($ao, $c);
+}
+?>
+--EXPECTF--
+--> Access prop on instance of ArrayObject with ArrayObject::ARRAY_AS_PROPS:
+ - Iteration:
+ prop=>C::prop.orig
+ - Read:
+string(12) "C::prop.orig"
+string(12) "C::prop.orig"
+ - Write:
+string(8) "changed2"
+string(8) "changed2"
+ - Isset:
+bool(true)
+bool(true)
+ - Unset:
+
+Notice: Undefined index: prop in %s on line 39
+
+Notice: Undefined index: prop in %s on line 40
+
+Notice: Undefined index: prop in %s on line 40
+NULL
+NULL
+ - After:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (0) {
+ }
+}
+object(C)#1 (0) {
+}
+
+--> Access prop on instance of MyArrayObject with ArrayObject::ARRAY_AS_PROPS:
+ - Iteration:
+ prop=>C::prop.orig
+ - Read:
+string(24) "MyArrayObject::prop.orig"
+string(12) "C::prop.orig"
+ - Write:
+string(8) "changed1"
+string(8) "changed2"
+ - Isset:
+bool(true)
+bool(true)
+ - Unset:
+
+Notice: Undefined index: prop in %s on line 40
+
+Notice: Undefined index: prop in %s on line 40
+NULL
+NULL
+ - After:
+object(MyArrayObject)#3 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#4 (0) {
+ }
+}
+object(C)#4 (0) {
+}
diff --git a/ext/spl/tests/arrayObject___construct_basic5.phpt b/ext/spl/tests/arrayObject___construct_basic5.phpt
new file mode 100644
index 0000000..8c44ee2
--- /dev/null
+++ b/ext/spl/tests/arrayObject___construct_basic5.phpt
@@ -0,0 +1,106 @@
+--TEST--
+SPL: ArrayObject::__construct basic usage with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS. Currently fails on php.net due to bug 45622.
+--FILE--
+<?php
+class C {
+ public $prop = 'C::prop.orig';
+}
+
+class MyArrayObject extends ArrayObject {
+ public $prop = 'MyArrayObject::prop.orig';
+}
+
+echo "\n--> Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS:\n";
+$c = new C;
+$ao = new ArrayObject($c, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS);
+testAccess($c, $ao);
+
+echo "\n--> Access prop on instance of MyArrayObject with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS:\n";
+$c = new C;
+$ao = new MyArrayObject($c, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS);
+testAccess($c, $ao);
+
+function testAccess($c, $ao) {
+ echo " - Iteration:\n";
+ foreach ($ao as $key=>$value) {
+ echo " $key=>$value\n";
+ }
+
+ echo " - Read:\n";
+ @var_dump($ao->prop, $ao['prop']);
+
+ echo " - Write:\n";
+ $ao->prop = 'changed1';
+ $ao['prop'] = 'changed2';
+ var_dump($ao->prop, $ao['prop']);
+
+ echo " - Isset:\n";
+ var_dump(isset($ao->prop), isset($ao['prop']));
+
+ echo " - Unset:\n";
+ unset($ao->prop);
+ unset($ao['prop']);
+ var_dump($ao->prop, $ao['prop']);
+
+ echo " - After:\n";
+ var_dump($ao, $c);
+}
+?>
+--EXPECTF--
+--> Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS:
+ - Iteration:
+ prop=>C::prop.orig
+ - Read:
+string(12) "C::prop.orig"
+string(12) "C::prop.orig"
+ - Write:
+string(8) "changed2"
+string(8) "changed2"
+ - Isset:
+bool(true)
+bool(true)
+ - Unset:
+
+Notice: Undefined index: prop in %s on line 39
+
+Notice: Undefined index: prop in %s on line 40
+
+Notice: Undefined index: prop in %s on line 40
+NULL
+NULL
+ - After:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (0) {
+ }
+}
+object(C)#1 (0) {
+}
+
+--> Access prop on instance of MyArrayObject with ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS:
+ - Iteration:
+ prop=>C::prop.orig
+ - Read:
+string(24) "MyArrayObject::prop.orig"
+string(12) "C::prop.orig"
+ - Write:
+string(8) "changed1"
+string(8) "changed2"
+ - Isset:
+bool(true)
+bool(true)
+ - Unset:
+
+Notice: Undefined index: prop in %s on line 40
+
+Notice: Undefined index: prop in %s on line 40
+NULL
+NULL
+ - After:
+object(MyArrayObject)#3 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#4 (0) {
+ }
+}
+object(C)#4 (0) {
+}
diff --git a/ext/spl/tests/arrayObject___construct_basic6.phpt b/ext/spl/tests/arrayObject___construct_basic6.phpt
new file mode 100644
index 0000000..1c7ec36
--- /dev/null
+++ b/ext/spl/tests/arrayObject___construct_basic6.phpt
@@ -0,0 +1,80 @@
+--TEST--
+SPL: ArrayObject::__construct: check impact of ArrayObject::STD_PROP_LIST on var_dump.
+--FILE--
+<?php
+class MyArrayObject extends ArrayObject {
+ private $priv1 = 'secret1';
+ public $pub1 = 'public1';
+}
+
+$ao = new ArrayObject(array(1,2,3));
+$ao->p = 1;
+var_dump($ao);
+
+$ao = new ArrayObject(array(1,2,3), ArrayObject::STD_PROP_LIST);
+$ao->p = 1;
+var_dump($ao);
+
+$ao = new MyArrayObject(array(1,2,3));
+var_dump($ao);
+
+$ao = new MyArrayObject(array(1,2,3), ArrayObject::STD_PROP_LIST);
+var_dump($ao);
+?>
+--EXPECTF--
+object(ArrayObject)#1 (2) {
+ ["p"]=>
+ int(1)
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+object(ArrayObject)#2 (2) {
+ ["p"]=>
+ int(1)
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+object(MyArrayObject)#1 (3) {
+ ["priv1":"MyArrayObject":private]=>
+ string(7) "secret1"
+ ["pub1"]=>
+ string(7) "public1"
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+object(MyArrayObject)#2 (3) {
+ ["priv1":"MyArrayObject":private]=>
+ string(7) "secret1"
+ ["pub1"]=>
+ string(7) "public1"
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
diff --git a/ext/spl/tests/arrayObject___construct_error1.phpt b/ext/spl/tests/arrayObject___construct_error1.phpt
new file mode 100644
index 0000000..21c312d
--- /dev/null
+++ b/ext/spl/tests/arrayObject___construct_error1.phpt
@@ -0,0 +1,25 @@
+--TEST--
+SPL: ArrayObject::__construct with bad iterator.
+--FILE--
+<?php
+echo "Bad iterator type:\n";
+$a = new stdClass;
+$a->p = 1;
+try {
+ var_dump(new ArrayObject($a, 0, "Exception"));
+} catch (InvalidArgumentException $e) {
+ echo $e->getMessage() . "(" . $e->getLine() . ")\n";
+}
+
+echo "Non-existent class:\n";
+try {
+ var_dump(new ArrayObject(new stdClass, 0, "nonExistentClassName"));
+} catch (InvalidArgumentException $e) {
+ echo $e->getMessage() . "(" . $e->getLine() . ")\n";
+}
+?>
+--EXPECTF--
+Bad iterator type:
+ArrayObject::__construct() expects parameter 3 to be a class name derived from Iterator, 'Exception' given(6)
+Non-existent class:
+ArrayObject::__construct() expects parameter 3 to be a class name derived from Iterator, 'nonExistentClassName' given(13)
diff --git a/ext/spl/tests/arrayObject___construct_error2.phpt b/ext/spl/tests/arrayObject___construct_error2.phpt
new file mode 100644
index 0000000..850a2cb
--- /dev/null
+++ b/ext/spl/tests/arrayObject___construct_error2.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: ArrayObject::__construct with too many arguments.
+--FILE--
+<?php
+echo "Too many arguments:\n";
+Class C implements Iterator {
+ function current() {}
+ function next() {}
+ function key() {}
+ function valid() {}
+ function rewind() {}
+}
+
+try {
+ var_dump(new ArrayObject(new stdClass, 0, "C", "extra"));
+} catch (InvalidArgumentException $e) {
+ echo $e->getMessage() . "(" . $e->getLine() . ")\n";
+}
+?>
+--EXPECTF--
+Too many arguments:
+ArrayObject::__construct() expects at most 3 parameters, 4 given(12) \ No newline at end of file
diff --git a/ext/spl/tests/arrayObject_asort_basic1.phpt b/ext/spl/tests/arrayObject_asort_basic1.phpt
new file mode 100644
index 0000000..53df1d5
--- /dev/null
+++ b/ext/spl/tests/arrayObject_asort_basic1.phpt
@@ -0,0 +1,64 @@
+--TEST--
+SPL: Test ArrayObject::asort() function : basic functionality with array based store
+--FILE--
+<?php
+/* Prototype : int ArrayObject::asort()
+ * Description: proto int ArrayIterator::asort()
+ * Sort the entries by values.
+ * Source code: ext/spl/spl_array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ArrayObject::asort() : basic functionality ***\n";
+
+$ao1 = new ArrayObject(array(4,2,3));
+$ao2 = new ArrayObject(array('a'=>4,'b'=>2,'c'=>3));
+var_dump($ao1->asort());
+var_dump($ao1);
+var_dump($ao2->asort('blah'));
+var_dump($ao2);
+var_dump($ao2->asort(SORT_NUMERIC));
+var_dump($ao2);
+?>
+===DONE===
+--EXPECTF--
+*** Testing ArrayObject::asort() : basic functionality ***
+bool(true)
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [0]=>
+ int(4)
+ }
+}
+
+Warning: asort() expects parameter 2 to be long, string given in %sarrayObject_asort_basic1.php on line %d
+bool(false)
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ ["a"]=>
+ int(4)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ }
+}
+bool(true)
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["a"]=>
+ int(4)
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/arrayObject_asort_basic2.phpt b/ext/spl/tests/arrayObject_asort_basic2.phpt
new file mode 100644
index 0000000..d481d0c
--- /dev/null
+++ b/ext/spl/tests/arrayObject_asort_basic2.phpt
@@ -0,0 +1,52 @@
+--TEST--
+SPL: Test ArrayObject::asort() function : basic functionality with object based store
+--FILE--
+<?php
+/* Prototype : int ArrayObject::asort()
+ * Description: proto int ArrayIterator::asort()
+ * Sort the entries by values.
+ * Source code: ext/spl/spl_array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ArrayObject::asort() : basic functionality ***\n";
+Class C {
+ public $prop1 = 'x';
+ public $prop2 = 'z';
+ private $prop3 = 'a';
+ public $prop4 = 'x';
+}
+
+$c = new C;
+$ao1 = new ArrayObject($c);
+var_dump($ao1->asort());
+var_dump($ao1, $c);
+?>
+===DONE===
+--EXPECTF--
+*** Testing ArrayObject::asort() : basic functionality ***
+bool(true)
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (4) {
+ ["prop3":"C":private]=>
+ string(1) "a"
+ ["prop1"]=>
+ string(1) "x"
+ ["prop4"]=>
+ string(1) "x"
+ ["prop2"]=>
+ string(1) "z"
+ }
+}
+object(C)#1 (4) {
+ ["prop3":"C":private]=>
+ string(1) "a"
+ ["prop1"]=>
+ string(1) "x"
+ ["prop4"]=>
+ string(1) "x"
+ ["prop2"]=>
+ string(1) "z"
+}
+===DONE===
diff --git a/ext/spl/tests/arrayObject_clone_basic1.phpt b/ext/spl/tests/arrayObject_clone_basic1.phpt
new file mode 100644
index 0000000..dd4abf3
--- /dev/null
+++ b/ext/spl/tests/arrayObject_clone_basic1.phpt
@@ -0,0 +1,48 @@
+--TEST--
+SPL: Cloning an instance of ArrayObject which wraps an array.
+--FILE--
+<?php
+$a = array(1,2);
+$aa1 = new ArrayObject($a);
+$a['p1'] = 'new element added to a before clone';
+
+$aa2 = clone $aa1;
+
+$a['p2'] = 'new element added to a after clone';
+$aa1['new.aa1'] = 'new element added to aa1';
+$aa2['new.aa2'] = 'new element added to aa2';
+var_dump($a, $aa1, $aa2);
+?>
+--EXPECTF--
+array(4) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ ["p1"]=>
+ string(35) "new element added to a before clone"
+ ["p2"]=>
+ string(34) "new element added to a after clone"
+}
+object(ArrayObject)#1 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ ["new.aa1"]=>
+ string(24) "new element added to aa1"
+ }
+}
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ ["new.aa2"]=>
+ string(24) "new element added to aa2"
+ }
+}
diff --git a/ext/spl/tests/arrayObject_clone_basic2.phpt b/ext/spl/tests/arrayObject_clone_basic2.phpt
new file mode 100644
index 0000000..932eaed
--- /dev/null
+++ b/ext/spl/tests/arrayObject_clone_basic2.phpt
@@ -0,0 +1,46 @@
+--TEST--
+SPL: Cloning an instance of ArrayObject which wraps an object.
+--FILE--
+<?php
+class C { }
+
+$c = new C;
+$ao1 = new ArrayObject($c);
+$c->p1 = 'new prop added to c before clone';
+
+$ao2 = clone $ao1;
+
+$c->p2 = 'new prop added to c after clone';
+$ao1['new.ao1'] = 'new element added to ao1';
+$ao2['new.ao2'] = 'new element added to ao2';
+var_dump($c, $ao1, $ao2);
+?>
+--EXPECTF--
+object(C)#1 (3) {
+ ["p1"]=>
+ string(32) "new prop added to c before clone"
+ ["p2"]=>
+ string(31) "new prop added to c after clone"
+ ["new.ao1"]=>
+ string(24) "new element added to ao1"
+}
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (3) {
+ ["p1"]=>
+ string(32) "new prop added to c before clone"
+ ["p2"]=>
+ string(31) "new prop added to c after clone"
+ ["new.ao1"]=>
+ string(24) "new element added to ao1"
+ }
+}
+object(ArrayObject)#3 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(2) {
+ ["p1"]=>
+ string(32) "new prop added to c before clone"
+ ["new.ao2"]=>
+ string(24) "new element added to ao2"
+ }
+}
diff --git a/ext/spl/tests/arrayObject_clone_basic3.phpt b/ext/spl/tests/arrayObject_clone_basic3.phpt
new file mode 100644
index 0000000..f7ac894
--- /dev/null
+++ b/ext/spl/tests/arrayObject_clone_basic3.phpt
@@ -0,0 +1,80 @@
+--TEST--
+SPL: Cloning nested ArrayObjects.
+--FILE--
+<?php
+class C {
+ public $p = 'C::p.orig';
+}
+
+$wrappedObject = new C;
+$innerArrayObject = new ArrayObject($wrappedObject);
+
+$outerArrayObject = new ArrayObject($innerArrayObject);
+
+$wrappedObject->dynamic1 = 'new prop added to $wrappedObject before clone';
+$clonedOuterArrayObject = clone $outerArrayObject;
+$wrappedObject->dynamic2 = 'new prop added to $wrappedObject after clone';
+
+$innerArrayObject['new.iAO'] = 'new element added $innerArrayObject';
+$outerArrayObject['new.oAO'] = 'new element added to $outerArrayObject';
+$clonedOuterArrayObject['new.coAO'] = 'new element added to $clonedOuterArrayObject';
+
+var_dump($wrappedObject, $innerArrayObject, $outerArrayObject, $clonedOuterArrayObject);
+?>
+--EXPECTF--
+object(C)#1 (5) {
+ ["p"]=>
+ string(9) "C::p.orig"
+ ["dynamic1"]=>
+ string(45) "new prop added to $wrappedObject before clone"
+ ["dynamic2"]=>
+ string(44) "new prop added to $wrappedObject after clone"
+ ["new.iAO"]=>
+ string(35) "new element added $innerArrayObject"
+ ["new.oAO"]=>
+ string(38) "new element added to $outerArrayObject"
+}
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (5) {
+ ["p"]=>
+ string(9) "C::p.orig"
+ ["dynamic1"]=>
+ string(45) "new prop added to $wrappedObject before clone"
+ ["dynamic2"]=>
+ string(44) "new prop added to $wrappedObject after clone"
+ ["new.iAO"]=>
+ string(35) "new element added $innerArrayObject"
+ ["new.oAO"]=>
+ string(38) "new element added to $outerArrayObject"
+ }
+}
+object(ArrayObject)#3 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (5) {
+ ["p"]=>
+ string(9) "C::p.orig"
+ ["dynamic1"]=>
+ string(45) "new prop added to $wrappedObject before clone"
+ ["dynamic2"]=>
+ string(44) "new prop added to $wrappedObject after clone"
+ ["new.iAO"]=>
+ string(35) "new element added $innerArrayObject"
+ ["new.oAO"]=>
+ string(38) "new element added to $outerArrayObject"
+ }
+ }
+}
+object(ArrayObject)#4 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ ["p"]=>
+ string(9) "C::p.orig"
+ ["dynamic1"]=>
+ string(45) "new prop added to $wrappedObject before clone"
+ ["new.coAO"]=>
+ string(44) "new element added to $clonedOuterArrayObject"
+ }
+}
diff --git a/ext/spl/tests/arrayObject_count_basic1.phpt b/ext/spl/tests/arrayObject_count_basic1.phpt
new file mode 100644
index 0000000..a003c2c
--- /dev/null
+++ b/ext/spl/tests/arrayObject_count_basic1.phpt
@@ -0,0 +1,84 @@
+--TEST--
+SPL: ArrayObject::count() and ArrayIterator::count() basic functionality.
+--FILE--
+==ArrayObject==
+<?php
+class C extends ArrayObject {
+ function count() {
+ return 99;
+ }
+}
+
+$c = new C;
+$ao = new ArrayObject;
+
+var_dump(count($c), count($ao));
+
+$c[] = 'a';
+$ao[] = 'a';
+var_dump(count($c), count($ao));
+
+$c[] = 'b';
+$ao[] = 'b';
+var_dump(count($c), count($ao));
+
+unset($c[0]);
+unset($ao[0]);
+var_dump($c->count(), $ao->count());
+
+//Extra args are ignored.
+var_dump($ao->count('blah'));
+?>
+==ArrayIterator==
+<?php
+class D extends ArrayIterator {
+ function count() {
+ return 99;
+ }
+}
+
+$c = new D;
+$ao = new ArrayIterator;
+
+var_dump(count($c), count($ao));
+
+$c[] = 'a';
+$ao[] = 'a';
+var_dump(count($c), count($ao));
+
+$c[] = 'b';
+$ao[] = 'b';
+var_dump(count($c), count($ao));
+
+unset($c[0]);
+unset($ao[0]);
+var_dump($c->count(), $ao->count());
+
+//Extra args are ignored.
+var_dump($ao->count('blah'));
+?>
+--EXPECTF--
+==ArrayObject==
+int(99)
+int(0)
+int(99)
+int(1)
+int(99)
+int(2)
+int(99)
+int(1)
+
+Warning: ArrayObject::count() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+==ArrayIterator==
+int(99)
+int(0)
+int(99)
+int(1)
+int(99)
+int(2)
+int(99)
+int(1)
+
+Warning: ArrayIterator::count() expects exactly 0 parameters, 1 given in %s on line %d
+NULL \ No newline at end of file
diff --git a/ext/spl/tests/arrayObject_exchangeArray_basic1.phpt b/ext/spl/tests/arrayObject_exchangeArray_basic1.phpt
new file mode 100644
index 0000000..988f103
--- /dev/null
+++ b/ext/spl/tests/arrayObject_exchangeArray_basic1.phpt
@@ -0,0 +1,40 @@
+--TEST--
+SPL: ArrayObject::exchangeArray() and copy-on-write references
+--FILE--
+<?php
+$ao = new ArrayObject();
+$swapIn = array();
+$cowRef = $swapIn; // create a copy-on-write ref to $swapIn
+$ao->exchangeArray($swapIn);
+
+$ao['a'] = 'adding element to $ao';
+$swapIn['b'] = 'adding element to $swapIn';
+$ao['c'] = 'adding another element to $ao';
+
+echo "\n--> swapIn: ";
+var_dump($swapIn);
+
+echo "\n--> cowRef: ";
+var_dump($cowRef);
+
+echo "\n--> ao: ";
+var_dump($ao);
+?>
+--EXPECTF--
+--> swapIn: array(1) {
+ ["b"]=>
+ string(25) "adding element to $swapIn"
+}
+
+--> cowRef: array(0) {
+}
+
+--> ao: object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(2) {
+ ["a"]=>
+ string(21) "adding element to $ao"
+ ["c"]=>
+ string(29) "adding another element to $ao"
+ }
+}
diff --git a/ext/spl/tests/arrayObject_exchangeArray_basic2.phpt b/ext/spl/tests/arrayObject_exchangeArray_basic2.phpt
new file mode 100644
index 0000000..c7f1b3a
--- /dev/null
+++ b/ext/spl/tests/arrayObject_exchangeArray_basic2.phpt
@@ -0,0 +1,97 @@
+--TEST--
+SPL: ArrayObject::exchangeArray() with various object arguments
+--FILE--
+<?php
+echo "--> exchangeArray(array):\n";
+$ao = new ArrayObject();
+$ao->exchangeArray(array('key'=>'original'));
+var_dump($ao['key']);
+var_dump($ao);
+
+echo "\n--> exchangeArray(normal object):\n";
+$obj = new stdClass;
+$obj->key = 'normal object prop';
+$ao->exchangeArray($obj);
+var_dump($ao['key']);
+var_dump($ao);
+
+echo "\n--> exchangeArray(ArrayObject):\n";
+$obj = new ArrayObject(array('key'=>'ArrayObject element'));
+$ao->exchangeArray($obj);
+var_dump($ao['key']);
+var_dump($ao);
+
+echo "\n--> exchangeArray(ArrayIterator):\n";
+$obj = new ArrayIterator(array('key'=>'ArrayIterator element'));
+$ao->exchangeArray($obj);
+var_dump($ao['key']);
+var_dump($ao);
+
+echo "\n--> exchangeArray(nested ArrayObject):\n";
+$obj = new ArrayObject(new ArrayObject(array('key'=>'nested ArrayObject element')));
+$ao->exchangeArray($obj);
+var_dump($ao['key']);
+var_dump($ao);
+?>
+--EXPECTF--
+--> exchangeArray(array):
+string(8) "original"
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ ["key"]=>
+ string(8) "original"
+ }
+}
+
+--> exchangeArray(normal object):
+string(18) "normal object prop"
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ object(stdClass)#%d (1) {
+ ["key"]=>
+ string(18) "normal object prop"
+ }
+}
+
+--> exchangeArray(ArrayObject):
+string(19) "ArrayObject element"
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ ["key"]=>
+ string(19) "ArrayObject element"
+ }
+ }
+}
+
+--> exchangeArray(ArrayIterator):
+string(21) "ArrayIterator element"
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ object(ArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(1) {
+ ["key"]=>
+ string(21) "ArrayIterator element"
+ }
+ }
+}
+
+--> exchangeArray(nested ArrayObject):
+string(26) "nested ArrayObject element"
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ ["key"]=>
+ string(26) "nested ArrayObject element"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ext/spl/tests/arrayObject_exchangeArray_basic3.phpt b/ext/spl/tests/arrayObject_exchangeArray_basic3.phpt
new file mode 100644
index 0000000..4045b7a
--- /dev/null
+++ b/ext/spl/tests/arrayObject_exchangeArray_basic3.phpt
@@ -0,0 +1,128 @@
+--TEST--
+SPL: ArrayObject::exchangeArray() basic usage with object as underlying data store.
+--FILE--
+<?php
+
+class C {
+ public $pub1 = 'public1';
+}
+
+echo "--> exchangeArray() with objects:\n";
+$original = new C;
+$ao = new ArrayObject($original);
+$swapIn = new C;
+try {
+ $copy = $ao->exchangeArray($swapIn);
+ $copy['addedToCopy'] = 'added To Copy';
+} catch (Exception $e) {
+ echo "Exception:" . $e->getMessage() . "\n";
+}
+$swapIn->addedToSwapIn = 'added To Swap-In';
+$original->addedToOriginal = 'added To Original';
+var_dump($ao, $original, $swapIn, $copy);
+
+
+echo "\n\n--> exchangeArray() with no arg:\n";
+unset($original, $ao, $swapIn, $copy);
+$original = new C;
+$ao = new ArrayObject($original);
+try {
+ $copy = $ao->exchangeArray();
+ $copy['addedToCopy'] = 'added To Copy';
+} catch (Exception $e) {
+ echo "Exception:" . $e->getMessage() . "\n";
+}
+$original->addedToOriginal = 'added To Original';
+var_dump($ao, $original, $copy);
+
+echo "\n\n--> exchangeArray() with bad arg type:\n";
+unset($original, $ao, $swapIn, $copy);
+$original = new C;
+$ao = new ArrayObject($original);
+try {
+ $copy = $ao->exchangeArray(null);
+ $copy['addedToCopy'] = 'added To Copy';
+} catch (Exception $e) {
+ echo "Exception:" . $e->getMessage() . "\n";
+}
+$original->addedToOriginal = 'added To Original';
+var_dump($ao, $original, $copy);
+
+?>
+--EXPECTF--
+--> exchangeArray() with objects:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#3 (2) {
+ ["pub1"]=>
+ string(7) "public1"
+ ["addedToSwapIn"]=>
+ string(16) "added To Swap-In"
+ }
+}
+object(C)#1 (2) {
+ ["pub1"]=>
+ string(7) "public1"
+ ["addedToOriginal"]=>
+ string(17) "added To Original"
+}
+object(C)#3 (2) {
+ ["pub1"]=>
+ string(7) "public1"
+ ["addedToSwapIn"]=>
+ string(16) "added To Swap-In"
+}
+array(2) {
+ ["pub1"]=>
+ string(7) "public1"
+ ["addedToCopy"]=>
+ string(13) "added To Copy"
+}
+
+
+--> exchangeArray() with no arg:
+
+Warning: ArrayObject::exchangeArray() expects exactly 1 parameter, 0 given in %s on line 27
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#3 (2) {
+ ["pub1"]=>
+ string(7) "public1"
+ ["addedToOriginal"]=>
+ string(17) "added To Original"
+ }
+}
+object(C)#3 (2) {
+ ["pub1"]=>
+ string(7) "public1"
+ ["addedToOriginal"]=>
+ string(17) "added To Original"
+}
+array(2) {
+ ["pub1"]=>
+ string(7) "public1"
+ ["addedToCopy"]=>
+ string(13) "added To Copy"
+}
+
+
+--> exchangeArray() with bad arg type:
+Exception:Passed variable is not an array or object, using empty array instead
+
+Notice: Undefined variable: copy in %s on line 46
+object(ArrayObject)#3 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#2 (2) {
+ ["pub1"]=>
+ string(7) "public1"
+ ["addedToOriginal"]=>
+ string(17) "added To Original"
+ }
+}
+object(C)#2 (2) {
+ ["pub1"]=>
+ string(7) "public1"
+ ["addedToOriginal"]=>
+ string(17) "added To Original"
+}
+NULL
diff --git a/ext/spl/tests/arrayObject_getFlags_basic1.phpt b/ext/spl/tests/arrayObject_getFlags_basic1.phpt
new file mode 100644
index 0000000..b078c51
--- /dev/null
+++ b/ext/spl/tests/arrayObject_getFlags_basic1.phpt
@@ -0,0 +1,25 @@
+--TEST--
+SPL: ArrayObject::getFlags() basic usage
+--FILE--
+<?php
+$ao = new ArrayObject(new ArrayObject(new stdClass));
+var_dump($ao->getFlags());
+
+$ao = new ArrayObject(new ArrayObject(array(1,2,3)), ArrayObject::STD_PROP_LIST);
+var_dump($ao->getFlags());
+
+$ao = new ArrayObject(new ArrayIterator(new ArrayObject()), ArrayObject::ARRAY_AS_PROPS);
+var_dump($ao->getFlags());
+
+$ao = new ArrayObject(new ArrayObject(), ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS);
+var_dump($ao->getFlags());
+
+$cao = clone $ao;
+var_dump($cao->getFlags());
+?>
+--EXPECTF--
+int(0)
+int(1)
+int(2)
+int(3)
+int(3) \ No newline at end of file
diff --git a/ext/spl/tests/arrayObject_getFlags_basic2.phpt b/ext/spl/tests/arrayObject_getFlags_basic2.phpt
new file mode 100644
index 0000000..f7d56ea
--- /dev/null
+++ b/ext/spl/tests/arrayObject_getFlags_basic2.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: ArrayObject::getFlags() - ensure flags are passed on to nested array objects and iterators.
+--FILE--
+<?php
+$ao = new ArrayObject(array(), ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS);
+var_dump($ao->getFlags());
+
+$ao2 = new ArrayObject($ao);
+var_dump($ao2->getFlags());
+var_dump($ao2->getIterator()->getFlags());
+
+$ai = new ArrayIterator($ao);
+var_dump($ai->getFlags());
+
+$ao2 = new ArrayObject($ao, 0);
+var_dump($ao2->getFlags());
+
+?>
+--EXPECTF--
+int(3)
+int(3)
+int(3)
+int(3)
+int(0) \ No newline at end of file
diff --git a/ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt b/ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt
new file mode 100644
index 0000000..b23c196
--- /dev/null
+++ b/ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt
@@ -0,0 +1,116 @@
+--TEST--
+SPL: ArrayObject::getIteratorClass and ArrayObject::setIteratorClass basic functionality
+--FILE--
+<?php
+class MyIterator extends ArrayIterator {
+
+ function __construct() {
+ $args = func_get_args();
+ echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+
+ function rewind() {
+ $args = func_get_args();
+ echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ return parent::rewind();
+ }
+
+ function valid() {
+ $args = func_get_args();
+ echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ return parent::valid();
+ }
+
+ function current() {
+ $args = func_get_args();
+ echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ return parent::current();
+ }
+
+ function next() {
+ $args = func_get_args();
+ echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ return parent::next();
+ }
+
+ function key() {
+ $args = func_get_args();
+ echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ return parent::key();
+ }
+}
+
+$ao = new ArrayObject(array('a'=>1,'b'=>2,'c'=>3), 0, "MyIterator");
+
+echo "--> Access using MyIterator:\n";
+var_dump($ao->getIteratorClass());
+var_dump($ao->getIterator());
+foreach($ao as $key=>$value) {
+ echo " $key=>$value\n";
+}
+
+echo "\n\n--> Access using ArrayIterator:\n";
+var_dump($ao->setIteratorClass("ArrayIterator"));
+var_dump($ao->getIteratorClass());
+var_dump($ao->getIterator());
+foreach($ao as $key=>$value) {
+ echo "$key=>$value\n";
+}
+
+?>
+--EXPECTF--
+--> Access using MyIterator:
+string(10) "MyIterator"
+object(MyIterator)#2 (1) {
+ ["storage":"ArrayIterator":private]=>
+ object(ArrayObject)#1 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ }
+ }
+}
+ In MyIterator::rewind()
+ In MyIterator::valid()
+ In MyIterator::current()
+ In MyIterator::key()
+ a=>1
+ In MyIterator::next()
+ In MyIterator::valid()
+ In MyIterator::current()
+ In MyIterator::key()
+ b=>2
+ In MyIterator::next()
+ In MyIterator::valid()
+ In MyIterator::current()
+ In MyIterator::key()
+ c=>3
+ In MyIterator::next()
+ In MyIterator::valid()
+
+
+--> Access using ArrayIterator:
+NULL
+string(13) "ArrayIterator"
+object(ArrayIterator)#3 (1) {
+ ["storage":"ArrayIterator":private]=>
+ object(ArrayObject)#1 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ }
+ }
+}
+a=>1
+b=>2
+c=>3
diff --git a/ext/spl/tests/arrayObject_ksort_basic1.phpt b/ext/spl/tests/arrayObject_ksort_basic1.phpt
new file mode 100644
index 0000000..8f37938
--- /dev/null
+++ b/ext/spl/tests/arrayObject_ksort_basic1.phpt
@@ -0,0 +1,67 @@
+--TEST--
+SPL: Test ArrayObject::ksort() function : basic functionality with array based store
+--FILE--
+<?php
+/* Prototype : int ArrayObject::ksort()
+ * Description: proto int ArrayIterator::ksort()
+ * Sort the entries by key.
+ * Source code: ext/spl/spl_array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ArrayObject::ksort() : basic functionality ***\n";
+$ao1 = new ArrayObject(array(4,2,3));
+$ao2 = new ArrayObject(array('b'=>4,'a'=>2,'q'=>3, 99=>'x'));
+var_dump($ao1->ksort());
+var_dump($ao1);
+var_dump($ao2->ksort('blah'));
+var_dump($ao2);
+var_dump($ao2->ksort(SORT_STRING));
+var_dump($ao2);
+?>
+===DONE===
+--EXPECTF--
+*** Testing ArrayObject::ksort() : basic functionality ***
+bool(true)
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+
+Warning: ksort() expects parameter 2 to be long, string given in %sarrayObject_ksort_basic1.php on line %d
+bool(false)
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(4) {
+ ["b"]=>
+ int(4)
+ ["a"]=>
+ int(2)
+ ["q"]=>
+ int(3)
+ [99]=>
+ string(1) "x"
+ }
+}
+bool(true)
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(4) {
+ [99]=>
+ string(1) "x"
+ ["a"]=>
+ int(2)
+ ["b"]=>
+ int(4)
+ ["q"]=>
+ int(3)
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/arrayObject_ksort_basic2.phpt b/ext/spl/tests/arrayObject_ksort_basic2.phpt
new file mode 100644
index 0000000..1464e73
--- /dev/null
+++ b/ext/spl/tests/arrayObject_ksort_basic2.phpt
@@ -0,0 +1,52 @@
+--TEST--
+SPL: Test ArrayObject::ksort() function : basic functionality with object base store
+--FILE--
+<?php
+/* Prototype : int ArrayObject::ksort()
+ * Description: proto int ArrayIterator::ksort()
+ * Sort the entries by key.
+ * Source code: ext/spl/spl_array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ArrayObject::ksort() : basic functionality ***\n";
+Class C {
+ public $x = 'prop1';
+ public $z = 'prop2';
+ public $a = 'prop3';
+ private $b = 'prop4';
+}
+
+$c = new C;
+$ao1 = new ArrayObject($c);
+var_dump($ao1->ksort());
+var_dump($ao1, $c);
+?>
+===DONE===
+--EXPECTF--
+*** Testing ArrayObject::ksort() : basic functionality ***
+bool(true)
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (4) {
+ ["b":"C":private]=>
+ string(5) "prop4"
+ ["a"]=>
+ string(5) "prop3"
+ ["x"]=>
+ string(5) "prop1"
+ ["z"]=>
+ string(5) "prop2"
+ }
+}
+object(C)#1 (4) {
+ ["b":"C":private]=>
+ string(5) "prop4"
+ ["a"]=>
+ string(5) "prop3"
+ ["x"]=>
+ string(5) "prop1"
+ ["z"]=>
+ string(5) "prop2"
+}
+===DONE===
diff --git a/ext/spl/tests/arrayObject_magicMethods1.phpt b/ext/spl/tests/arrayObject_magicMethods1.phpt
new file mode 100644
index 0000000..ec4812f
--- /dev/null
+++ b/ext/spl/tests/arrayObject_magicMethods1.phpt
@@ -0,0 +1,195 @@
+--TEST--
+SPL: ArrayObject: ensure a wrapped object's magic methods for property access are not invoked when manipulating the ArrayObject's elements using [].
+--FILE--
+<?php
+class UsesMagic {
+ public $a = 1;
+ public $b = 2;
+ public $c = 3;
+
+ private $priv = 'secret';
+
+ function __get($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __set($name, $value) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __isset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __unset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+
+}
+
+$obj = new UsesMagic;
+
+$ao = new ArrayObject($obj);
+echo "\n--> Write existent, non-existent and dynamic:\n";
+$ao['a'] = 'changed';
+$ao['dynamic'] = 'new';
+$ao['dynamic'] = 'new.changed';
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Read existent, non-existent and dynamic:\n";
+var_dump($ao['a']);
+var_dump($ao['nonexistent']);
+var_dump($ao['dynamic']);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> isset existent, non-existent and dynamic:\n";
+var_dump(isset($ao['a']));
+var_dump(isset($ao['nonexistent']));
+var_dump(isset($ao['dynamic']));
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Unset existent, non-existent and dynamic:\n";
+unset($ao['a']);
+unset($ao['nonexistent']);
+unset($ao['dynamic']);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+?>
+--EXPECTF--
+--> Write existent, non-existent and dynamic:
+ Original wrapped object:
+object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> Read existent, non-existent and dynamic:
+string(7) "changed"
+
+Notice: Undefined index: nonexistent in %s on line 42
+NULL
+string(11) "new.changed"
+ Original wrapped object:
+object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> isset existent, non-existent and dynamic:
+bool(true)
+bool(false)
+bool(true)
+ Original wrapped object:
+object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> Unset existent, non-existent and dynamic:
+
+Notice: Undefined index: nonexistent in %s on line 60
+ Original wrapped object:
+object(UsesMagic)#1 (3) {
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (3) {
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ }
+}
diff --git a/ext/spl/tests/arrayObject_magicMethods2.phpt b/ext/spl/tests/arrayObject_magicMethods2.phpt
new file mode 100644
index 0000000..691a9a1
--- /dev/null
+++ b/ext/spl/tests/arrayObject_magicMethods2.phpt
@@ -0,0 +1,197 @@
+--TEST--
+SPL: ArrayObject: ensure a wrapped object's magic methods for property access are not invoked when manipulating the ArrayObject's elements using ->.
+--FILE--
+<?php
+class UsesMagic {
+ public $a = 1;
+ public $b = 2;
+ public $c = 3;
+
+ private $priv = 'secret';
+
+ function __get($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __set($name, $value) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __isset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __unset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+
+}
+
+$obj = new UsesMagic;
+
+$ao = new ArrayObject($obj);
+echo "\n--> Write existent, non-existent and dynamic:\n";
+$ao->a = 'changed';
+$ao->dynamic = 'new';
+$ao->dynamic = 'new.changed';
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Read existent, non-existent and dynamic:\n";
+var_dump($ao->a);
+var_dump($ao->nonexistent);
+var_dump($ao->dynamic);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> isset existent, non-existent and dynamic:\n";
+var_dump(isset($ao->a));
+var_dump(isset($ao->nonexistent));
+var_dump(isset($ao->dynamic));
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Unset existent, non-existent and dynamic:\n";
+unset($ao->a);
+unset($ao->nonexistent);
+unset($ao->dynamic);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+?>
+--EXPECTF--
+--> Write existent, non-existent and dynamic:
+ Original wrapped object:
+object(UsesMagic)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (3) {
+ ["a"]=>
+ string(7) "changed"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ }
+}
+
+--> Read existent, non-existent and dynamic:
+string(7) "changed"
+
+Notice: Undefined property: ArrayObject::$nonexistent in %s on line 42
+NULL
+string(11) "new.changed"
+ Original wrapped object:
+object(UsesMagic)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (3) {
+ ["a"]=>
+ string(7) "changed"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ }
+}
+
+--> isset existent, non-existent and dynamic:
+bool(true)
+bool(false)
+bool(true)
+ Original wrapped object:
+object(UsesMagic)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (3) {
+ ["a"]=>
+ string(7) "changed"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ }
+}
+
+--> Unset existent, non-existent and dynamic:
+ Original wrapped object:
+object(UsesMagic)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ }
+}
diff --git a/ext/spl/tests/arrayObject_magicMethods3.phpt b/ext/spl/tests/arrayObject_magicMethods3.phpt
new file mode 100644
index 0000000..6231cea
--- /dev/null
+++ b/ext/spl/tests/arrayObject_magicMethods3.phpt
@@ -0,0 +1,195 @@
+--TEST--
+SPL: ArrayObject: ensure a wrapped object's magic methods for property access are not invoked when manipulating the ArrayObject's elements using -> and ArrayObject::ARRAY_AS_PROPS.
+--FILE--
+<?php
+class UsesMagic {
+ public $a = 1;
+ public $b = 2;
+ public $c = 3;
+
+ private $priv = 'secret';
+
+ function __get($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __set($name, $value) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __isset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __unset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+
+}
+
+$obj = new UsesMagic;
+
+$ao = new ArrayObject($obj, ArrayObject::ARRAY_AS_PROPS);
+echo "\n--> Write existent, non-existent and dynamic:\n";
+$ao->a = 'changed';
+$ao->dynamic = 'new';
+$ao->dynamic = 'new.changed';
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Read existent, non-existent and dynamic:\n";
+var_dump($ao->a);
+var_dump($ao->nonexistent);
+var_dump($ao->dynamic);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> isset existent, non-existent and dynamic:\n";
+var_dump(isset($ao->a));
+var_dump(isset($ao->nonexistent));
+var_dump(isset($ao->dynamic));
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Unset existent, non-existent and dynamic:\n";
+unset($ao->a);
+unset($ao->nonexistent);
+unset($ao->dynamic);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+?>
+--EXPECTF--
+--> Write existent, non-existent and dynamic:
+ Original wrapped object:
+object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> Read existent, non-existent and dynamic:
+string(7) "changed"
+
+Notice: Undefined index: nonexistent in %s on line 42
+NULL
+string(11) "new.changed"
+ Original wrapped object:
+object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> isset existent, non-existent and dynamic:
+bool(true)
+bool(false)
+bool(true)
+ Original wrapped object:
+object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> Unset existent, non-existent and dynamic:
+
+Notice: Undefined index: nonexistent in %s on line 60
+ Original wrapped object:
+object(UsesMagic)#1 (3) {
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ object(UsesMagic)#1 (3) {
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"UsesMagic":private]=>
+ string(6) "secret"
+ }
+}
diff --git a/ext/spl/tests/arrayObject_magicMethods4.phpt b/ext/spl/tests/arrayObject_magicMethods4.phpt
new file mode 100644
index 0000000..9580dc5
--- /dev/null
+++ b/ext/spl/tests/arrayObject_magicMethods4.phpt
@@ -0,0 +1,206 @@
+--TEST--
+SPL: ArrayObject: ensure the magic methods for property access of a subclass of ArrayObject are not invoked when manipulating its elements using [].
+--FILE--
+<?php
+class C {
+ public $a = 1;
+ public $b = 2;
+ public $c = 3;
+
+ private $priv = 'secret';
+}
+
+class UsesMagic extends ArrayObject {
+
+ public $b = "This should not be in the storage";
+
+ function __get($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __set($name, $value) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __isset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __unset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+
+}
+$obj = new C;
+$ao = new UsesMagic($obj);
+echo "\n--> Write existent, non-existent and dynamic:\n";
+$ao['a'] = 'changed';
+$ao['dynamic'] = 'new';
+$ao['dynamic'] = 'new.changed';
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Read existent, non-existent and dynamic:\n";
+var_dump($ao['a']);
+var_dump($ao['nonexistent']);
+var_dump($ao['dynamic']);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> isset existent, non-existent and dynamic:\n";
+var_dump(isset($ao['a']));
+var_dump(isset($ao['nonexistent']));
+var_dump(isset($ao['dynamic']));
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Unset existent, non-existent and dynamic:\n";
+unset($ao['a']);
+unset($ao['nonexistent']);
+unset($ao['dynamic']);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+?>
+--EXPECTF--
+--> Write existent, non-existent and dynamic:
+ Original wrapped object:
+object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(33) "This should not be in the storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> Read existent, non-existent and dynamic:
+string(7) "changed"
+
+Notice: Undefined index: nonexistent in %s on line 45
+NULL
+string(11) "new.changed"
+ Original wrapped object:
+object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(33) "This should not be in the storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> isset existent, non-existent and dynamic:
+bool(true)
+bool(false)
+bool(true)
+ Original wrapped object:
+object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(33) "This should not be in the storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> Unset existent, non-existent and dynamic:
+
+Notice: Undefined index: nonexistent in %s on line 63
+ Original wrapped object:
+object(C)#1 (3) {
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(33) "This should not be in the storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (3) {
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ }
+}
diff --git a/ext/spl/tests/arrayObject_magicMethods5.phpt b/ext/spl/tests/arrayObject_magicMethods5.phpt
new file mode 100644
index 0000000..023086d
--- /dev/null
+++ b/ext/spl/tests/arrayObject_magicMethods5.phpt
@@ -0,0 +1,206 @@
+--TEST--
+SPL: ArrayObject: ensure the magic methods for property access of a subclass of ArrayObject ARE invoked when manipulating its elements using ->.
+--FILE--
+<?php
+class C {
+ public $a = 1;
+ public $b = 2;
+ public $c = 3;
+
+ private $priv = 'secret';
+}
+
+class UsesMagic extends ArrayObject {
+
+ public $b = "This should appear in storage";
+
+ function __get($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __set($name, $value) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __isset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __unset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+
+}
+$obj = new C;
+$ao = new UsesMagic($obj);
+echo "\n--> Write existent, non-existent and dynamic:\n";
+$ao->a = 'changed';
+$ao->dynamic = 'new';
+$ao->dynamic = 'new.changed';
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Read existent, non-existent and dynamic:\n";
+var_dump($ao->a);
+var_dump($ao->nonexistent);
+var_dump($ao->dynamic);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> isset existent, non-existent and dynamic:\n";
+var_dump(isset($ao->a));
+var_dump(isset($ao->nonexistent));
+var_dump(isset($ao->dynamic));
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Unset existent, non-existent and dynamic:\n";
+unset($ao->a);
+unset($ao->nonexistent);
+unset($ao->dynamic);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+?>
+--EXPECTF--
+--> Write existent, non-existent and dynamic:
+In UsesMagic::__set(a,changed)
+In UsesMagic::__set(dynamic,new)
+In UsesMagic::__set(dynamic,new.changed)
+ Original wrapped object:
+object(C)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(29) "This should appear in storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ }
+}
+
+--> Read existent, non-existent and dynamic:
+In UsesMagic::__get(a)
+NULL
+In UsesMagic::__get(nonexistent)
+NULL
+In UsesMagic::__get(dynamic)
+NULL
+ Original wrapped object:
+object(C)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(29) "This should appear in storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ }
+}
+
+--> isset existent, non-existent and dynamic:
+In UsesMagic::__isset(a)
+bool(false)
+In UsesMagic::__isset(nonexistent)
+bool(false)
+In UsesMagic::__isset(dynamic)
+bool(false)
+ Original wrapped object:
+object(C)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(29) "This should appear in storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ }
+}
+
+--> Unset existent, non-existent and dynamic:
+In UsesMagic::__unset(a)
+In UsesMagic::__unset(nonexistent)
+In UsesMagic::__unset(dynamic)
+ Original wrapped object:
+object(C)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(29) "This should appear in storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (4) {
+ ["a"]=>
+ int(1)
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ }
+}
diff --git a/ext/spl/tests/arrayObject_magicMethods6.phpt b/ext/spl/tests/arrayObject_magicMethods6.phpt
new file mode 100644
index 0000000..b43f56c
--- /dev/null
+++ b/ext/spl/tests/arrayObject_magicMethods6.phpt
@@ -0,0 +1,206 @@
+--TEST--
+SPL: ArrayObject: ensure the magic methods for property access of a subclass of ArrayObject are not invoked when manipulating its elements using -> ArrayObject::ARRAY_AS_PROPS.
+--FILE--
+<?php
+class C {
+ public $a = 1;
+ public $b = 2;
+ public $c = 3;
+
+ private $priv = 'secret';
+}
+
+class UsesMagic extends ArrayObject {
+
+ public $b = "This should never appear in storage";
+
+ function __get($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __set($name, $value) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __isset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+ function __unset($name) {
+ $args = func_get_args();
+ echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ }
+
+}
+$obj = new C;
+$ao = new UsesMagic($obj, ArrayObject::ARRAY_AS_PROPS);
+echo "\n--> Write existent, non-existent and dynamic:\n";
+$ao->a = 'changed';
+$ao->dynamic = 'new';
+$ao->dynamic = 'new.changed';
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Read existent, non-existent and dynamic:\n";
+var_dump($ao->a);
+var_dump($ao->nonexistent);
+var_dump($ao->dynamic);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> isset existent, non-existent and dynamic:\n";
+var_dump(isset($ao->a));
+var_dump(isset($ao->nonexistent));
+var_dump(isset($ao->dynamic));
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+
+echo "\n--> Unset existent, non-existent and dynamic:\n";
+unset($ao->a);
+unset($ao->nonexistent);
+unset($ao->dynamic);
+echo " Original wrapped object:\n";
+var_dump($obj);
+echo " Wrapping ArrayObject:\n";
+var_dump($ao);
+?>
+--EXPECTF--
+--> Write existent, non-existent and dynamic:
+ Original wrapped object:
+object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(35) "This should never appear in storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> Read existent, non-existent and dynamic:
+string(7) "changed"
+
+Notice: Undefined index: nonexistent in %s on line 45
+NULL
+string(11) "new.changed"
+ Original wrapped object:
+object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(35) "This should never appear in storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> isset existent, non-existent and dynamic:
+bool(true)
+bool(false)
+bool(true)
+ Original wrapped object:
+object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(35) "This should never appear in storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (5) {
+ ["a"]=>
+ string(7) "changed"
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ ["dynamic"]=>
+ string(11) "new.changed"
+ }
+}
+
+--> Unset existent, non-existent and dynamic:
+
+Notice: Undefined index: nonexistent in %s on line 63
+ Original wrapped object:
+object(C)#1 (3) {
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+}
+ Wrapping ArrayObject:
+object(UsesMagic)#2 (2) {
+ ["b"]=>
+ string(35) "This should never appear in storage"
+ ["storage":"ArrayObject":private]=>
+ object(C)#1 (3) {
+ ["b"]=>
+ int(2)
+ ["c"]=>
+ int(3)
+ ["priv":"C":private]=>
+ string(6) "secret"
+ }
+}
diff --git a/ext/spl/tests/arrayObject_natcasesort_basic1.phpt b/ext/spl/tests/arrayObject_natcasesort_basic1.phpt
new file mode 100644
index 0000000..62ad2ed
--- /dev/null
+++ b/ext/spl/tests/arrayObject_natcasesort_basic1.phpt
@@ -0,0 +1,56 @@
+--TEST--
+SPL: Test ArrayObject::natcasesort() function : basic functionality
+--FILE--
+<?php
+/* Prototype : int ArrayObject::natcasesort()
+ * Description: proto int ArrayIterator::natcasesort()
+ Sort the entries by values using case insensitive "natural order" algorithm.
+ * Source code: ext/spl/spl_array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ArrayObject::natcasesort() : basic functionality ***\n";
+
+$ao1 = new ArrayObject(array('boo10','boo1','boo2','boo22','BOO5'));
+$ao2 = new ArrayObject(array('a'=>'boo10','b'=>'boo1','c'=>'boo2','d'=>'boo22','e'=>'BOO5'));
+var_dump($ao1->natcasesort());
+var_dump($ao1);
+var_dump($ao2->natcasesort('blah'));
+var_dump($ao2);
+?>
+===DONE===
+--EXPECTF--
+*** Testing ArrayObject::natcasesort() : basic functionality ***
+bool(true)
+object(ArrayObject)#1 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(5) {
+ [1]=>
+ string(4) "boo1"
+ [2]=>
+ string(4) "boo2"
+ [4]=>
+ string(4) "BOO5"
+ [0]=>
+ string(5) "boo10"
+ [3]=>
+ string(5) "boo22"
+ }
+}
+bool(true)
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(5) {
+ ["b"]=>
+ string(4) "boo1"
+ ["c"]=>
+ string(4) "boo2"
+ ["e"]=>
+ string(4) "BOO5"
+ ["a"]=>
+ string(5) "boo10"
+ ["d"]=>
+ string(5) "boo22"
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/arrayObject_natsort_basic1.phpt b/ext/spl/tests/arrayObject_natsort_basic1.phpt
new file mode 100644
index 0000000..1b4fd60
--- /dev/null
+++ b/ext/spl/tests/arrayObject_natsort_basic1.phpt
@@ -0,0 +1,57 @@
+--TEST--
+SPL: Test ArrayObject::natsort() function : basic functionality
+--FILE--
+<?php
+/* Prototype : int ArrayObject::natsort()
+ * Description: proto int ArrayIterator::natsort()
+ Sort the entries by values using "natural order" algorithm.
+ * Source code: ext/spl/spl_array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ArrayObject::natsort() : basic functionality ***\n";
+
+$ao1 = new ArrayObject(array('boo10','boo1','boo2','boo22','BOO5'));
+$ao2 = new ArrayObject(array('a'=>'boo10','b'=>'boo1','c'=>'boo2','d'=>'boo22','e'=>'BOO5'));
+var_dump($ao1->natsort());
+var_dump($ao1);
+var_dump($ao2->natsort('blah'));
+var_dump($ao2);
+?>
+===DONE===
+--EXPECTF--
+*** Testing ArrayObject::natsort() : basic functionality ***
+bool(true)
+object(ArrayObject)#1 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(5) {
+ [4]=>
+ string(4) "BOO5"
+ [1]=>
+ string(4) "boo1"
+ [2]=>
+ string(4) "boo2"
+ [0]=>
+ string(5) "boo10"
+ [3]=>
+ string(5) "boo22"
+ }
+}
+bool(true)
+object(ArrayObject)#2 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(5) {
+ ["e"]=>
+ string(4) "BOO5"
+ ["b"]=>
+ string(4) "boo1"
+ ["c"]=>
+ string(4) "boo2"
+ ["a"]=>
+ string(5) "boo10"
+ ["d"]=>
+ string(5) "boo22"
+ }
+}
+===DONE===
+
diff --git a/ext/spl/tests/arrayObject_offsetExists_nullcheck.phpt b/ext/spl/tests/arrayObject_offsetExists_nullcheck.phpt
new file mode 100644
index 0000000..1953643
--- /dev/null
+++ b/ext/spl/tests/arrayObject_offsetExists_nullcheck.phpt
@@ -0,0 +1,10 @@
+--TEST--
+SPL: ArrayObject::offsetExists() should return true for element containing NULL
+--FILE--
+<?php
+$ao = new ArrayObject(array('foo' => null));
+var_dump($ao->offsetExists('foo'));
+
+?>
+--EXPECTF--
+bool(true) \ No newline at end of file
diff --git a/ext/spl/tests/arrayObject_setFlags_basic1.phpt b/ext/spl/tests/arrayObject_setFlags_basic1.phpt
new file mode 100644
index 0000000..391b0ee
--- /dev/null
+++ b/ext/spl/tests/arrayObject_setFlags_basic1.phpt
@@ -0,0 +1,51 @@
+--TEST--
+SPL: ArrayObject::setFlags basic usage with ArrayObject::ARRAY_AS_PROPS. Currently fails on php.net due to bug 45622.
+--FILE--
+<?php
+class C extends ArrayObject {
+ public $p = 'object property';
+}
+
+function access_p($ao) {
+ // isset
+ var_dump(isset($ao->p));
+ // read
+ var_dump($ao->p);
+ // write
+ $ao->p = $ao->p . '.changed';
+ var_dump($ao->p);
+}
+
+$ao = new C(array('p'=>'array element'));
+$ao->setFlags(ArrayObject::ARRAY_AS_PROPS);
+
+echo "\n--> Access the real property:\n";
+access_p($ao);
+
+echo "\n--> Remove the real property and access the array element:\n";
+unset($ao->p);
+access_p($ao);
+
+echo "\n--> Remove the array element and try access again:\n";
+unset($ao->p);
+access_p($ao);
+?>
+--EXPECTF--
+--> Access the real property:
+bool(true)
+string(15) "object property"
+string(23) "object property.changed"
+
+--> Remove the real property and access the array element:
+bool(true)
+string(13) "array element"
+string(21) "array element.changed"
+
+--> Remove the array element and try access again:
+bool(false)
+
+Notice: Undefined index: p in %s on line 10
+NULL
+
+Notice: Undefined index: p in %s on line 12
+string(8) ".changed"
diff --git a/ext/spl/tests/arrayObject_setFlags_basic2.phpt b/ext/spl/tests/arrayObject_setFlags_basic2.phpt
new file mode 100644
index 0000000..806f812
--- /dev/null
+++ b/ext/spl/tests/arrayObject_setFlags_basic2.phpt
@@ -0,0 +1,29 @@
+--TEST--
+SPL: Ensure access to non-visible properties falls back to dimension access with ArrayObject::ARRAY_AS_PROPS.
+--FILE--
+<?php
+class C extends ArrayObject {
+ private $x = 'secret';
+
+ static function go($c) {
+ var_dump($c->x);
+ }
+}
+
+$c = new C(array('x'=>'public'));
+
+$c->setFlags(ArrayObject::ARRAY_AS_PROPS);
+C::go($c);
+var_dump($c->x);
+
+
+$c->setFlags(0);
+C::go($c);
+var_dump($c->x);
+?>
+--EXPECTF--
+string(6) "secret"
+string(6) "public"
+string(6) "secret"
+
+Fatal error: Cannot access private property C::$x in %s on line 19
diff --git a/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt b/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt
new file mode 100644
index 0000000..4715eea
--- /dev/null
+++ b/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt
@@ -0,0 +1,56 @@
+--TEST--
+SPL: ArrayObject with bad iterator class.
+--FILE--
+<?php
+try {
+ $ao = new ArrayObject(array('a'=>1,'b'=>2,'c'=>3));
+ $ao->setIteratorClass("nonExistentClass");
+ foreach($ao as $key=>$value) {
+ echo " $key=>$value\n";
+ }
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ $ao = new ArrayObject(array('a'=>1,'b'=>2,'c'=>3));
+ $ao->setIteratorClass("stdClass");
+ foreach($ao as $key=>$value) {
+ echo " $key=>$value\n";
+ }
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+
+try {
+ $ao = new ArrayObject(array('a'=>1,'b'=>2,'c'=>3), 0, "nonExistentClass");
+ foreach($ao as $key=>$value) {
+ echo " $key=>$value\n";
+ }
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+try {
+ $ao = new ArrayObject(array('a'=>1,'b'=>2,'c'=>3), 0, "stdClass");
+ foreach($ao as $key=>$value) {
+ echo " $key=>$value\n";
+ }
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+Warning: ArrayObject::setIteratorClass() expects parameter 1 to be a class name derived from Iterator, 'nonExistentClass' given in %s on line 4
+ a=>1
+ b=>2
+ c=>3
+
+Warning: ArrayObject::setIteratorClass() expects parameter 1 to be a class name derived from Iterator, 'stdClass' given in %s on line 14
+ a=>1
+ b=>2
+ c=>3
+string(113) "ArrayObject::__construct() expects parameter 3 to be a class name derived from Iterator, 'nonExistentClass' given"
+string(105) "ArrayObject::__construct() expects parameter 3 to be a class name derived from Iterator, 'stdClass' given"
diff --git a/ext/spl/tests/arrayObject_uasort_basic1.phpt b/ext/spl/tests/arrayObject_uasort_basic1.phpt
new file mode 100644
index 0000000..203edb6
--- /dev/null
+++ b/ext/spl/tests/arrayObject_uasort_basic1.phpt
@@ -0,0 +1,44 @@
+--TEST--
+SPL: Test ArrayObject::uasort() function : basic functionality
+--FILE--
+<?php
+/* Prototype : int ArrayObject::uasort(callback cmp_function)
+ * Description: proto int ArrayIterator::uasort(callback cmp_function)
+ Sort the entries by values user defined function.
+ * Source code: ext/spl/spl_array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ArrayObject::uasort() : basic functionality ***\n";
+
+// Reverse sorter
+function cmp($value1, $value2) {
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 < $value2) {
+ return 1;
+ }
+ else
+ return -1;
+}
+$ao = new ArrayObject(array(2,3,1));
+
+$ao->uasort('cmp');
+var_dump($ao);
+?>
+===DONE===
+--EXPECTF--
+*** Testing ArrayObject::uasort() : basic functionality ***
+object(ArrayObject)#1 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [1]=>
+ int(3)
+ [0]=>
+ int(2)
+ [2]=>
+ int(1)
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/arrayObject_uasort_error1.phpt b/ext/spl/tests/arrayObject_uasort_error1.phpt
new file mode 100644
index 0000000..d7306c9
--- /dev/null
+++ b/ext/spl/tests/arrayObject_uasort_error1.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Test ArrayObject::uasort() function : wrong arg count
+--FILE--
+<?php
+/* Prototype : int ArrayObject::uasort(callback cmp_function)
+ * Description: proto int ArrayIterator::uasort(callback cmp_function)
+ Sort the entries by values user defined function.
+ * Source code: ext/spl/spl_array.c
+ * Alias to functions:
+ */
+
+$ao = new ArrayObject();
+
+try {
+ $ao->uasort();
+} catch (BadMethodCallException $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $ao->uasort(1,2);
+} catch (BadMethodCallException $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+Function expects exactly one argument
+Function expects exactly one argument
+===DONE===
diff --git a/ext/spl/tests/arrayObject_uksort_basic1.phpt b/ext/spl/tests/arrayObject_uksort_basic1.phpt
new file mode 100644
index 0000000..1581589
--- /dev/null
+++ b/ext/spl/tests/arrayObject_uksort_basic1.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test ArrayObject::uksort() function : basic functionality
+--FILE--
+<?php
+/* Prototype : int ArrayObject::uksort(callback cmp_function)
+ * Description: proto int ArrayIterator::uksort(callback cmp_function)
+ * Sort the entries by key using user defined function.
+ * Source code: ext/spl/spl_array.c
+ * Alias to functions:
+ */
+
+echo "*** Testing ArrayObject::uksort() : basic functionality ***\n";
+// Reverse sorter
+function cmp($value1, $value2) {
+ if($value1 == $value2) {
+ return 0;
+ }
+ else if($value1 < $value2) {
+ return 1;
+ }
+ else
+ return -1;
+}
+$ao = new ArrayObject(array(3=>0, 2=>1, 5=>2, 6=>3, 1=>4));
+
+$ao->uksort('cmp');
+var_dump($ao);
+?>
+===DONE===
+--EXPECTF--
+*** Testing ArrayObject::uksort() : basic functionality ***
+object(ArrayObject)#1 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(5) {
+ [6]=>
+ int(3)
+ [5]=>
+ int(2)
+ [3]=>
+ int(0)
+ [2]=>
+ int(1)
+ [1]=>
+ int(4)
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/arrayObject_uksort_error1.phpt b/ext/spl/tests/arrayObject_uksort_error1.phpt
new file mode 100644
index 0000000..d019fc4
--- /dev/null
+++ b/ext/spl/tests/arrayObject_uksort_error1.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Test ArrayObject::uksort() function : wrong arg count
+--FILE--
+<?php
+/* Prototype : int ArrayObject::uksort(callback cmp_function)
+ * Description: proto int ArrayIterator::uksort(callback cmp_function)
+ Sort the entries by key using user defined function.
+ * Source code: ext/spl/spl_array.c
+ * Alias to functions:
+ */
+
+$ao = new ArrayObject();
+
+try {
+ $ao->uksort();
+} catch (BadMethodCallException $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $ao->uksort(1,2);
+} catch (BadMethodCallException $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+Function expects exactly one argument
+Function expects exactly one argument
+===DONE===
diff --git a/ext/spl/tests/array_001.phpt b/ext/spl/tests/array_001.phpt
new file mode 100644
index 0000000..b55fcba
--- /dev/null
+++ b/ext/spl/tests/array_001.phpt
@@ -0,0 +1,113 @@
+--TEST--
+SPL: ArrayObject
+--FILE--
+<?php
+
+$ar = array(0=>0, 1=>1);
+$ar = new ArrayObject($ar);
+
+var_dump($ar);
+
+$ar[2] = 2;
+var_dump($ar[2]);
+var_dump($ar["3"] = 3);
+
+var_dump(array_merge((array)$ar, array(4=>4, 5=>5)));
+
+var_dump($ar["a"] = "a");
+
+var_dump($ar);
+var_dump($ar[0]);
+var_dump($ar[6]);
+var_dump($ar["b"]);
+
+unset($ar[1]);
+unset($ar["3"]);
+unset($ar["a"]);
+unset($ar[7]);
+unset($ar["c"]);
+var_dump($ar);
+
+$ar[] = '3';
+$ar[] = 4;
+var_dump($ar);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(2) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(1)
+ }
+}
+int(2)
+int(3)
+array(6) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(1)
+ [2]=>
+ int(2)
+ [3]=>
+ int(3)
+ [4]=>
+ int(4)
+ [5]=>
+ int(5)
+}
+string(1) "a"
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(5) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(1)
+ [2]=>
+ int(2)
+ [3]=>
+ int(3)
+ ["a"]=>
+ string(1) "a"
+ }
+}
+int(0)
+
+Notice: Undefined offset: 6 in %sarray_001.php on line %d
+NULL
+
+Notice: Undefined index: b in %sarray_001.php on line %d
+NULL
+
+Notice: Undefined offset: 7 in %sarray_001.php on line %d
+
+Notice: Undefined index: c in %sarray_001.php on line %d
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(2) {
+ [0]=>
+ int(0)
+ [2]=>
+ int(2)
+ }
+}
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(4) {
+ [0]=>
+ int(0)
+ [2]=>
+ int(2)
+ [4]=>
+ string(1) "3"
+ [5]=>
+ int(4)
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/array_002.phpt b/ext/spl/tests/array_002.phpt
new file mode 100644
index 0000000..5593588
--- /dev/null
+++ b/ext/spl/tests/array_002.phpt
@@ -0,0 +1,41 @@
+--TEST--
+SPL: ArrayObject copy constructor
+--FILE--
+<?php
+
+$array = array('1' => 'one',
+ '2' => 'two',
+ '3' => 'three');
+
+$object = new ArrayObject($array);
+$object[] = 'four';
+
+$arrayObject = new ArrayObject($object);
+
+$arrayObject[] = 'five';
+
+var_dump($arrayObject);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ object(ArrayObject)#1 (1) {
+ ["storage":"ArrayObject":private]=>
+ array(5) {
+ [1]=>
+ string(3) "one"
+ [2]=>
+ string(3) "two"
+ [3]=>
+ string(5) "three"
+ [4]=>
+ string(4) "four"
+ [5]=>
+ string(4) "five"
+ }
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/array_003.phpt b/ext/spl/tests/array_003.phpt
new file mode 100644
index 0000000..de4ce30
--- /dev/null
+++ b/ext/spl/tests/array_003.phpt
@@ -0,0 +1,63 @@
+--TEST--
+SPL: ArrayObject from object
+--FILE--
+<?php
+
+// This test also needs to exclude the protected and private variables
+// since they cannot be accessed from the external object which iterates
+// them.
+
+class test
+{
+ public $pub = "public";
+ protected $pro = "protected";
+ private $pri = "private";
+
+ function __construct()
+ {
+ $this->imp = "implicit";
+ }
+};
+
+$test = new test;
+$test->dyn = "dynamic";
+
+print_r($test);
+
+$object = new ArrayObject($test);
+
+print_r($object);
+
+foreach($test as $key => $val)
+{
+ echo "$key => $val\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+test Object
+(
+ [pub] => public
+ [pro:protected] => protected
+ [pri:test:private] => private
+ [imp] => implicit
+ [dyn] => dynamic
+)
+ArrayObject Object
+(
+ [storage:ArrayObject:private] => test Object
+ (
+ [pub] => public
+ [pro:protected] => protected
+ [pri:test:private] => private
+ [imp] => implicit
+ [dyn] => dynamic
+ )
+
+)
+pub => public
+imp => implicit
+dyn => dynamic
+===DONE===
diff --git a/ext/spl/tests/array_004.phpt b/ext/spl/tests/array_004.phpt
new file mode 100644
index 0000000..0b80e5c
--- /dev/null
+++ b/ext/spl/tests/array_004.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: ArrayIterator
+--FILE--
+<?php
+
+$arr = array(0=>0, 1=>1, 2=>2);
+$obj = new ArrayObject($arr);
+
+foreach($obj as $ak=>$av) {
+ foreach($obj as $bk=>$bv) {
+ if ($ak==0 && $bk==0) {
+ $arr[0] = "modify";
+ }
+ echo "$ak=>$av - $bk=>$bv\n";
+ }
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+0=>0 - 0=>0
+0=>0 - 1=>1
+0=>0 - 2=>2
+1=>1 - 0=>0
+1=>1 - 1=>1
+1=>1 - 2=>2
+2=>2 - 0=>0
+2=>2 - 1=>1
+2=>2 - 2=>2
+Done
diff --git a/ext/spl/tests/array_005.phpt b/ext/spl/tests/array_005.phpt
new file mode 100644
index 0000000..d7ef15d
--- /dev/null
+++ b/ext/spl/tests/array_005.phpt
@@ -0,0 +1,91 @@
+--TEST--
+SPL: ArrayObject/Iterator interaction
+--FILE--
+<?php
+
+class Student
+{
+ private $id;
+ private $name;
+
+ public function __construct($id, $name)
+ {
+ $this->id = $id;
+ $this->name = $name;
+ }
+
+ public function __toString()
+ {
+ return $this->id . ', ' . $this->name;
+ }
+
+ public function getId()
+ {
+ return $this->id;
+ }
+}
+
+class StudentIdFilter extends FilterIterator
+{
+ private $id;
+
+ public function __construct(ArrayObject $students, Student $other)
+ {
+ FilterIterator::__construct($students->getIterator());
+ $this->id = $other->getId();
+ }
+
+ public function accept()
+ {
+ echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n";
+ return $this->current()->getId() == $this->id;
+ }
+}
+
+class StudentList implements IteratorAggregate
+{
+ private $students;
+
+ public function __construct()
+ {
+ $this->students = new ArrayObject(array());
+ }
+
+ public function add(Student $student)
+ {
+ if (!$this->contains($student)) {
+ $this->students[] = $student;
+ }
+ }
+
+ public function contains(Student $student)
+ {
+ foreach ($this->students as $s)
+ {
+ if ($s->getId() == $student->getId()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public function getIterator() {
+ return $this->students->getIterator();
+ }
+}
+
+$students = new StudentList();
+$students->add(new Student('01234123', 'Joe'));
+$students->add(new Student('00000014', 'Bob'));
+$students->add(new Student('00000014', 'Foo'));
+
+foreach ($students as $student) {
+ echo $student, "\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+01234123, Joe
+00000014, Bob
+===DONE===
diff --git a/ext/spl/tests/array_006.phpt b/ext/spl/tests/array_006.phpt
new file mode 100644
index 0000000..49f2838
--- /dev/null
+++ b/ext/spl/tests/array_006.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: ArrayIterator without ArrayObject
+--INI--
+error_reporting=2047
+--FILE--
+<?php
+
+echo "==Normal==\n";
+
+$arr = array(0=>0, 1=>1, 2=>2);
+$obj = new ArrayIterator($arr);
+
+foreach($obj as $ak=>$av) {
+ foreach($obj as $bk=>$bv) {
+ if ($ak==0 && $bk==0) {
+ $arr[0] = "modify";
+ }
+ echo "$ak=>$av - $bk=>$bv\n";
+ }
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+==Normal==
+0=>0 - 0=>0
+0=>0 - 1=>1
+0=>0 - 2=>2
+===DONE===
diff --git a/ext/spl/tests/array_007.phpt b/ext/spl/tests/array_007.phpt
new file mode 100644
index 0000000..7d9bf6a
--- /dev/null
+++ b/ext/spl/tests/array_007.phpt
@@ -0,0 +1,71 @@
+--TEST--
+SPL: ArrayObject/Iterator from IteratorAggregate
+--FILE--
+<?php
+
+// This test also needs to exclude the protected and private variables
+// since they cannot be accessed from the external object which iterates
+// them.
+
+class test implements IteratorAggregate
+{
+ public $pub = "public";
+ protected $pro = "protected";
+ private $pri = "private";
+
+ function __construct()
+ {
+ $this->imp = "implicit";
+ }
+
+ function getIterator()
+ {
+ $it = new ArrayObject($this);
+ return $it->getIterator();
+ }
+};
+
+$test = new test;
+$test->dyn = "dynamic";
+
+print_r($test);
+
+print_r($test->getIterator());
+
+foreach($test as $key => $val)
+{
+ echo "$key => $val\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+test Object
+(
+ [pub] => public
+ [pro:protected] => protected
+ [pri:test:private] => private
+ [imp] => implicit
+ [dyn] => dynamic
+)
+ArrayIterator Object
+(
+ [storage:ArrayIterator:private] => ArrayObject Object
+ (
+ [storage:ArrayObject:private] => test Object
+ (
+ [pub] => public
+ [pro:protected] => protected
+ [pri:test:private] => private
+ [imp] => implicit
+ [dyn] => dynamic
+ )
+
+ )
+
+)
+pub => public
+imp => implicit
+dyn => dynamic
+===DONE===
diff --git a/ext/spl/tests/array_008.phpt b/ext/spl/tests/array_008.phpt
new file mode 100644
index 0000000..e7a618d
--- /dev/null
+++ b/ext/spl/tests/array_008.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: ArrayIterator and foreach reference
+--FILE--
+<?php
+
+$arr = array(0=>0, 1=>1, 2=>2);
+$obj = new ArrayObject($arr);
+
+foreach($obj as $ak=>&$av) {
+ foreach($obj as $bk=>&$bv) {
+ if ($ak==0 && $bk==0) {
+ $bv = "modify";
+ }
+ echo "$ak=>$av - $bk=>$bv\n";
+ }
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+0=>modify - 0=>modify
+0=>modify - 1=>1
+0=>modify - 2=>2
+1=>1 - 0=>modify
+1=>1 - 1=>1
+1=>1 - 2=>2
+2=>2 - 0=>modify
+2=>2 - 1=>1
+2=>2 - 2=>2
+===DONE===
diff --git a/ext/spl/tests/array_009.phpt b/ext/spl/tests/array_009.phpt
new file mode 100644
index 0000000..fc0d60b
--- /dev/null
+++ b/ext/spl/tests/array_009.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: ArrayIterator implementing RecursiveIterator
+--FILE--
+<?php
+
+$array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3);
+
+$dir = new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::LEAVES_ONLY);
+
+foreach ($dir as $file) {
+ print "$file\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+1
+21
+221
+222
+231
+3
+===DONE===
diff --git a/ext/spl/tests/array_009a.phpt b/ext/spl/tests/array_009a.phpt
new file mode 100644
index 0000000..396aa9b
--- /dev/null
+++ b/ext/spl/tests/array_009a.phpt
@@ -0,0 +1,37 @@
+--TEST--
+SPL: ArrayIterator implementing RecursiveIterator
+--FILE--
+<?php
+
+class MyRecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
+{
+ function hasChildren()
+ {
+ return is_array($this->current());
+ }
+
+ function getChildren()
+ {
+ return new MyRecursiveArrayIterator($this->current());
+ }
+}
+
+$array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3);
+
+$dir = new RecursiveIteratorIterator(new MyRecursiveArrayIterator($array), RecursiveIteratorIterator::LEAVES_ONLY);
+
+foreach ($dir as $file) {
+ print "$file\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+1
+21
+221
+222
+231
+3
+===DONE===
diff --git a/ext/spl/tests/array_010.phpt b/ext/spl/tests/array_010.phpt
new file mode 100644
index 0000000..d2f3de7
--- /dev/null
+++ b/ext/spl/tests/array_010.phpt
@@ -0,0 +1,144 @@
+--TEST--
+SPL: ArrayIterator implements ArrayAccess
+--FILE--
+<?php
+
+$obj = new ArrayObject(array('1st', 1, 2=>'3rd', '4th'=>4));
+
+var_dump($obj->getArrayCopy());
+
+echo "===EMPTY===\n";
+var_dump(empty($obj[0]));
+var_dump(empty($obj[1]));
+var_dump(empty($obj[2]));
+var_dump(empty($obj['4th']));
+var_dump(empty($obj['5th']));
+var_dump(empty($obj[6]));
+
+echo "===isset===\n";
+var_dump(isset($obj[0]));
+var_dump(isset($obj[1]));
+var_dump(isset($obj[2]));
+var_dump(isset($obj['4th']));
+var_dump(isset($obj['5th']));
+var_dump(isset($obj[6]));
+
+echo "===offsetGet===\n";
+var_dump($obj[0]);
+var_dump($obj[1]);
+var_dump($obj[2]);
+var_dump($obj['4th']);
+var_dump($obj['5th']);
+var_dump($obj[6]);
+
+echo "===offsetSet===\n";
+echo "WRITE 1\n";
+$obj[1] = 'Changed 1';
+var_dump($obj[1]);
+echo "WRITE 2\n";
+$obj['4th'] = 'Changed 4th';
+var_dump($obj['4th']);
+echo "WRITE 3\n";
+$obj['5th'] = 'Added 5th';
+var_dump($obj['5th']);
+echo "WRITE 4\n";
+$obj[6] = 'Added 6';
+var_dump($obj[6]);
+
+var_dump($obj[0]);
+var_dump($obj[2]);
+
+$x = $obj[6] = 'changed 6';
+var_dump($obj[6]);
+var_dump($x);
+
+echo "===unset===\n";
+var_dump($obj->getArrayCopy());
+unset($obj[2]);
+unset($obj['4th']);
+unset($obj[7]);
+unset($obj['8th']);
+var_dump($obj->getArrayCopy());
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(4) {
+ [0]=>
+ string(3) "1st"
+ [1]=>
+ int(1)
+ [2]=>
+ string(3) "3rd"
+ ["4th"]=>
+ int(4)
+}
+===EMPTY===
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+===isset===
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+===offsetGet===
+string(3) "1st"
+int(1)
+string(3) "3rd"
+int(4)
+
+Notice: Undefined index: 5th in %sarray_010.php on line %d
+NULL
+
+Notice: Undefined offset: 6 in %sarray_010.php on line %d
+NULL
+===offsetSet===
+WRITE 1
+string(9) "Changed 1"
+WRITE 2
+string(11) "Changed 4th"
+WRITE 3
+string(9) "Added 5th"
+WRITE 4
+string(7) "Added 6"
+string(3) "1st"
+string(3) "3rd"
+string(9) "changed 6"
+string(9) "changed 6"
+===unset===
+array(6) {
+ [0]=>
+ string(3) "1st"
+ [1]=>
+ string(9) "Changed 1"
+ [2]=>
+ string(3) "3rd"
+ ["4th"]=>
+ string(11) "Changed 4th"
+ ["5th"]=>
+ string(9) "Added 5th"
+ [6]=>
+ string(9) "changed 6"
+}
+
+Notice: Undefined offset: 7 in %sarray_010.php on line %d
+
+Notice: Undefined index: 8th in %sarray_010.php on line %d
+array(4) {
+ [0]=>
+ string(3) "1st"
+ [1]=>
+ string(9) "Changed 1"
+ ["5th"]=>
+ string(9) "Added 5th"
+ [6]=>
+ string(9) "changed 6"
+}
+===DONE===
diff --git a/ext/spl/tests/array_011.phpt b/ext/spl/tests/array_011.phpt
new file mode 100644
index 0000000..0c5ad55
--- /dev/null
+++ b/ext/spl/tests/array_011.phpt
@@ -0,0 +1,35 @@
+--TEST--
+SPL: ArrayIterator, LimitIterator and string keys
+--FILE--
+<?php
+
+$a = array('zero' => 0, 'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5);
+//foreach (new ArrayIterator($a) as $k => $v)
+foreach (new LimitIterator(new ArrayIterator($a), 1, 3) as $k => $v)
+{
+ var_dump(array($k, $v));
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(3) "one"
+ [1]=>
+ int(1)
+}
+array(2) {
+ [0]=>
+ string(3) "two"
+ [1]=>
+ int(2)
+}
+array(2) {
+ [0]=>
+ string(5) "three"
+ [1]=>
+ int(3)
+}
+===DONE===
diff --git a/ext/spl/tests/array_012.phpt b/ext/spl/tests/array_012.phpt
new file mode 100644
index 0000000..2ee9724
--- /dev/null
+++ b/ext/spl/tests/array_012.phpt
@@ -0,0 +1,63 @@
+--TEST--
+SPL: ArrayIterator::count
+--FILE--
+<?php
+
+echo "===Array===\n";
+
+$a = array('zero' => 0, 'one' => 1, 'two' => 2);
+$it = new ArrayIterator($a);
+
+var_dump($it->count());
+foreach($it as $key => $val)
+{
+ echo "$key=>$val\n";
+ var_dump($it->count());
+}
+var_dump($it->count());
+
+echo "===Object===\n";
+
+class test
+{
+ public $zero = 0;
+ protected $pro;
+ public $one = 1;
+ private $pri;
+ public $two = 2;
+}
+
+$o = new test;
+$it = new ArrayIterator($o);
+
+var_dump($it->count());
+foreach($it as $key => $val)
+{
+ echo "$key=>$val\n";
+ var_dump($it->count());
+}
+var_dump($it->count());
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+===Array===
+int(3)
+zero=>0
+int(3)
+one=>1
+int(3)
+two=>2
+int(3)
+int(3)
+===Object===
+int(3)
+zero=>0
+int(3)
+one=>1
+int(3)
+two=>2
+int(3)
+int(3)
+===DONE===
diff --git a/ext/spl/tests/array_013.phpt b/ext/spl/tests/array_013.phpt
new file mode 100644
index 0000000..3fda538
--- /dev/null
+++ b/ext/spl/tests/array_013.phpt
@@ -0,0 +1,79 @@
+--TEST--
+SPL: ArrayIterator::append
+--FILE--
+<?php
+
+if (!class_exists('NoRewindIterator', false))
+{
+ require_once(dirname(__FILE__) . '/../examples/norewinditerator.inc');
+}
+
+echo "===Array===\n";
+
+$a = array(0 => 'zero', 1 => 'one', 2 => 'two');
+$it = new ArrayIterator($a);
+
+foreach($it as $key => $val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===Append===\n";
+
+$it->append('three');
+$it->append('four');
+
+foreach(new NoRewindIterator($it) as $key => $val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===Object===\n";
+
+class test
+{
+ public $zero = 0;
+ protected $pro;
+ public $one = 1;
+ private $pri;
+ public $two = 2;
+}
+
+$o = new test;
+$it = new ArrayIterator($o);
+
+foreach($it as $key => $val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===Append===\n";
+
+$it->append('three');
+$it->append('four');
+
+foreach(new NoRewindIterator($it) as $key => $val)
+{
+ echo "$key=>$val\n";
+}
+
+var_dump($o->{0}); /* doesn't wotk anyway */
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===Array===
+0=>zero
+1=>one
+2=>two
+===Append===
+3=>three
+4=>four
+===Object===
+zero=>0
+one=>1
+two=>2
+===Append===
+
+Catchable fatal error: ArrayIterator::append(): Cannot append properties to objects, use ArrayIterator::offsetSet() instead in %sarray_013.php on line %d
diff --git a/ext/spl/tests/array_014.phpt b/ext/spl/tests/array_014.phpt
new file mode 100644
index 0000000..1ac9d4f
--- /dev/null
+++ b/ext/spl/tests/array_014.phpt
@@ -0,0 +1,59 @@
+--TEST--
+SPL: ArrayIterator::seek()
+--FILE--
+<?php
+
+$it = new ArrayIterator(range(0,10));
+var_dump($it->count());
+$it->seek(5);
+var_dump($it->current());
+$it->seek(4);
+var_dump($it->current());
+try
+{
+ $it->seek(-1);
+ var_dump($it->current());
+}
+catch(Exception $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+try
+{
+ $it->seek(12);
+ var_dump($it->current());
+}
+catch(Exception $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+$pos = 0;
+foreach($it as $v)
+{
+ $it->seek($pos++);
+ var_dump($v);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(11)
+int(5)
+int(4)
+Seek position -1 is out of range
+Seek position 12 is out of range
+int(0)
+int(1)
+int(2)
+int(3)
+int(4)
+int(5)
+int(6)
+int(7)
+int(8)
+int(9)
+int(10)
+===DONE===
diff --git a/ext/spl/tests/array_015.phpt b/ext/spl/tests/array_015.phpt
new file mode 100644
index 0000000..f0bf9f4
--- /dev/null
+++ b/ext/spl/tests/array_015.phpt
@@ -0,0 +1,97 @@
+--TEST--
+SPL: ArrayIterator::next() with internal arrays
+--FILE--
+<?php
+
+$ar = new ArrayObject();
+
+$ar[0] = 1;
+$ar[1] = 2;
+$ar[2] = 3;
+$ar[3] = 4;
+$ar[4] = 5;
+
+var_dump($ar);
+
+$it = $ar->getIterator();
+
+$ar->offsetUnset($it->key());
+$it->next();
+
+var_dump($it->current());
+var_dump($ar);
+
+foreach($it as $k => $v)
+{
+ $ar->offsetUnset($k+1);
+ echo "$k=>$v\n";
+}
+
+var_dump($ar);
+
+foreach($it as $k => $v)
+{
+ $ar->offsetUnset($k);
+ echo "$k=>$v\n";
+}
+
+var_dump($ar);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+object(ArrayObject)#%d (1) {
+ %s"storage"%s"ArrayObject":private]=>
+ array(5) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ [4]=>
+ int(5)
+ }
+}
+
+Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_015.php on line %d
+int(2)
+object(ArrayObject)#%d (1) {
+ %s"storage"%s"ArrayObject":private]=>
+ array(4) {
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ [4]=>
+ int(5)
+ }
+}
+1=>2
+3=>4
+object(ArrayObject)#%d (1) {
+ %s"storage"%s"ArrayObject":private]=>
+ array(2) {
+ [1]=>
+ int(2)
+ [3]=>
+ int(4)
+ }
+}
+1=>2
+
+Notice: main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_015.php on line %d
+3=>4
+
+Notice: main(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sarray_015.php on line %d
+object(ArrayObject)#%d (1) {
+ %s"storage"%s"ArrayObject":private]=>
+ array(0) {
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/array_016.phpt b/ext/spl/tests/array_016.phpt
new file mode 100644
index 0000000..8637c5c
--- /dev/null
+++ b/ext/spl/tests/array_016.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: ArrayIterator/Object and IteratorIterator
+--FILE--
+<?php
+
+$it = new ArrayIterator(range(0,3));
+
+foreach(new IteratorIterator($it) as $v)
+{
+ var_dump($v);
+}
+
+$it = new ArrayObject(range(0,3));
+
+foreach(new IteratorIterator($it) as $v)
+{
+ var_dump($v);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(0)
+int(1)
+int(2)
+int(3)
+int(0)
+int(1)
+int(2)
+int(3)
+===DONE===
diff --git a/ext/spl/tests/array_017.phpt b/ext/spl/tests/array_017.phpt
new file mode 100644
index 0000000..8f3d345
--- /dev/null
+++ b/ext/spl/tests/array_017.phpt
@@ -0,0 +1,817 @@
+--TEST--
+SPL: ArrayObject::exchangeArray($this)
+--FILE--
+<?php
+
+class ArrayIteratorEx extends ArrayIterator
+{
+ public $pub2 = 1;
+ protected $pro2 = 2;
+ private $pri2 = 3;
+
+ function __construct($ar, $flags = 0)
+ {
+ echo __METHOD__ . "()\n";
+ parent::__construct($ar, $flags);
+ $this->imp2 = 4;
+ }
+
+ function dump()
+ {
+ echo __METHOD__ . "()\n";
+ var_dump(array('Flags'=>$this->getFlags()
+ ,'OVars'=>get_object_vars($this)
+ ,'$this'=>$this));
+ }
+
+ function setFlags($flags)
+ {
+ echo __METHOD__ . "($flags)\n";
+ ArrayIterator::setFlags($flags);
+ }
+}
+
+class ArrayObjectEx extends ArrayObject
+{
+ public $pub1 = 1;
+ protected $pro1 = 2;
+ private $pri1 = 3;
+
+ function __construct($ar = array(), $flags = 0)
+ {
+ echo __METHOD__ . "()\n";
+ parent::__construct($ar, $flags);
+ $this->imp1 = 4;
+ }
+
+ function exchange()
+ {
+ echo __METHOD__ . "()\n";
+ $this->exchangeArray($this);
+ }
+
+ function dump()
+ {
+ echo __METHOD__ . "()\n";
+ var_dump(array('Flags'=>$this->getFlags()
+ ,'OVars'=>get_object_vars($this)
+ ,'$this'=>$this));
+ }
+
+ function show()
+ {
+ echo __METHOD__ . "()\n";
+ foreach($this as $n => $v)
+ {
+ var_dump(array($n => $v));
+ }
+ }
+
+ function setFlags($flags)
+ {
+ echo __METHOD__ . "($flags)\n";
+ ArrayObject::setFlags($flags);
+ }
+
+ function getIterator()
+ {
+ echo __METHOD__ . "()\n";
+ $it = new ArrayIteratorEx($this, $this->getFlags());
+ $it->dyn2 = 5;
+ $it->dump();
+ return $it;
+ }
+}
+
+function check($obj, $flags)
+{
+ echo "===CHECK===\n";
+
+ $obj->setFlags($flags);
+ $obj->dump();
+ $obj->show();
+
+ echo "===FOREACH===\n";
+
+ $it = $obj->getIterator();
+ foreach($it as $n => $v)
+ {
+ var_dump(array($n => $v));
+ }
+
+ echo "===PROPERTY===\n";
+
+ var_dump($obj->pub1);
+ var_dump(isset($obj->a));
+ $obj->setFlags($flags | 2);
+ var_dump($obj->pub1);
+ var_dump(isset($obj->a));
+
+ var_dump($it->pub2);
+ var_dump(isset($it->pub1));
+ $it->setFlags($flags | 2);
+ var_dump($it->pub2);
+ var_dump(isset($it->pub1));
+}
+
+$obj = new ArrayObjectEx(array(0=>1,'a'=>25, 'pub1'=>42), 0);
+$obj->dyn1 = 5;
+
+check($obj, 0);
+check($obj, 1);
+
+echo "#####EXCHANGE#####\n";
+
+$obj->exchange();
+
+check($obj, 0);
+check($obj, 1);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+ArrayObjectEx::__construct()
+===CHECK===
+ArrayObjectEx::setFlags(0)
+ArrayObjectEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(0)
+ ["OVars"]=>
+ array(2) {
+ ["a"]=>
+ int(25)
+ ["pub1"]=>
+ int(42)
+ }
+ ["$this"]=>
+ object(ArrayObjectEx)#%d (6) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ ["a"]=>
+ int(25)
+ ["pub1"]=>
+ int(42)
+ }
+ }
+}
+ArrayObjectEx::show()
+ArrayObjectEx::getIterator()
+ArrayIteratorEx::__construct()
+ArrayIteratorEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(0)
+ ["OVars"]=>
+ array(2) {
+ ["a"]=>
+ int(25)
+ ["pub1"]=>
+ int(42)
+ }
+ ["$this"]=>
+ object(ArrayIteratorEx)#%d (6) {
+ ["pub2"]=>
+ int(1)
+ ["pro2":protected]=>
+ int(2)
+ ["pri2":"ArrayIteratorEx":private]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ ["storage":"ArrayIterator":private]=>
+ object(ArrayObjectEx)#%d (6) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ ["a"]=>
+ int(25)
+ ["pub1"]=>
+ int(42)
+ }
+ }
+ }
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ ["a"]=>
+ int(25)
+}
+array(1) {
+ ["pub1"]=>
+ int(42)
+}
+===FOREACH===
+ArrayObjectEx::getIterator()
+ArrayIteratorEx::__construct()
+ArrayIteratorEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(0)
+ ["OVars"]=>
+ array(2) {
+ ["a"]=>
+ int(25)
+ ["pub1"]=>
+ int(42)
+ }
+ ["$this"]=>
+ object(ArrayIteratorEx)#%d (6) {
+ ["pub2"]=>
+ int(1)
+ ["pro2":protected]=>
+ int(2)
+ ["pri2":"ArrayIteratorEx":private]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ ["storage":"ArrayIterator":private]=>
+ object(ArrayObjectEx)#%d (6) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ ["a"]=>
+ int(25)
+ ["pub1"]=>
+ int(42)
+ }
+ }
+ }
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ ["a"]=>
+ int(25)
+}
+array(1) {
+ ["pub1"]=>
+ int(42)
+}
+===PROPERTY===
+int(1)
+bool(false)
+ArrayObjectEx::setFlags(2)
+int(1)
+bool(true)
+int(1)
+bool(false)
+ArrayIteratorEx::setFlags(2)
+int(1)
+bool(true)
+===CHECK===
+ArrayObjectEx::setFlags(1)
+ArrayObjectEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(1)
+ ["OVars"]=>
+ array(5) {
+ ["pub1"]=>
+ int(1)
+ ["pro1"]=>
+ int(2)
+ ["pri1"]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ }
+ ["$this"]=>
+ object(ArrayObjectEx)#%d (6) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ ["a"]=>
+ int(25)
+ ["pub1"]=>
+ int(42)
+ }
+ }
+}
+ArrayObjectEx::show()
+ArrayObjectEx::getIterator()
+ArrayIteratorEx::__construct()
+ArrayIteratorEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(1)
+ ["OVars"]=>
+ array(5) {
+ ["pub2"]=>
+ int(1)
+ ["pro2"]=>
+ int(2)
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ }
+ ["$this"]=>
+ object(ArrayIteratorEx)#%d (6) {
+ ["pub2"]=>
+ int(1)
+ ["pro2":protected]=>
+ int(2)
+ ["pri2":"ArrayIteratorEx":private]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ ["storage":"ArrayIterator":private]=>
+ object(ArrayObjectEx)#%d (6) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ ["a"]=>
+ int(25)
+ ["pub1"]=>
+ int(42)
+ }
+ }
+ }
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ ["a"]=>
+ int(25)
+}
+array(1) {
+ ["pub1"]=>
+ int(42)
+}
+===FOREACH===
+ArrayObjectEx::getIterator()
+ArrayIteratorEx::__construct()
+ArrayIteratorEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(1)
+ ["OVars"]=>
+ array(5) {
+ ["pub2"]=>
+ int(1)
+ ["pro2"]=>
+ int(2)
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ }
+ ["$this"]=>
+ object(ArrayIteratorEx)#%d (6) {
+ ["pub2"]=>
+ int(1)
+ ["pro2":protected]=>
+ int(2)
+ ["pri2":"ArrayIteratorEx":private]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ ["storage":"ArrayIterator":private]=>
+ object(ArrayObjectEx)#%d (6) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ ["a"]=>
+ int(25)
+ ["pub1"]=>
+ int(42)
+ }
+ }
+ }
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ ["a"]=>
+ int(25)
+}
+array(1) {
+ ["pub1"]=>
+ int(42)
+}
+===PROPERTY===
+int(1)
+bool(false)
+ArrayObjectEx::setFlags(3)
+int(1)
+bool(true)
+int(1)
+bool(false)
+ArrayIteratorEx::setFlags(3)
+int(1)
+bool(true)
+#####EXCHANGE#####
+ArrayObjectEx::exchange()
+===CHECK===
+ArrayObjectEx::setFlags(0)
+ArrayObjectEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(0)
+ ["OVars"]=>
+ array(5) {
+ ["pub1"]=>
+ int(1)
+ ["pro1"]=>
+ int(2)
+ ["pri1"]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ }
+ ["$this"]=>
+ object(ArrayObjectEx)#%d (5) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ }
+}
+ArrayObjectEx::show()
+ArrayObjectEx::getIterator()
+ArrayIteratorEx::__construct()
+ArrayIteratorEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(0)
+ ["OVars"]=>
+ array(4) {
+ ["pub1"]=>
+ int(1)
+ ["pro1"]=>
+ int(2)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ }
+ ["$this"]=>
+ object(ArrayIteratorEx)#%d (6) {
+ ["pub2"]=>
+ int(1)
+ ["pro2":protected]=>
+ int(2)
+ ["pri2":"ArrayIteratorEx":private]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ ["storage":"ArrayIterator":private]=>
+ object(ArrayObjectEx)#%d (5) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ }
+ }
+}
+array(1) {
+ ["pub1"]=>
+ int(1)
+}
+array(1) {
+ ["imp1"]=>
+ int(4)
+}
+array(1) {
+ ["dyn1"]=>
+ int(5)
+}
+===FOREACH===
+ArrayObjectEx::getIterator()
+ArrayIteratorEx::__construct()
+ArrayIteratorEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(0)
+ ["OVars"]=>
+ array(4) {
+ ["pub1"]=>
+ int(1)
+ ["pro1"]=>
+ int(2)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ }
+ ["$this"]=>
+ object(ArrayIteratorEx)#%d (6) {
+ ["pub2"]=>
+ int(1)
+ ["pro2":protected]=>
+ int(2)
+ ["pri2":"ArrayIteratorEx":private]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ ["storage":"ArrayIterator":private]=>
+ object(ArrayObjectEx)#%d (5) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ }
+ }
+}
+array(1) {
+ ["pub1"]=>
+ int(1)
+}
+array(1) {
+ ["imp1"]=>
+ int(4)
+}
+array(1) {
+ ["dyn1"]=>
+ int(5)
+}
+===PROPERTY===
+int(1)
+bool(false)
+ArrayObjectEx::setFlags(2)
+int(1)
+bool(false)
+int(1)
+bool(false)
+ArrayIteratorEx::setFlags(2)
+int(1)
+bool(true)
+===CHECK===
+ArrayObjectEx::setFlags(1)
+ArrayObjectEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(1)
+ ["OVars"]=>
+ array(5) {
+ ["pub1"]=>
+ int(1)
+ ["pro1"]=>
+ int(2)
+ ["pri1"]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ }
+ ["$this"]=>
+ object(ArrayObjectEx)#%d (5) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ }
+}
+ArrayObjectEx::show()
+ArrayObjectEx::getIterator()
+ArrayIteratorEx::__construct()
+ArrayIteratorEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(1)
+ ["OVars"]=>
+ array(5) {
+ ["pub2"]=>
+ int(1)
+ ["pro2"]=>
+ int(2)
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ }
+ ["$this"]=>
+ object(ArrayIteratorEx)#%d (6) {
+ ["pub2"]=>
+ int(1)
+ ["pro2":protected]=>
+ int(2)
+ ["pri2":"ArrayIteratorEx":private]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ ["storage":"ArrayIterator":private]=>
+ object(ArrayObjectEx)#%d (5) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ }
+ }
+}
+array(1) {
+ ["pub1"]=>
+ int(1)
+}
+array(1) {
+ ["imp1"]=>
+ int(4)
+}
+array(1) {
+ ["dyn1"]=>
+ int(5)
+}
+===FOREACH===
+ArrayObjectEx::getIterator()
+ArrayIteratorEx::__construct()
+ArrayIteratorEx::dump()
+array(3) {
+ ["Flags"]=>
+ int(1)
+ ["OVars"]=>
+ array(5) {
+ ["pub2"]=>
+ int(1)
+ ["pro2"]=>
+ int(2)
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ }
+ ["$this"]=>
+ object(ArrayIteratorEx)#%d (6) {
+ ["pub2"]=>
+ int(1)
+ ["pro2":protected]=>
+ int(2)
+ ["pri2":"ArrayIteratorEx":private]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
+ ["storage":"ArrayIterator":private]=>
+ object(ArrayObjectEx)#%d (5) {
+ ["pub1"]=>
+ int(1)
+ ["pro1":protected]=>
+ int(2)
+ ["pri1":"ArrayObjectEx":private]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
+ }
+ }
+}
+array(1) {
+ ["pub1"]=>
+ int(1)
+}
+array(1) {
+ ["imp1"]=>
+ int(4)
+}
+array(1) {
+ ["dyn1"]=>
+ int(5)
+}
+===PROPERTY===
+int(1)
+bool(false)
+ArrayObjectEx::setFlags(3)
+int(1)
+bool(false)
+int(1)
+bool(false)
+ArrayIteratorEx::setFlags(3)
+int(1)
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/array_018.phpt b/ext/spl/tests/array_018.phpt
new file mode 100644
index 0000000..7c68a62
--- /dev/null
+++ b/ext/spl/tests/array_018.phpt
Binary files differ
diff --git a/ext/spl/tests/array_019.phpt b/ext/spl/tests/array_019.phpt
new file mode 100644
index 0000000..d128f4d
--- /dev/null
+++ b/ext/spl/tests/array_019.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: ArrayIterator and foreach by reference
+--FILE--
+<?php
+
+$ar = new ArrayObject(array(1)); foreach($ar as &$v) var_dump($v);
+$ar = new ArrayIterator(array(2)); foreach($ar as &$v) var_dump($v);
+$ar = new RecursiveArrayIterator(array(3)); foreach($ar as &$v) var_dump($v);
+
+class ArrayIteratorEx extends ArrayIterator
+{
+ function current()
+ {
+ return ArrayIterator::current();
+ }
+}
+
+$ar = new ArrayIteratorEx(array(4)); foreach($ar as $v) var_dump($v);
+$ar = new ArrayIteratorEx(array(5)); foreach($ar as &$v) var_dump($v);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(1)
+int(2)
+int(3)
+int(4)
+
+Fatal error: An iterator cannot be used with foreach by reference in %sarray_019.php on line %d
diff --git a/ext/spl/tests/array_020.phpt b/ext/spl/tests/array_020.phpt
new file mode 100644
index 0000000..4c6fe0d
--- /dev/null
+++ b/ext/spl/tests/array_020.phpt
@@ -0,0 +1,64 @@
+--TEST--
+SPL: ArrayIterator overloading
+--FILE--
+<?php
+
+class ArrayIteratorEx extends ArrayIterator
+{
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ ArrayIterator::rewind();
+ }
+
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ return ArrayIterator::valid();
+ }
+
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return ArrayIterator::key();
+ }
+
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return ArrayIterator::current();
+ }
+
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ return ArrayIterator::next();
+ }
+}
+
+$ar = new ArrayIteratorEx(array(1,2));
+foreach($ar as $k => $v)
+{
+ var_dump($k);
+ var_dump($v);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+ArrayIteratorEx::rewind
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+ArrayIteratorEx::key
+int(0)
+int(1)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+ArrayIteratorEx::key
+int(1)
+int(2)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+===DONE===
diff --git a/ext/spl/tests/array_021.phpt b/ext/spl/tests/array_021.phpt
new file mode 100644
index 0000000..f2ae0c8
--- /dev/null
+++ b/ext/spl/tests/array_021.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: ArrayObject::seek() and exceptions
+--FILE--
+<?php
+
+class foo extends ArrayObject
+{
+ public function seek($key)
+ {
+ echo __METHOD__ . "($key)\n";
+ throw new Exception("hi");
+ }
+}
+
+$test = new foo(array(1,2,3));
+
+try
+{
+ $test->seek('bar');
+}
+catch (Exception $e)
+{
+ echo "got exception\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+foo::seek(bar)
+got exception
+===DONE===
diff --git a/ext/spl/tests/array_022.phpt b/ext/spl/tests/array_022.phpt
new file mode 100644
index 0000000..82da3bb
--- /dev/null
+++ b/ext/spl/tests/array_022.phpt
@@ -0,0 +1,80 @@
+--TEST--
+SPL: ArrayObject/Iterator and reference to self
+--FILE--
+==ArrayObject===
+<?php
+
+class MyArrayObject extends ArrayObject
+{
+ public function __construct()
+ {
+ parent::__construct($this);
+ $this['bar'] = 'baz';
+ }
+}
+
+$a = new MyArrayObject;
+
+$b = clone $a;
+$b['baz'] = 'Foo';
+
+var_dump($a);
+var_dump($b);
+
+?>
+==ArrayIterator===
+<?php
+
+class MyArrayIterator extends ArrayIterator
+{
+ public function __construct()
+ {
+ parent::__construct($this);
+ $this['bar'] = 'baz';
+ }
+}
+
+$a = new MyArrayIterator;
+
+$b = clone $a;
+$b['baz'] = 'Foo';
+
+var_dump($a);
+var_dump($b);
+
+?>
+===DONE===
+--EXPECTF--
+==ArrayObject===
+object(MyArrayObject)#%d (1) {
+ ["bar"]=>
+ string(3) "baz"
+}
+object(MyArrayObject)#%d (3) {
+ ["bar"]=>
+ string(3) "baz"
+ ["baz"]=>
+ string(3) "Foo"
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ ["bar"]=>
+ string(3) "baz"
+ }
+}
+==ArrayIterator===
+object(MyArrayIterator)#%d (1) {
+ ["bar"]=>
+ string(3) "baz"
+}
+object(MyArrayIterator)#%d (3) {
+ ["bar"]=>
+ string(3) "baz"
+ ["baz"]=>
+ string(3) "Foo"
+ ["storage":"ArrayIterator":private]=>
+ object(MyArrayIterator)#%d (1) {
+ ["bar"]=>
+ string(3) "baz"
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/array_023.phpt b/ext/spl/tests/array_023.phpt
new file mode 100644
index 0000000..a444604
--- /dev/null
+++ b/ext/spl/tests/array_023.phpt
@@ -0,0 +1,87 @@
+--TEST--
+Testing class extending to ArrayObject and serialize
+--FILE--
+<?php
+
+class Name extends ArrayObject
+{
+ public $var = 'a';
+ protected $bar = 'b';
+ private $foo = 'c';
+}
+
+$a = new Name();
+var_dump($a);
+var_dump($a->var);
+
+$a = unserialize(serialize($a));
+
+var_dump($a);
+var_dump($a->var);
+
+class Bla extends ArrayObject
+{
+ public $var = 'aaa';
+ protected $bar = 'bbb';
+ private $foo = 'ccc';
+}
+
+$a = new Bla();
+var_dump($a);
+var_dump($a->var);
+
+$a = unserialize(serialize($a));
+
+var_dump($a);
+var_dump($a->var);
+
+?>
+--EXPECT--
+object(Name)#1 (4) {
+ ["var"]=>
+ string(1) "a"
+ ["bar":protected]=>
+ string(1) "b"
+ ["foo":"Name":private]=>
+ string(1) "c"
+ ["storage":"ArrayObject":private]=>
+ array(0) {
+ }
+}
+string(1) "a"
+object(Name)#2 (4) {
+ ["var"]=>
+ string(1) "a"
+ ["bar":protected]=>
+ string(1) "b"
+ ["foo":"Name":private]=>
+ string(1) "c"
+ ["storage":"ArrayObject":private]=>
+ array(0) {
+ }
+}
+string(1) "a"
+object(Bla)#1 (4) {
+ ["var"]=>
+ string(3) "aaa"
+ ["bar":protected]=>
+ string(3) "bbb"
+ ["foo":"Bla":private]=>
+ string(3) "ccc"
+ ["storage":"ArrayObject":private]=>
+ array(0) {
+ }
+}
+string(3) "aaa"
+object(Bla)#2 (4) {
+ ["var"]=>
+ string(3) "aaa"
+ ["bar":protected]=>
+ string(3) "bbb"
+ ["foo":"Bla":private]=>
+ string(3) "ccc"
+ ["storage":"ArrayObject":private]=>
+ array(0) {
+ }
+}
+string(3) "aaa"
diff --git a/ext/spl/tests/array_024.phpt b/ext/spl/tests/array_024.phpt
new file mode 100644
index 0000000..0c073bf
--- /dev/null
+++ b/ext/spl/tests/array_024.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: ArrayObject with overriden count()
+--FILE--
+<?php
+$obj = new ArrayObject(array(1,2));
+var_dump(count($obj));
+class ArrayObject2 extends ArrayObject {
+ public function count() {
+ return -parent::count();
+ }
+}
+$obj = new ArrayObject2(array(1,2));
+var_dump(count($obj));
+?>
+--EXPECT--
+int(2)
+int(-2)
diff --git a/ext/spl/tests/array_025.phpt b/ext/spl/tests/array_025.phpt
new file mode 100644
index 0000000..35893ea
--- /dev/null
+++ b/ext/spl/tests/array_025.phpt
@@ -0,0 +1,40 @@
+--TEST--
+SPL: ArrayObject serialize with an object as storage
+--FILE--
+<?php
+$obj1 = new ArrayObject(new ArrayObject(array(1,2)));
+$s = serialize($obj1);
+$obj2 = unserialize($s);
+
+print_r($obj1);
+echo "$s\n";
+print_r($obj2);
+?>
+--EXPECT--
+ArrayObject Object
+(
+ [storage:ArrayObject:private] => ArrayObject Object
+ (
+ [storage:ArrayObject:private] => Array
+ (
+ [0] => 1
+ [1] => 2
+ )
+
+ )
+
+)
+C:11:"ArrayObject":76:{x:i:0;C:11:"ArrayObject":37:{x:i:0;a:2:{i:0;i:1;i:1;i:2;};m:a:0:{}};m:a:0:{}}
+ArrayObject Object
+(
+ [storage:ArrayObject:private] => ArrayObject Object
+ (
+ [storage:ArrayObject:private] => Array
+ (
+ [0] => 1
+ [1] => 2
+ )
+
+ )
+
+)
diff --git a/ext/spl/tests/array_026.phpt b/ext/spl/tests/array_026.phpt
new file mode 100644
index 0000000..9c79c57
--- /dev/null
+++ b/ext/spl/tests/array_026.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: ArrayObject indirect offsetGet overwriting EG(uninitialized_zvar_ptr)
+--FILE--
+<?php
+$test = new ArrayObject();
+$test['d1']['d2'] = 'hello';
+$test['d1']['d3'] = 'world';
+var_dump($test, $test3['mmmmm']);
+?>
+--EXPECTF--
+Notice: Undefined variable: test3 in %s%earray_026.php on line %d
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ ["d1"]=>
+ array(2) {
+ ["d2"]=>
+ string(5) "hello"
+ ["d3"]=>
+ string(5) "world"
+ }
+ }
+}
+NULL
diff --git a/ext/spl/tests/array_027.phpt b/ext/spl/tests/array_027.phpt
new file mode 100644
index 0000000..509b8f9
--- /dev/null
+++ b/ext/spl/tests/array_027.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SPL: ArrayObject revursive var_dump
+--FILE--
+<?php
+class AO extends ArrayObject {
+}
+$o = new AO();
+$o['plop'] = $o;
+
+var_dump($o);
+--EXPECTF--
+object(AO)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(1) {
+ ["plop"]=>
+ *RECURSION*
+ }
+}
diff --git a/ext/spl/tests/bug28822.phpt b/ext/spl/tests/bug28822.phpt
new file mode 100644
index 0000000..7114eda
--- /dev/null
+++ b/ext/spl/tests/bug28822.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #28822 (ArrayObject::offsetExists() works inverted)
+--FILE--
+<?php
+
+$array = new ArrayObject();
+$array->offsetSet('key', 'value');
+var_dump($array->offsetExists('key'));
+var_dump($array->offsetExists('nokey'));
+
+?>
+===DONE===
+--EXPECT--
+bool(true)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/bug31185.phpt b/ext/spl/tests/bug31185.phpt
new file mode 100644
index 0000000..aa410eb
--- /dev/null
+++ b/ext/spl/tests/bug31185.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Bug #31185 (Crash when exceptions thrown from ArrayAccess::offsetUnset())
+--FILE--
+<?php
+
+class FooBar implements ArrayAccess {
+ private $array = array();
+
+ public function offsetExists($index) {
+ return isset($this->array[$index]);
+ }
+
+ public function offsetGet($index) {
+ return $this->array[$index];
+ }
+
+ public function offsetSet($index, $value) {
+ echo __METHOD__ . "($index, $value)\n";
+ $this->array[$index] = $value;
+ }
+
+ public function offsetUnset($index) {
+ throw new Exception('FAIL');
+ unset($this->array[$index]);
+ }
+
+}
+
+$i = 0; $j = 0;
+$foo = new FooBar();
+$foo[$j++] = $i++;
+$foo[$j++] = $i++;
+$foo[$j++] = $i++;
+try
+{
+ unset($foo[1]);
+}
+catch (Exception $e)
+{
+ echo "CAUGHT: " . $e->getMessage() . "\n";
+}
+
+print_R($foo);
+?>
+===DONE===
+--EXPECT--
+FooBar::offsetSet(0, 0)
+FooBar::offsetSet(1, 1)
+FooBar::offsetSet(2, 2)
+CAUGHT: FAIL
+FooBar Object
+(
+ [array:FooBar:private] => Array
+ (
+ [0] => 0
+ [1] => 1
+ [2] => 2
+ )
+
+)
+===DONE===
diff --git a/ext/spl/tests/bug31346.phpt b/ext/spl/tests/bug31346.phpt
new file mode 100644
index 0000000..9b5618e
--- /dev/null
+++ b/ext/spl/tests/bug31346.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #31486 (ArrayIterator::next segfaults)
+--FILE--
+<?php
+$obj = new stdClass;
+$obj->var1=1;
+
+$ao = new ArrayObject($obj);
+
+$i = $ao->getIterator();
+
+$ao->offsetUnset($i->key());
+$i->next();
+
+?>
+===DONE===
+--EXPECTF--
+Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sbug31346.php on line %d
+===DONE===
diff --git a/ext/spl/tests/bug31348.phpt b/ext/spl/tests/bug31348.phpt
new file mode 100644
index 0000000..047e4b2
--- /dev/null
+++ b/ext/spl/tests/bug31348.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #31348 (CachingIterator::rewind() leaks)
+--FILE--
+<?php
+$a = Array("some","blah");
+$i = new ArrayIterator($a);
+
+$ci = new CachingIterator($i);
+
+$ci->rewind();
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/ext/spl/tests/bug31926.phpt b/ext/spl/tests/bug31926.phpt
new file mode 100644
index 0000000..2d72df4
--- /dev/null
+++ b/ext/spl/tests/bug31926.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #31926 (php in free() error with RecursiveArrayIterator)
+--FILE--
+<?php
+
+$array = array(0 => array('world'));
+
+$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
+foreach($it as $key => $val) {
+ var_dump($key, $val);
+}
+
+?>
+--EXPECT--
+int(0)
+string(5) "world"
diff --git a/ext/spl/tests/bug32134.phpt b/ext/spl/tests/bug32134.phpt
new file mode 100644
index 0000000..5a880b3
--- /dev/null
+++ b/ext/spl/tests/bug32134.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Bug #32134 (Overloading offsetGet/offsetSet)
+--FILE--
+<?php
+
+class myArray extends ArrayIterator
+{
+
+ public function __construct($array = array())
+ {
+ parent::__construct($array);
+ }
+
+ public function offsetGet($index)
+ {
+ static $i = 0;
+ echo __METHOD__ . "($index)\n";
+ if (++$i > 3) exit(1);
+ return parent::offsetGet($index);
+ }
+
+ public function offsetSet($index, $newval)
+ {
+ echo __METHOD__ . "($index,$newval)\n";
+ return parent::offsetSet($index, $newval);
+ }
+
+}
+
+$myArray = new myArray();
+
+$myArray->offsetSet('one', 'one');
+var_dump($myArray->offsetGet('one'));
+
+$myArray['two'] = 'two';
+var_dump($myArray['two']);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+myArray::offsetSet(one,one)
+myArray::offsetGet(one)
+string(3) "one"
+myArray::offsetSet(two,two)
+myArray::offsetGet(two)
+string(3) "two"
+===DONE===
diff --git a/ext/spl/tests/bug32394.phpt b/ext/spl/tests/bug32394.phpt
new file mode 100644
index 0000000..8189b23
--- /dev/null
+++ b/ext/spl/tests/bug32394.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #32394 (offsetUnset() segfaults in a foreach)
+--FILE--
+<?php
+
+$object = new ArrayIterator;
+$object->append(1);
+
+foreach($object as $key => $value)
+{
+ $object->offsetUnset($key);
+}
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/ext/spl/tests/bug33136.phpt b/ext/spl/tests/bug33136.phpt
new file mode 100644
index 0000000..121ff58
--- /dev/null
+++ b/ext/spl/tests/bug33136.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Bug #33136 (method offsetSet in class extended from ArrayObject crash PHP)
+--FILE--
+<?php
+
+class Collection extends ArrayObject
+{
+ private $data;
+
+ function __construct()
+ {
+ $this->data = array();
+ parent::__construct($this->data);
+ }
+
+ function offsetGet($index)
+ {
+ echo __METHOD__ . "($index)\n";
+ return parent::offsetGet($index);
+ }
+
+ function offsetSet($index, $value)
+ {
+ echo __METHOD__ . "(" . (is_null($index) ? "NULL" : $index) . ",$value)\n";
+ parent::offsetSet($index, $value);
+ }
+}
+
+echo "\n\nInitiate Obj\n";
+$arrayObj = new Collection();
+
+echo "Assign values\n";
+
+$arrayObj[] = "foo";
+var_dump($arrayObj[0]);
+
+$arrayObj[] = "bar";
+var_dump($arrayObj[0]);
+var_dump($arrayObj[1]);
+
+$arrayObj["foo"] = "baz";
+var_dump($arrayObj["foo"]);
+
+print_r($arrayObj);
+
+var_dump(count($arrayObj));
+
+?>
+===DONE===
+<?php //exit(0); ?>
+--EXPECT--
+Initiate Obj
+Assign values
+Collection::offsetSet(NULL,foo)
+Collection::offsetGet(0)
+string(3) "foo"
+Collection::offsetSet(NULL,bar)
+Collection::offsetGet(0)
+string(3) "foo"
+Collection::offsetGet(1)
+string(3) "bar"
+Collection::offsetSet(foo,baz)
+Collection::offsetGet(foo)
+string(3) "baz"
+Collection Object
+(
+ [data:Collection:private] => Array
+ (
+ )
+
+ [storage:ArrayObject:private] => Array
+ (
+ [0] => foo
+ [1] => bar
+ [foo] => baz
+ )
+
+)
+int(3)
+===DONE===
diff --git a/ext/spl/tests/bug34548.phpt b/ext/spl/tests/bug34548.phpt
new file mode 100644
index 0000000..27c3094
--- /dev/null
+++ b/ext/spl/tests/bug34548.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #34548 (Method append() in class extended from ArrayObject crashes PHP)
+--FILE--
+<?php
+
+class Collection extends ArrayObject
+{
+ public function add($dataArray)
+ {
+ foreach($dataArray as $value) $this->append($value);
+ }
+
+ public function offsetSet($index, $value)
+ {
+ parent::offsetSet($index, $value);
+ }
+}
+
+$data1=array('one', 'two', 'three');
+$data2=array('four', 'five');
+
+$foo=new Collection($data1);
+$foo->add($data2);
+
+print_r($foo->getArrayCopy());
+
+echo "Done\n";
+?>
+--EXPECT--
+Array
+(
+ [0] => one
+ [1] => two
+ [2] => three
+ [3] => four
+ [4] => five
+)
+Done
diff --git a/ext/spl/tests/bug36258.phpt b/ext/spl/tests/bug36258.phpt
new file mode 100644
index 0000000..60817d0
--- /dev/null
+++ b/ext/spl/tests/bug36258.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #36258 (SplFileObject::getPath() may lead to segfault)
+--FILE--
+<?php
+
+$diriter = new RecursiveIteratorIterator( new RecursiveDirectoryIterator('.') );
+
+foreach ($diriter as $key => $file) {
+ var_dump($file->getFilename());
+ var_dump($file->getPath());
+ break;
+}
+
+?>
+===DONE===
+--EXPECTF--
+string(%d) "%s"
+string(%d) "%s"
+===DONE===
diff --git a/ext/spl/tests/bug36287.phpt b/ext/spl/tests/bug36287.phpt
new file mode 100644
index 0000000..0c3f287
--- /dev/null
+++ b/ext/spl/tests/bug36287.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #36287 (Segfault with SplFileInfo conversion)
+--FILE--
+<?php
+
+$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("."), true);
+
+$idx = 0;
+foreach($it as $file)
+{
+ echo "First\n";
+ var_Dump($file->getFilename());
+ echo "Second\n";
+ var_dump($file->getFilename());
+ if (++$idx > 1)
+ {
+ break;
+ }
+}
+
+?>
+===DONE===
+--EXPECTF--
+First
+string(%d) "%s"
+Second
+string(%d) "%s"
+First
+string(%d) "%s"
+Second
+string(%d) "%s"
+===DONE===
diff --git a/ext/spl/tests/bug36825.phpt b/ext/spl/tests/bug36825.phpt
new file mode 100644
index 0000000..35de013
--- /dev/null
+++ b/ext/spl/tests/bug36825.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #36825 (Exceptions thrown in ArrayObject::offsetGet cause segfault)
+--FILE--
+<?php
+
+class foo extends ArrayObject
+{
+ public function offsetGet($key)
+ {
+ echo __METHOD__ . "($key)\n";
+ throw new Exception("hi");
+ }
+}
+
+$test = new foo();
+
+try
+{
+ var_dump($test['bar']);
+}
+catch (Exception $e)
+{
+ echo "got exception\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+foo::offsetGet(bar)
+got exception
+===DONE===
diff --git a/ext/spl/tests/bug36941.phpt b/ext/spl/tests/bug36941.phpt
new file mode 100644
index 0000000..528ba4a
--- /dev/null
+++ b/ext/spl/tests/bug36941.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Bug #36941 (ArrayIterator does not clone itself)
+--FILE--
+===ArrayObject===
+<?php
+$a = new ArrayObject();
+$a[] = 1;
+
+$b = clone $a;
+
+var_dump($a[0], $b[0]);
+$b[0] = $b[0] + 1;
+var_dump($a[0], $b[0]);
+$b[0] = 3;
+var_dump($a[0], $b[0]);
+?>
+===ArrayIterator===
+<?php
+$a = new ArrayIterator();
+$a[] = 1;
+
+$b = clone $a;
+
+var_dump($a[0], $b[0]);
+$b[0] = $b[0] + 1;
+var_dump($a[0], $b[0]);
+$b[0] = 3;
+var_dump($a[0], $b[0]);
+?>
+===DONE===
+--EXPECT--
+===ArrayObject===
+int(1)
+int(1)
+int(1)
+int(2)
+int(1)
+int(3)
+===ArrayIterator===
+int(1)
+int(1)
+int(2)
+int(2)
+int(3)
+int(3)
+===DONE===
diff --git a/ext/spl/tests/bug37457.phpt b/ext/spl/tests/bug37457.phpt
new file mode 100644
index 0000000..e66fa4d
--- /dev/null
+++ b/ext/spl/tests/bug37457.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Bug #37457 (Crash when an exception is thrown in accept() method of FilterIterator)
+--FILE--
+<?php
+
+class Collection implements Iterator
+{
+ protected $array, $valid = false;
+
+ public function __construct(array $a)
+ {
+ echo __METHOD__ . "\n";
+ $this->array = $a;
+ }
+
+ public function current()
+ {
+ echo __METHOD__ . "\n";
+ return current($this->array);
+ }
+
+ public function key()
+ {
+ echo __METHOD__ . "\n";
+ return key($this->array);
+ }
+
+ public function next()
+ {
+ echo __METHOD__ . "\n";
+ $this->valid = (false !== next($this->array));
+ }
+
+ public function valid()
+ {
+ echo __METHOD__ . "\n";
+ return $this->valid;
+ }
+
+ public function rewind()
+ {
+ echo __METHOD__ . "\n";
+ $this->valid = (false !== reset($this->array));
+ }
+}
+
+class TestFilter extends FilterIterator
+{
+ public function accept()
+ {
+ echo __METHOD__ . "\n";
+ throw new Exception("Failure in Accept");
+ }
+}
+
+$test = new TestFilter(new Collection(array(0)));
+
+try
+{
+ foreach ($test as $item)
+ {
+ echo $item;
+ }
+}
+catch (Exception $e)
+{
+ var_dump($e->getMessage());
+}
+
+?>
+===DONE===
+--EXPECTF--
+Collection::__construct
+Collection::rewind
+Collection::valid
+Collection::current
+Collection::key
+TestFilter::accept
+string(17) "Failure in Accept"
+===DONE===
diff --git a/ext/spl/tests/bug38325.phpt b/ext/spl/tests/bug38325.phpt
new file mode 100644
index 0000000..ddb2829
--- /dev/null
+++ b/ext/spl/tests/bug38325.phpt
@@ -0,0 +1,9 @@
+--TEST--
+Bug #38325 (spl_autoload_register() gaves wrong line for "class not found")
+--FILE--
+<?php
+spl_autoload_register();
+new ThisClassDoesNotExistEverFoo();
+?>
+--EXPECTF--
+Fatal error: spl_autoload(): Class ThisClassDoesNotExistEverFoo could not be loaded in %s on line 3
diff --git a/ext/spl/tests/bug38618.phpt b/ext/spl/tests/bug38618.phpt
new file mode 100644
index 0000000..17439b4
--- /dev/null
+++ b/ext/spl/tests/bug38618.phpt
@@ -0,0 +1,105 @@
+--TEST--
+Bug #38618 (RecursiveArrayIterator::hasChildren() follows objects)
+--FILE--
+<?php # vim:ft=php
+
+class FruitPublic
+{
+ public $title;
+
+ public function __construct($title)
+ {
+ $this->title = $title;
+ }
+
+ public function __toString()
+ {
+ return $this->title;
+ }
+}
+
+class FruitProtected
+{
+ protected $title;
+
+ public function __construct($title)
+ {
+ $this->title = $title;
+ }
+
+ public function __toString()
+ {
+ return $this->title;
+ }
+}
+
+function test_array($array, $which, $flags = 0)
+{
+ echo "===$which===\n";
+ $it = new RecursiveArrayIterator($array, $flags);
+ foreach (new RecursiveIteratorIterator($it) as $k => $fruit) {
+ echo $k , ' => ', $fruit, "\n";
+ }
+}
+
+$array = array(
+ 1 => array(
+ 1 => array(
+ 1 => 'apple',
+ ),
+ 2 => array(
+ 1 => 'grape',
+ ),
+ ),
+);
+
+test_array($array, 'Default with array');
+
+$array = array(
+ 1 => array(
+ 1 => array(
+ 1 => new FruitPublic('apple'),
+ ),
+ 2 => array(
+ 1 => new FruitPublic('grape'),
+ ),
+ ),
+);
+
+test_array($array, 'Public Property');
+
+$array = array(
+ 1 => array(
+ 1 => array(
+ 1 => new FruitProtected('apple'),
+ ),
+ 2 => array(
+ 1 => new FruitProtected('grape'),
+ ),
+ ),
+);
+
+test_array($array, 'Protected Property');
+
+test_array($array, 'Public Property New', RecursiveArrayIterator::CHILD_ARRAYS_ONLY);
+test_array($array, 'Protected Property New', RecursiveArrayIterator::CHILD_ARRAYS_ONLY);
+?>
+===DONE===
+<?php exit(0); ?>
+?>
+===DONE===
+--EXPECTF--
+===Default with array===
+1 => apple
+1 => grape
+===Public Property===
+title => apple
+title => grape
+===Protected Property===
+===Public Property New===
+1 => apple
+1 => grape
+===Protected Property New===
+1 => apple
+1 => grape
+===DONE===
diff --git a/ext/spl/tests/bug40036.phpt b/ext/spl/tests/bug40036.phpt
new file mode 100644
index 0000000..8180c03
--- /dev/null
+++ b/ext/spl/tests/bug40036.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #40036 (empty() does not work correctly with ArrayObject when using ARRAY_AS_PROPS)
+--FILE--
+<?php
+class View extends ArrayObject
+{
+ public function __construct(array $array = array())
+ {
+ parent::__construct($array, ArrayObject::ARRAY_AS_PROPS);
+ }
+}
+
+$view = new View();
+$view->foo = false;
+$view->bar = null;
+$view->baz = '';
+if (empty($view['foo']) || empty($view->foo)) {
+ echo "View::foo empty\n";
+}
+if (empty($view['bar']) || empty($view->bar)) {
+ echo "View::bar empty\n";
+}
+if (empty($view['baz']) || empty($view->baz)) {
+ echo "View::baz empty\n";
+}
+?>
+===DONE===
+--EXPECT--
+View::foo empty
+View::bar empty
+View::baz empty
+===DONE===
diff --git a/ext/spl/tests/bug40091.phpt b/ext/spl/tests/bug40091.phpt
new file mode 100644
index 0000000..eb157e7
--- /dev/null
+++ b/ext/spl/tests/bug40091.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Bug #40091 (issue with spl_autoload_register() and 2 instances of the same class)
+--FILE--
+<?php
+class MyAutoloader {
+ function __construct($directory_to_use) {}
+ function autoload($class_name) {
+ // code to autoload based on directory
+ }
+}
+
+$autloader1 = new MyAutoloader('dir1');
+spl_autoload_register(array($autloader1, 'autoload'));
+
+$autloader2 = new MyAutoloader('dir2');
+spl_autoload_register(array($autloader2, 'autoload'));
+
+print_r(spl_autoload_functions());
+?>
+===DONE===
+--EXPECT--
+Array
+(
+ [0] => Array
+ (
+ [0] => MyAutoloader Object
+ (
+ )
+
+ [1] => autoload
+ )
+
+ [1] => Array
+ (
+ [0] => MyAutoloader Object
+ (
+ )
+
+ [1] => autoload
+ )
+
+)
+===DONE===
diff --git a/ext/spl/tests/bug40442.phpt b/ext/spl/tests/bug40442.phpt
new file mode 100644
index 0000000..fbeb22d
--- /dev/null
+++ b/ext/spl/tests/bug40442.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #40442 (ArrayObject::offsetExists broke in 5.2.1, works in 5.2.0)
+--FILE--
+<?php
+$a = new ArrayObject();
+$a->offsetSet('property', 0);
+var_dump($a->offsetExists('property'));
+?>
+===DONE===
+--EXPECT--
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/bug40872.phpt b/ext/spl/tests/bug40872.phpt
new file mode 100644
index 0000000..a48fe74
--- /dev/null
+++ b/ext/spl/tests/bug40872.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #40872 (inconsistency in offsetSet, offsetExists treatment of string enclosed integers)
+--FILE--
+<?php
+ class Project {
+ public $id;
+
+ function __construct($id) {
+ $this->id = $id;
+ }
+ }
+
+ class ProjectsList extends ArrayIterator {
+ public function add(Project $item) {
+ $this->offsetSet($item->id, $item);
+ }
+ }
+
+ $projects = new ProjectsList();
+ $projects->add(new Project('1'));
+ $projects->add(new Project(2));
+
+ var_dump($projects->offsetExists(1));
+ var_dump($projects->offsetExists('2'));
+?>
+===DONE===
+--EXPECT--
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/bug41528.phpt b/ext/spl/tests/bug41528.phpt
new file mode 100644
index 0000000..6be82c1
--- /dev/null
+++ b/ext/spl/tests/bug41528.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Bug #41528 (Classes extending ArrayObject do not serialize correctly)
+--FILE--
+<?php
+class ClassOne extends ArrayObject
+{
+ public $a = 2;
+}
+
+$classOne = new ClassOne();
+$classOne->a = 1;
+
+var_dump($classOne);
+var_dump($classOne->a);
+
+$classOne = unserialize(serialize($classOne));
+
+var_dump($classOne);
+var_dump($classOne->a);
+?>
+--EXPECT--
+object(ClassOne)#1 (2) {
+ ["a"]=>
+ int(1)
+ ["storage":"ArrayObject":private]=>
+ array(0) {
+ }
+}
+int(1)
+object(ClassOne)#2 (2) {
+ ["a"]=>
+ int(1)
+ ["storage":"ArrayObject":private]=>
+ array(0) {
+ }
+}
+int(1)
diff --git a/ext/spl/tests/bug41691.phpt b/ext/spl/tests/bug41691.phpt
new file mode 100644
index 0000000..3cf3d87
--- /dev/null
+++ b/ext/spl/tests/bug41691.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #41691 (ArrayObject::exchangeArray hangs Apache)
+--FILE--
+<?php
+
+class A extends ArrayObject {
+ public function __construct($dummy, $flags) {
+ parent::__construct($this, $flags);
+ }
+ public $a;
+ public $b;
+ public $c;
+}
+
+$a = new A(null, ArrayObject::ARRAY_AS_PROPS );
+var_dump($a->exchangeArray(array('a'=>1,'b'=>1,'c'=>1)));
+
+echo "Done\n";
+?>
+--EXPECTF--
+array(3) {
+ ["a"]=>
+ NULL
+ ["b"]=>
+ NULL
+ ["c"]=>
+ NULL
+}
+Done
diff --git a/ext/spl/tests/bug41692.phpt b/ext/spl/tests/bug41692.phpt
new file mode 100644
index 0000000..c9b7d8d
--- /dev/null
+++ b/ext/spl/tests/bug41692.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Bug #41692 (ArrayObject shows weird behaviour in respect to inheritance)
+--FILE--
+<?php
+
+class Bar extends ArrayObject {
+ private $foo = array( 1, 2, 3 );
+ function __construct()
+ {
+ parent::__construct($this->foo);
+ }
+}
+
+$foo = new Bar();
+var_dump($foo);
+$foo['foo'] = 23;
+
+$bar = new Bar();
+var_dump($bar);
+
+echo "Done\n";
+?>
+--EXPECTF--
+object(Bar)#%d (2) {
+ ["foo":"Bar":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+object(Bar)#%d (2) {
+ ["foo":"Bar":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+ ["storage":"ArrayObject":private]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ }
+}
+Done
diff --git a/ext/spl/tests/bug41828.phpt b/ext/spl/tests/bug41828.phpt
new file mode 100644
index 0000000..6053e0e
--- /dev/null
+++ b/ext/spl/tests/bug41828.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #41828 (Segfault if extended constructor of RecursiveIterator doesn't call its parent)
+--FILE--
+<?php
+class foo extends RecursiveIteratorIterator {
+
+ public function __construct($str) {
+ }
+
+ public function bar() {
+ }
+}
+
+$foo = new foo("This is bar");
+echo $foo->bar();
+
+?>
+==DONE==
+<?php exit(0); ?>
+--EXPECTF--
+Fatal error: main(): The foo instance wasn't initialized properly in %s on line %d
diff --git a/ext/spl/tests/bug42364.phpt b/ext/spl/tests/bug42364.phpt
new file mode 100644
index 0000000..971fcc5
--- /dev/null
+++ b/ext/spl/tests/bug42364.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #42364 (Crash when using getRealPath with DirectoryIterator)
+--FILE--
+<?php
+$it = new DirectoryIterator(dirname(__FILE__));
+
+$count = 0;
+
+foreach ($it as $e) {
+ $count++;
+ $type = gettype($e->getRealPath());
+ if ($type != "string" && $type != "unicode") {
+ echo $e->getFilename(), " is a ", gettype($e->getRealPath()), "\n";
+ }
+}
+
+if ($count > 0) {
+ echo "Found $count entries!\n";
+}
+?>
+===DONE===
+--EXPECTF--
+Found %i entries!
+===DONE===
diff --git a/ext/spl/tests/bug42654.phpt b/ext/spl/tests/bug42654.phpt
new file mode 100644
index 0000000..20aad74
--- /dev/null
+++ b/ext/spl/tests/bug42654.phpt
@@ -0,0 +1,158 @@
+--TEST--
+Bug #42654 (RecursiveIteratorIterator modifies only part of leaves)
+--FILE--
+<?php
+$data = array(1 => 'val1',
+ array(2 => 'val2',
+ array(3 => 'val3'),
+ ),
+ 4 => 'val4'
+ );
+
+$iterator = new RecursiveIteratorIterator(new
+RecursiveArrayIterator($data));
+foreach($iterator as $foo) {
+ $key = $iterator->key();
+ echo "update $key\n";
+ var_dump($iterator->getInnerIterator());
+ $iterator->offsetSet($key, 'alter');
+ var_dump($iterator->getInnerIterator());
+}
+$copy = $iterator->getArrayCopy();
+var_dump($copy);
+?>
+--EXPECTF--
+update 1
+object(RecursiveArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(3) {
+ [1]=>
+ string(4) "val1"
+ [2]=>
+ array(2) {
+ [2]=>
+ string(4) "val2"
+ [3]=>
+ array(1) {
+ [3]=>
+ string(4) "val3"
+ }
+ }
+ [4]=>
+ string(4) "val4"
+ }
+}
+object(RecursiveArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(3) {
+ [1]=>
+ string(5) "alter"
+ [2]=>
+ array(2) {
+ [2]=>
+ string(4) "val2"
+ [3]=>
+ array(1) {
+ [3]=>
+ string(4) "val3"
+ }
+ }
+ [4]=>
+ string(4) "val4"
+ }
+}
+update 2
+object(RecursiveArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(2) {
+ [2]=>
+ string(4) "val2"
+ [3]=>
+ array(1) {
+ [3]=>
+ string(4) "val3"
+ }
+ }
+}
+object(RecursiveArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(2) {
+ [2]=>
+ string(5) "alter"
+ [3]=>
+ array(1) {
+ [3]=>
+ string(4) "val3"
+ }
+ }
+}
+update 3
+object(RecursiveArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(1) {
+ [3]=>
+ string(4) "val3"
+ }
+}
+object(RecursiveArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(1) {
+ [3]=>
+ string(5) "alter"
+ }
+}
+update 4
+object(RecursiveArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(3) {
+ [1]=>
+ string(5) "alter"
+ [2]=>
+ array(2) {
+ [2]=>
+ string(4) "val2"
+ [3]=>
+ array(1) {
+ [3]=>
+ string(4) "val3"
+ }
+ }
+ [4]=>
+ string(4) "val4"
+ }
+}
+object(RecursiveArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(3) {
+ [1]=>
+ string(5) "alter"
+ [2]=>
+ array(2) {
+ [2]=>
+ string(4) "val2"
+ [3]=>
+ array(1) {
+ [3]=>
+ string(4) "val3"
+ }
+ }
+ [4]=>
+ string(5) "alter"
+ }
+}
+array(3) {
+ [1]=>
+ string(5) "alter"
+ [2]=>
+ array(2) {
+ [2]=>
+ string(4) "val2"
+ [3]=>
+ array(1) {
+ [3]=>
+ string(4) "val3"
+ }
+ }
+ [4]=>
+ string(5) "alter"
+}
diff --git a/ext/spl/tests/bug42703.phpt b/ext/spl/tests/bug42703.phpt
new file mode 100644
index 0000000..5c52763
--- /dev/null
+++ b/ext/spl/tests/bug42703.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Bug #42703 (Exception raised in an iterator::current() causes segfault in FilterIterator)
+--FILE--
+<?php
+class BlaIterator implements Iterator
+{
+ public function rewind() { }
+
+ public function next() { }
+
+ public function valid() {
+ return true;
+ }
+
+ public function current()
+ {
+ throw new Exception('boo');
+ }
+
+ public function key() { }
+}
+
+$it = new BlaIterator();
+$itit = new IteratorIterator($it);
+
+try {
+ foreach($itit as $key => $value) {
+ echo $key, $value;
+ }
+}
+catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+var_dump($itit->current());
+var_dump($itit->key());
+?>
+--EXPECTF--
+string(3) "boo"
+NULL
+NULL
diff --git a/ext/spl/tests/bug44144.phpt b/ext/spl/tests/bug44144.phpt
new file mode 100644
index 0000000..2933d2f
--- /dev/null
+++ b/ext/spl/tests/bug44144.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #44144 (spl_autoload_functions() should return object instance when appropriate)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+class Foo {
+ public function nonstaticMethod() {}
+}
+$foo = new Foo;
+spl_autoload_register(array($foo, 'nonstaticMethod'));
+$funcs = spl_autoload_functions();
+var_dump($funcs);
+?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ object(Foo)#%d (0) {
+ }
+ [1]=>
+ string(15) "nonstaticMethod"
+ }
+}
+
+
diff --git a/ext/spl/tests/bug44615.phpt b/ext/spl/tests/bug44615.phpt
new file mode 100644
index 0000000..1fd3d19
--- /dev/null
+++ b/ext/spl/tests/bug44615.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RecursiveArrayIterator bug 44615
+--CREDITS--
+Julien Pauli <doctorrock83@gmail.com>
+#testfest phpcampparis 2008-06-07
+--FILE--
+<?php
+$a = new stdClass();
+
+$array = array(array('z',$a),array('q','s'));
+
+$rai = new RecursiveArrayIterator($array,RecursiveArrayIterator::CHILD_ARRAYS_ONLY);
+
+foreach (new RecursiveIteratorIterator($rai) as $t) {
+ var_dump($t);
+}
+echo "Second:\n";
+$rai = new RecursiveArrayIterator($array);
+foreach (new RecursiveIteratorIterator($rai) as $t) {
+ var_dump($t);
+}
+?>
+--EXPECTF--
+string(1) "z"
+object(stdClass)#1 (0) {
+}
+string(1) "q"
+string(1) "s"
+Second:
+string(1) "z"
+string(1) "q"
+string(1) "s"
diff --git a/ext/spl/tests/bug45216.phpt b/ext/spl/tests/bug45216.phpt
new file mode 100644
index 0000000..b3c4aa5
--- /dev/null
+++ b/ext/spl/tests/bug45216.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplFileObject::fgetss (bug 45216)
+--CREDITS--
+Perrick Penet <perrick@noparking.net>
+#testfest phpcampparis 2008-06-07
+--FILE--
+<?php
+$file = dirname(__FILE__) . '/foo.html';
+file_put_contents($file, 'text 0<div class="tested">text 1</div>');
+$handle = fopen($file, 'r');
+
+$object = new SplFileObject($file);
+var_dump($object->fgetss());
+var_dump(fgetss($handle));
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__) . '/foo.html');
+?>
+--EXPECTF--
+string(12) "text 0text 1"
+string(12) "text 0text 1"
diff --git a/ext/spl/tests/bug45614.phpt b/ext/spl/tests/bug45614.phpt
new file mode 100644
index 0000000..8f99934
--- /dev/null
+++ b/ext/spl/tests/bug45614.phpt
@@ -0,0 +1,56 @@
+--TEST--
+SPL: Bug#45614 (ArrayIterator can show 1st private prop of wrapped object)
+--FILE--
+<?php
+class C {
+ private $priv1 = 'secret1';
+ private $priv2 = 'secret2';
+ public $pub1 = 'public1';
+ public $pub2 = 'public2';
+ public $pub3 = 'public3';
+}
+
+function showFirstTwoItems($it) {
+ echo str_replace("\0", '\0', $it->key()) . " => " . $it->current() .
+"\n";
+ $it->next();
+ echo str_replace("\0", '\0', $it->key()) . " => " . $it->current() .
+"\n";
+}
+
+$ao = new ArrayObject(new C);
+$ai = $ao->getIterator();
+
+echo "--> Show the first two items:\n";
+showFirstTwoItems($ai);
+
+echo "\n--> Rewind and show the first two items:\n";
+$ai->rewind();
+showFirstTwoItems($ai);
+
+echo "\n--> Invalidate current position and show the first two items:\n";
+unset($ai[$ai->key()]);
+$ai->current();
+showFirstTwoItems($ai);
+
+echo "\n--> Rewind, seek and show the first two items:\n";
+$ai->rewind();
+$ai->seek(0);
+showFirstTwoItems($ai);
+?>
+--EXPECT--
+--> Show the first two items:
+pub1 => public1
+pub2 => public2
+
+--> Rewind and show the first two items:
+pub1 => public1
+pub2 => public2
+
+--> Invalidate current position and show the first two items:
+pub1 => public1
+pub3 => public3
+
+--> Rewind, seek and show the first two items:
+pub1 => public1
+pub3 => public3
diff --git a/ext/spl/tests/bug45622.phpt b/ext/spl/tests/bug45622.phpt
new file mode 100644
index 0000000..a8fe2c4
--- /dev/null
+++ b/ext/spl/tests/bug45622.phpt
@@ -0,0 +1,51 @@
+--TEST--
+SPL: Bug #45622 (isset($arrayObject->p) misbehaves with ArrayObject::ARRAY_AS_PROPS set
+--FILE--
+<?php
+
+class C extends ArrayObject {
+ public $p = 'object property';
+}
+
+$ao = new C(array('p'=>'array element'));
+$ao->setFlags(ArrayObject::ARRAY_AS_PROPS);
+
+echo "\n--> Access the real property:\n";
+var_dump(isset($ao->p));
+var_dump($ao->p);
+
+echo "\n--> Remove the real property and access the array element:\n";
+unset($ao->p);
+var_dump(isset($ao->p));
+var_dump($ao->p);
+
+echo "\n--> Remove the array element and try access again:\n";
+unset($ao->p);
+var_dump(isset($ao->p));
+var_dump($ao->p);
+
+echo "\n--> Re-add the real property:\n";
+$ao->p = 'object property';
+var_dump(isset($ao->p));
+var_dump($ao->p);
+?>
+--EXPECTF--
+
+--> Access the real property:
+bool(true)
+%unicode|string%(15) "object property"
+
+--> Remove the real property and access the array element:
+bool(true)
+%unicode|string%(13) "array element"
+
+--> Remove the array element and try access again:
+bool(false)
+
+Notice: Undefined index: p in %s on line %d
+NULL
+
+--> Re-add the real property:
+bool(true)
+%unicode|string%(15) "object property"
+
diff --git a/ext/spl/tests/bug45622b.phpt b/ext/spl/tests/bug45622b.phpt
new file mode 100644
index 0000000..f101a84
--- /dev/null
+++ b/ext/spl/tests/bug45622b.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Ensure fix to bug45622 doesn't cause __isset() to be called when ArrayObject::ARRAY_AS_PROPS is used.
+--FILE--
+<?php
+class UsesMagic extends ArrayObject {
+ function __get($n) { echo "In " . __METHOD__ . "!\n"; }
+ function __set($n, $v) { echo "In " . __METHOD__ . "!\n"; }
+ function __isset($n) { echo "In " . __METHOD__ . "!\n"; }
+ function __unset($n) { echo "In " . __METHOD__ . "!\n"; }
+}
+$ao = new UsesMagic(array(), ArrayObject::ARRAY_AS_PROPS);
+
+echo "Doesn't trigger __get.\n";
+echo $ao->prop1;
+
+echo "Doesn't trigger __set.\n";
+$ao->prop2 = 'foo';
+
+echo "Doesn't trigger __unset.\n";
+unset($ao->prop3);
+
+echo "Shouldn't trigger __isset.\n";
+isset($ao->prop4);
+?>
+--EXPECTF--
+Doesn't trigger __get.
+
+Notice: Undefined index: prop1 in %s on line 11
+Doesn't trigger __set.
+Doesn't trigger __unset.
+
+Notice: Undefined index: prop3 in %s on line 17
+Shouldn't trigger __isset. \ No newline at end of file
diff --git a/ext/spl/tests/bug45826.phpt b/ext/spl/tests/bug45826.phpt
new file mode 100644
index 0000000..7993bfa
--- /dev/null
+++ b/ext/spl/tests/bug45826.phpt
@@ -0,0 +1,88 @@
+--TEST--
+ArrayObject/ArrayIterator : serialization
+--FILE--
+<?php
+$o = new ArrayObject();
+$y = new StdClass;
+$o->append($y);
+$o->append($y);
+$o->append($o);
+
+var_dump($o[0] === $o[1]);
+var_dump($o[2] === $o);
+
+$s1 = serialize($o);
+$s2 = $o->serialize();
+var_dump($s1);
+var_dump($s2);
+
+$o1 =unserialize($s1);
+
+var_dump($o1[0] === $o1[1]);
+var_dump($o1[2] === $o1);
+
+$o2 = new ArrayObject();
+$o2->unserialize($s2);
+
+var_dump($o2[0] === $o2[1]);
+var_dump($o2[2] !== $o2);
+var_dump($o2[2][2] === $o2[2]);
+
+echo "#### Extending ArrayObject\n";
+unset($o,$x,$s1,$s2,$o1,$o2);
+class ArrayObject2 extends ArrayObject {
+ public function serialize() {
+ return parent::serialize();
+ }
+
+ public function unserialize($s) {
+ return parent::unserialize($s);
+ }
+}
+
+$o = new ArrayObject2();
+$y = new StdClass;
+$o->append($y);
+$o->append($y);
+$o->append($o);
+
+var_dump($o[0] === $o[1]);
+var_dump($o[2] === $o);
+
+$s1 = serialize($o);
+$s2 = $o->serialize();
+var_dump($s1);
+var_dump($s2);
+
+$o1 =unserialize($s1);
+
+var_dump($o1[0] === $o1[1]);
+var_dump($o1[2] === $o1);
+
+$o2 = new ArrayObject2();
+$o2->unserialize($s2);
+
+var_dump($o2[0] === $o2[1]);
+var_dump($o2[2] !== $o2);
+var_dump($o2[2][2] === $o2[2]);
+?>
+--EXPECT--
+bool(true)
+bool(true)
+string(84) "C:11:"ArrayObject":60:{x:i:0;a:3:{i:0;O:8:"stdClass":0:{}i:1;r:4;i:2;r:1;};m:a:0:{}}"
+string(125) "x:i:0;a:3:{i:0;O:8:"stdClass":0:{}i:1;r:3;i:2;C:11:"ArrayObject":45:{x:i:0;a:3:{i:0;r:3;i:1;r:3;i:2;r:5;};m:a:0:{}}};m:a:0:{}"
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+#### Extending ArrayObject
+bool(true)
+bool(true)
+string(85) "C:12:"ArrayObject2":60:{x:i:0;a:3:{i:0;O:8:"stdClass":0:{}i:1;r:4;i:2;r:1;};m:a:0:{}}"
+string(126) "x:i:0;a:3:{i:0;O:8:"stdClass":0:{}i:1;r:3;i:2;C:12:"ArrayObject2":45:{x:i:0;a:3:{i:0;r:3;i:1;r:3;i:2;r:5;};m:a:0:{}}};m:a:0:{}"
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/spl/tests/bug46031.phpt b/ext/spl/tests/bug46031.phpt
new file mode 100644
index 0000000..9261ff0
--- /dev/null
+++ b/ext/spl/tests/bug46031.phpt
@@ -0,0 +1,9 @@
+--TEST--
+Bug #46031 (Segfault in AppendIterator::next)
+--FILE--
+<?php
+$x = new AppendIterator();
+var_dump($x->next());
+?>
+--EXPECT--
+NULL
diff --git a/ext/spl/tests/bug46051.phpt b/ext/spl/tests/bug46051.phpt
new file mode 100644
index 0000000..49a5824
--- /dev/null
+++ b/ext/spl/tests/bug46051.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #46051 (SplFileInfo::openFile - memory overlap)
+--FILE--
+<?php
+
+$x = new splfileinfo(__FILE__);
+
+try {
+$x->openFile(NULL, NULL, NULL);
+} catch (Exception $e) { }
+
+var_dump($x->getPathName());
+--EXPECTF--
+%unicode|string%(%d) "%sbug46051.php"
diff --git a/ext/spl/tests/bug46053.phpt b/ext/spl/tests/bug46053.phpt
new file mode 100644
index 0000000..75da7f3
--- /dev/null
+++ b/ext/spl/tests/bug46053.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #46053 (SplFileObject::seek - Endless loop)
+--FILE--
+<?php
+
+$x = new splfileobject(__FILE__);
+$x->getPathName();
+$x->seek(10);
+$x->seek(0);
+var_dump(trim($x->fgets()));
+--EXPECTF--
+string(%d) "<?php"
diff --git a/ext/spl/tests/bug46088.phpt b/ext/spl/tests/bug46088.phpt
new file mode 100644
index 0000000..4785377
--- /dev/null
+++ b/ext/spl/tests/bug46088.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #46088 (RegexIterator::accept - segfault)
+--FILE--
+<?php
+
+$x = new RegexIterator(new ArrayIterator(range(1, 10)), '/\d/');
+var_dump($x->accept());
+
+?>
+--EXPECT--
+bool(false)
diff --git a/ext/spl/tests/bug46115.phpt b/ext/spl/tests/bug46115.phpt
new file mode 100644
index 0000000..71207d8
--- /dev/null
+++ b/ext/spl/tests/bug46115.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #46115 (Memory leak when calling a method using Reflection)
+--FILE--
+<?php
+$h = new RecursiveArrayIterator(array());
+$x = new reflectionmethod('RecursiveArrayIterator', 'asort');
+$z = $x->invoke($h);
+?>
+DONE
+--EXPECT--
+DONE
diff --git a/ext/spl/tests/bug46160.phpt b/ext/spl/tests/bug46160.phpt
new file mode 100644
index 0000000..e4dbdff
--- /dev/null
+++ b/ext/spl/tests/bug46160.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #46160 (SPL - Memory leak when exception is throwed in offsetSet method)
+--FILE--
+<?php
+
+try {
+ $x = new splqueue;
+ $x->offsetSet(0, 0);
+} catch (Exception $e) { }
+
+?>
+DONE
+--EXPECT--
+DONE
diff --git a/ext/spl/tests/bug47534.phpt b/ext/spl/tests/bug47534.phpt
new file mode 100644
index 0000000..d221c23
--- /dev/null
+++ b/ext/spl/tests/bug47534.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SPL: RecursiveDirectoryIterator bug 47534
+--FILE--
+<?php
+$it1 = new RecursiveDirectoryIterator(dirname(__FILE__), FileSystemIterator::CURRENT_AS_PATHNAME);
+$it1->rewind();
+echo gettype($it1->current())."\n";
+
+$it2 = new RecursiveDirectoryIterator(dirname(__FILE__));
+$it2->rewind();
+echo gettype($it2->current())."\n";
+--EXPECT--
+string
+object
diff --git a/ext/spl/tests/bug48023.phpt b/ext/spl/tests/bug48023.phpt
new file mode 100644
index 0000000..ed0ff9e
--- /dev/null
+++ b/ext/spl/tests/bug48023.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #48023 (spl_autoload_register didn't addref closures)
+--FILE--
+<?php
+spl_autoload_register(function(){});
+
+new Foo;
+
+?>
+===DONE===
+--EXPECTF--
+Fatal error: Class 'Foo' not found in %s on line %d
diff --git a/ext/spl/tests/bug48361.phpt b/ext/spl/tests/bug48361.phpt
new file mode 100644
index 0000000..44b05ab
--- /dev/null
+++ b/ext/spl/tests/bug48361.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SPL: Bug #48361 SpleFileInfo::getPathName should return the dirname's path
+--FILE--
+<?php
+$info = new SplFileInfo(__FILE__);
+var_dump($info->getRealPath());
+var_dump($info->getPathInfo()->getRealPath());
+?>
+===DONE===
+--EXPECTF--
+string(%d) "%stests%sbug48361.php"
+string(%d) "%stests"
+===DONE===
+
diff --git a/ext/spl/tests/bug48493.phpt b/ext/spl/tests/bug48493.phpt
new file mode 100644
index 0000000..d0be7f8
--- /dev/null
+++ b/ext/spl/tests/bug48493.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SPL: Bug #48493 spl_autoload_unregister() can't handle prepended functions
+--FILE--
+<?php
+function autoload1() {}
+
+function autoload2() {}
+
+spl_autoload_register('autoload2');
+spl_autoload_register('autoload1', true, true);
+var_dump(spl_autoload_functions());
+
+spl_autoload_unregister('autoload2');
+var_dump(spl_autoload_functions());
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(9) "autoload1"
+ [1]=>
+ string(9) "autoload2"
+}
+array(1) {
+ [0]=>
+ string(9) "autoload1"
+}
diff --git a/ext/spl/tests/bug49263.phpt b/ext/spl/tests/bug49263.phpt
new file mode 100644
index 0000000..2075577
--- /dev/null
+++ b/ext/spl/tests/bug49263.phpt
@@ -0,0 +1,54 @@
+--TEST--
+SPL: SplObjectStorage serialization references
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+$o1 = new stdClass;
+$o2 = new stdClass;
+
+$s = new splObjectStorage();
+
+$s->attach($o1, array('prev' => 2, 'next' => $o2));
+$s->attach($o2, array('prev' => $o1));
+
+$ss = serialize($s);
+unset($s,$o1,$o2);
+echo $ss."\n";
+var_dump(unserialize($ss));
+?>
+===DONE===
+--EXPECTF--
+C:16:"SplObjectStorage":113:{x:i:2;O:8:"stdClass":0:{},a:2:{s:4:"prev";i:2;s:4:"next";O:8:"stdClass":0:{}};r:6;,a:1:{s:4:"prev";r:3;};m:a:0:{}}
+object(SplObjectStorage)#2 (1) {
+ ["storage":"SplObjectStorage":private]=>
+ array(2) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(stdClass)#1 (0) {
+ }
+ ["inf"]=>
+ array(2) {
+ ["prev"]=>
+ int(2)
+ ["next"]=>
+ object(stdClass)#3 (0) {
+ }
+ }
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(stdClass)#3 (0) {
+ }
+ ["inf"]=>
+ array(1) {
+ ["prev"]=>
+ object(stdClass)#1 (0) {
+ }
+ }
+ }
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/bug49723.phpt b/ext/spl/tests/bug49723.phpt
new file mode 100644
index 0000000..221e806
--- /dev/null
+++ b/ext/spl/tests/bug49723.phpt
@@ -0,0 +1,16 @@
+--TEST--
+LimitIterator: do not seek if not needed
+--FILE--
+<?php
+
+$it = new ArrayIterator(array());
+
+$lit = new LimitIterator($it, 0, 5);
+
+foreach ($lit as $v) {
+ echo $v;
+}
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/ext/spl/tests/bug49972.phpt b/ext/spl/tests/bug49972.phpt
new file mode 100644
index 0000000..843c251
--- /dev/null
+++ b/ext/spl/tests/bug49972.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #49972 (AppendIterator undefined function crash)
+--FILE--
+<?php
+
+$iterator = new AppendIterator();
+$iterator->undefined();
+
+?>
+--EXPECTF--
+Fatal error: Call to undefined method AppendIterator::undefined() in %s on line %d
diff --git a/ext/spl/tests/bug50579.phpt b/ext/spl/tests/bug50579.phpt
new file mode 100644
index 0000000..e32262a
--- /dev/null
+++ b/ext/spl/tests/bug50579.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #50579 (RegexIterator::REPLACE doesn't work)
+--FILE--
+<?php
+
+class foo extends ArrayIterator {
+ public function __construct( ) {
+ parent::__construct(array(
+ 'test1'=>'test888',
+ 'test2'=>'what?',
+ 'test3'=>'test999'));
+ }
+}
+$h = new foo;
+$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE);
+$i->replacement = '[$0]';
+foreach ($i as $name=>$value) {
+ echo $name . '=>' . $value . "\n";
+}
+
+$i->replacement = '$1';
+foreach ($i as $name=>$value) {
+ echo $name . '=>' . $value . "\n";
+}
+
+$h = new foo;
+$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE);
+$i->replacement = '[$1]';
+foreach ($i as $name=>$value) {
+ echo $name . '=>' . $value . "\n";
+}
+
+?>
+--EXPECTF--
+test1=>[test888]
+test3=>[test999]
+test1=>888
+test3=>999
+test1=>[888]
+test3=>[999]
diff --git a/ext/spl/tests/bug51119.phpt b/ext/spl/tests/bug51119.phpt
new file mode 100644
index 0000000..441aa12
--- /dev/null
+++ b/ext/spl/tests/bug51119.phpt
@@ -0,0 +1,34 @@
+--TEST--
+SPL: LimitIterator zero is valid offset
+--FILE--
+<?php
+
+$array = array('a', 'b', 'c');
+$arrayIterator = new ArrayIterator($array);
+
+try {
+ $limitIterator = new LimitIterator($arrayIterator, 0);
+ foreach ($limitIterator as $item) {
+ echo $item . "\n";
+ }
+} catch (OutOfRangeException $e){
+ print $e->getMessage() . "\n";
+}
+
+try {
+ $limitIterator = new LimitIterator($arrayIterator, -1);
+ foreach ($limitIterator as $item) {
+ echo $item . "\n";
+ }
+} catch (OutOfRangeException $e){
+ print $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+a
+b
+c
+Parameter offset must be >= 0
+===DONE===
diff --git a/ext/spl/tests/bug51374.phpt b/ext/spl/tests/bug51374.phpt
new file mode 100644
index 0000000..a4d2853
--- /dev/null
+++ b/ext/spl/tests/bug51374.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: SplFileObject wrongly initializes objects
+--FILE--
+<?php
+class Foo extends SplFileObject
+{
+ public $bam = array();
+}
+$fileInfo = new SplFileInfo('php://temp');
+$fileInfo->setFileClass('Foo');
+$file = $fileInfo->openFile('r');
+
+print var_dump($file->bam); // is null or UNKNOWN:0
+?>
+===DONE===
+--EXPECT--
+array(0) {
+}
+===DONE===
diff --git a/ext/spl/tests/bug51532.phpt b/ext/spl/tests/bug51532.phpt
new file mode 100644
index 0000000..3a0722b
--- /dev/null
+++ b/ext/spl/tests/bug51532.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SPL: Allow valid extension of SplFileObject::fscanf
+--FILE--
+<?php
+
+class A extends SplFileObject {
+ public function fscanf($format) {
+
+ }
+}
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/ext/spl/tests/bug52238.phpt b/ext/spl/tests/bug52238.phpt
new file mode 100644
index 0000000..10da0b5
--- /dev/null
+++ b/ext/spl/tests/bug52238.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #52238 - Crash when an Exception occurred in iterator_to_array
+--FILE--
+<?php
+class Foo implements IteratorAggregate
+{
+ public function bar() {
+ throw new Exception;
+ }
+
+ public function getIterator() {
+ return new ArrayIterator($this->bar());
+ }
+}
+var_dump(iterator_to_array(new Foo));
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 %s: Foo->bar()
+#1 [internal function]: Foo->getIterator()
+#2 %s: iterator_to_array(Object(Foo))
+#3 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/bug52573.phpt b/ext/spl/tests/bug52573.phpt
new file mode 100644
index 0000000..54587fa
--- /dev/null
+++ b/ext/spl/tests/bug52573.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #52573 (SplFileObject::fscanf Segmentation fault)
+--FILE--
+<?php // test
+
+$result = null;
+$f = new SplFileObject(__FILE__, 'r');
+var_dump($f->fscanf('<?php // %s', $result));
+var_dump($result);
+var_dump($f->fscanf('<?php // %s'));
+?>
+--EXPECTF--
+int(1)
+string(4) "test"
+array(1) {
+ [0]=>
+ NULL
+}
diff --git a/ext/spl/tests/bug52861.phpt b/ext/spl/tests/bug52861.phpt
new file mode 100644
index 0000000..30a3261
--- /dev/null
+++ b/ext/spl/tests/bug52861.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #52861 (unset failes with ArrayObject and deep arrays)
+--FILE--
+<?php
+$arrayObject = new ArrayObject(array('foo' => array('bar' => array('baz' => 'boo'))));
+
+unset($arrayObject['foo']['bar']['baz']);
+print_r($arrayObject->getArrayCopy());
+?>
+--EXPECT--
+Array
+(
+ [foo] => Array
+ (
+ [bar] => Array
+ (
+ )
+
+ )
+
+)
+
diff --git a/ext/spl/tests/bug53071.phpt b/ext/spl/tests/bug53071.phpt
new file mode 100644
index 0000000..c2c2605
--- /dev/null
+++ b/ext/spl/tests/bug53071.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #53071 (Usage of SPLObjectStorage defeats gc_collect_cycles)
+--FILE--
+<?php
+gc_enable();
+class myClass
+{
+ public $member;
+}
+function LimitedScope()
+{
+ $myA = new myClass();
+ $myB = new SplObjectStorage();
+ $myC = new myClass();
+ $myC->member = $myA; // myC has a referece to myA
+ $myB->Attach($myC); // myB attaches myC
+ $myA->member = $myB; // myA has myB, comleting the cycle
+}
+LimitedScope();
+var_dump(gc_collect_cycles());
+
+echo "Done.\n";
+
+?>
+--EXPECTF--
+int(5)
+Done.
diff --git a/ext/spl/tests/bug53144.phpt b/ext/spl/tests/bug53144.phpt
new file mode 100644
index 0000000..7cf179b
--- /dev/null
+++ b/ext/spl/tests/bug53144.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #53144 (Segfault in SplObjectStorage::removeAll)
+--FILE--
+<?php
+
+$o1 = new StdClass;
+$o2 = new StdClass;
+
+$b = new SplObjectStorage();
+$b[$o1] = "bar";
+$b[$o2] = "baz";
+
+var_dump(count($b));
+$b->removeAll($b);
+var_dump(count($b));
+
+?>
+--EXPECTF--
+int(2)
+int(0) \ No newline at end of file
diff --git a/ext/spl/tests/bug53362.phpt b/ext/spl/tests/bug53362.phpt
new file mode 100644
index 0000000..70ba6e2
--- /dev/null
+++ b/ext/spl/tests/bug53362.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #53362 (Segmentation fault when extending SplFixedArray)
+--FILE--
+<?php
+
+class obj extends SplFixedArray{
+ public function offsetSet($offset, $value) {
+ var_dump($offset);
+ }
+}
+
+$obj = new obj;
+
+$obj[]=2;
+$obj[]=2;
+$obj[]=2;
+
+?>
+--EXPECTF--
+NULL
+NULL
+NULL
diff --git a/ext/spl/tests/bug53515.phpt b/ext/spl/tests/bug53515.phpt
new file mode 100644
index 0000000..8ecb02b
--- /dev/null
+++ b/ext/spl/tests/bug53515.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #53515 (property_exists incorrect on ArrayObject null and 0 values)
+--FILE--
+<?php
+
+$a = array('a' => 1, 'b'=> true, 'c' => 0, 'd' => null, 'e' => false, 'f' => array());
+$o = new ArrayObject($a, ArrayObject::ARRAY_AS_PROPS);
+
+$a['z'] = '';
+$a[''] = '';
+
+foreach ($a as $key => $value) {
+ echo $key . ': ' . (is_null($value) ? 'null' : @"$value") .
+ ' array_key_exists: ' . (array_key_exists($key, $a) ? 'true' : 'false') .
+ ' property_exists: ' . (property_exists($o, $key) ? 'true' : 'false'),"\n";
+}
+
+?>
+--EXPECT--
+a: 1 array_key_exists: true property_exists: true
+b: 1 array_key_exists: true property_exists: true
+c: 0 array_key_exists: true property_exists: true
+d: null array_key_exists: true property_exists: true
+e: array_key_exists: true property_exists: true
+f: Array array_key_exists: true property_exists: true
+z: array_key_exists: true property_exists: false
+: array_key_exists: true property_exists: false
diff --git a/ext/spl/tests/bug54281.phpt b/ext/spl/tests/bug54281.phpt
new file mode 100644
index 0000000..d42d9e5
--- /dev/null
+++ b/ext/spl/tests/bug54281.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #54281 (Crash in spl_recursive_it_rewind_ex)
+--FILE--
+<?php
+
+class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator {
+ function __construct($it, $max_depth) { }
+}
+$it = new RecursiveArrayIteratorIterator(new RecursiveArrayIterator(array()), 2);
+
+foreach($it as $k=>$v) { }
+
+?>
+--EXPECTF--
+Fatal error: RecursiveIteratorIterator::rewind(): The RecursiveArrayIteratorIterator instance wasn't initialized properly in %s on line %d
diff --git a/ext/spl/tests/bug54291.phpt b/ext/spl/tests/bug54291.phpt
new file mode 100644
index 0000000..b8f596e
--- /dev/null
+++ b/ext/spl/tests/bug54291.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #54291 (Crash iterating DirectoryIterator for dir name starting with \0)
+--FILE--
+<?php
+$dir = new DirectoryIterator("\x00/abc");
+$dir->isFile();
+--EXPECTF--
+Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Failed to open directory ""' in %s:%d
+Stack trace:
+#0 %s(%d): DirectoryIterator->__construct('?/abc')
+#1 {main}
+ thrown in %s on line %d
+
diff --git a/ext/spl/tests/bug54292.phpt b/ext/spl/tests/bug54292.phpt
new file mode 100644
index 0000000..d9175f7
--- /dev/null
+++ b/ext/spl/tests/bug54292.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #54292 (Wrong parameter causes crash in SplFileObject::__construct())
+--FILE--
+<?php
+
+try {
+ new SplFileObject('foo', array());
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+string(74) "SplFileObject::__construct() expects parameter 2 to be string, array given"
diff --git a/ext/spl/tests/bug54304.phpt b/ext/spl/tests/bug54304.phpt
new file mode 100644
index 0000000..32cbe48
--- /dev/null
+++ b/ext/spl/tests/bug54304.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #54304 (Setting replacement value for RegexIterator doesn't work)
+--FILE--
+<?php
+class foo extends ArrayIterator {
+ public function __construct( ) {
+ parent::__construct(array(
+ 'test3'=>'test999'));
+ }
+}
+
+$h = new foo;
+$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE);
+$i->replacement = 42;
+var_dump($i->replacement);
+foreach ($i as $name=>$value) {
+ var_dump($name, $value);
+}
+var_dump($i->replacement);
+?>
+--EXPECT--
+int(42)
+string(5) "test3"
+string(2) "42"
+int(42)
+
diff --git a/ext/spl/tests/bug54323.phpt b/ext/spl/tests/bug54323.phpt
new file mode 100644
index 0000000..df6416a
--- /dev/null
+++ b/ext/spl/tests/bug54323.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #54323 (Accessing unset()'ed ArrayObject's property causes crash)
+--FILE--
+<?php
+class C {
+ public $prop = 'C::prop.orig';
+}
+class MyArrayObject extends ArrayObject {
+}
+$c = new C;
+$ao = new MyArrayObject($c);
+testAccess($c, $ao);
+function testAccess($c, $ao) {
+ foreach ($ao as $key=>$value) {
+ }
+ unset($ao['prop']);
+ var_dump($c->prop, $ao['prop']);
+}
+--EXPECTF--
+Notice: Undefined property: C::$prop in %sbug54323.php on line 14
+
+Notice: Undefined index: prop in %sbug54323.php on line 14
+NULL
+NULL
diff --git a/ext/spl/tests/bug54384.phpt b/ext/spl/tests/bug54384.phpt
new file mode 100644
index 0000000..a1ce7ed
--- /dev/null
+++ b/ext/spl/tests/bug54384.phpt
@@ -0,0 +1,171 @@
+--TEST--
+Bug #54384: Several SPL classes crash when the parent constructor is not called
+--FILE--
+<?php
+
+function test($f) {
+ try {
+ $f();
+ echo "ran normally (unexpected)\n\n";
+ } catch (LogicException $e) {
+ echo "exception (expected)\n";
+ }
+}
+
+echo "IteratorIterator... ";
+class IteratorIteratorTest extends IteratorIterator {
+ function __construct(){}
+}
+test( function() {
+ $o = new IteratorIteratorTest;
+ $o->rewind();
+} );
+
+echo "FilterIterator... ";
+class FilterIteratorTest extends FilterIterator {
+ function __construct(){}
+ function accept(){}
+}
+test( function() {
+ $o = new FilterIteratorTest;
+ $o->rewind();
+} );
+
+echo "RecursiveFilterIterator... ";
+class RecursiveFilterIteratorTest extends RecursiveFilterIterator {
+ function __construct(){}
+ function accept(){}
+}
+test( function() {
+$o = new RecursiveFilterIteratorTest;
+$o->hasChildren();
+} );
+
+echo "ParentIterator... ";
+class ParentIteratorTest extends ParentIterator {
+ function __construct(){}
+}
+test ( function() {
+$o = new ParentIteratorTest;
+$o->accept();
+} );
+
+echo "LimitIterator... ";
+class LimitIteratorTest extends LimitIterator {
+ function __construct(){}
+}
+test ( function() {
+$o = new LimitIteratorTest;
+$o->rewind();
+} );
+
+echo "CachingIterator... ";
+class CachingIteratorTest extends CachingIterator {
+ function __construct(){}
+}
+test ( function() {
+$o = new CachingIteratorTest;
+$o->rewind();
+} );
+
+echo "RecursiveCachingIterator... ";
+class RecursiveCachingIteratorTest extends RecursiveCachingIterator {
+ function __construct(){}
+}
+test ( function() {
+$o = new RecursiveCachingIteratorTest;
+$o->rewind();
+} );
+
+echo "NoRewindIterator... ";
+class NoRewindIteratorTest extends NoRewindIterator {
+ function __construct(){}
+}
+test ( function() {
+$o = new NoRewindIteratorTest;
+$o->valid();
+} );
+
+echo "RegexIterator... ";
+class RegexIteratorTest extends RegexIterator {
+ function __construct(){}
+}
+test ( function() {
+$o = new RegexIteratorTest;
+$o->rewind();
+} );
+
+echo "RecursiveRegexIterator... ";
+class RecursiveRegexIteratorTest extends RecursiveRegexIterator {
+ function __construct(){}
+}
+test ( function() {
+$o = new RecursiveRegexIteratorTest;
+$o->hasChildren();
+} );
+
+echo "GlobIterator... ";
+class GlobIteratorTest extends GlobIterator {
+ function __construct(){}
+}
+test ( function() {
+$o = new GlobIteratorTest;
+$o->count();
+} );
+
+echo "SplFileObject... ";
+class SplFileObjectTest extends SplFileObject {
+ function __construct(){}
+}
+test ( function() {
+$o = new SplFileObjectTest;
+$o->rewind();
+} );
+
+echo "SplTempFileObject... ";
+class SplTempFileObjectTest extends SplTempFileObject {
+ function __construct(){}
+}
+test ( function() {
+$o = new SplTempFileObjectTest;
+$o->rewind();
+} );
+
+echo "AppendIterator... ";
+class AppendIteratorTest extends AppendIterator {
+ function __construct(){}
+}
+test ( function() {
+$o = new AppendIteratorTest;
+foreach ($o as $a) {
+echo $a,"\n";
+}
+} );
+
+echo "InfiniteIterator... ";
+class InfiniteIteratorTest extends InfiniteIterator {
+ function __construct(){}
+}
+test ( function() {
+$o = new InfiniteIteratorTest;
+foreach ($o as $a) {
+echo $a,"\n";
+}
+} );
+
+--EXPECT--
+IteratorIterator... exception (expected)
+FilterIterator... exception (expected)
+RecursiveFilterIterator... exception (expected)
+ParentIterator... exception (expected)
+LimitIterator... exception (expected)
+CachingIterator... exception (expected)
+RecursiveCachingIterator... exception (expected)
+NoRewindIterator... exception (expected)
+RegexIterator... exception (expected)
+RecursiveRegexIterator... exception (expected)
+GlobIterator... exception (expected)
+SplFileObject... exception (expected)
+SplTempFileObject... exception (expected)
+AppendIterator... exception (expected)
+InfiniteIterator... exception (expected)
diff --git a/ext/spl/tests/bug54970.phpt b/ext/spl/tests/bug54970.phpt
new file mode 100644
index 0000000..62b1eed
--- /dev/null
+++ b/ext/spl/tests/bug54970.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Bug #54970 (SplFixedArray::setSize() isn't resizing)
+--FILE--
+<?php
+
+$fa = new SplFixedArray(2);
+$fa[0] = 'Hello';
+$fa[1] = 'World';
+$fa->setSize(3);
+$fa[2] = '!';
+var_dump($fa);
+$fa->setSize(2);
+var_dump($fa);
+var_dump($fa->getSize());
+
+
+?>
+--EXPECTF--
+object(SplFixedArray)#%d (3) {
+ [0]=>
+ string(5) "Hello"
+ [1]=>
+ string(5) "World"
+ [2]=>
+ string(1) "!"
+}
+object(SplFixedArray)#%d (2) {
+ [0]=>
+ string(5) "Hello"
+ [1]=>
+ string(5) "World"
+}
+int(2)
diff --git a/ext/spl/tests/bug54971.phpt b/ext/spl/tests/bug54971.phpt
new file mode 100644
index 0000000..22cdfba
--- /dev/null
+++ b/ext/spl/tests/bug54971.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Bug #54971 (Wrong result when using iterator_to_array with use_keys on true)
+--SKIPIF--
+<?php
+if (!extension_loaded('dom')) die("skip this test needs --enable-dom");
+?>
+--FILE--
+<?php
+
+$source = <<<XML
+<root>
+<node>val1</node>
+<node>val2</node>
+</root>
+XML;
+
+
+$doc = new DOMDocument();
+$doc->loadXML($source);
+
+$xpath = new DOMXPath($doc);
+$items = $xpath->query('//node');
+
+print_r(array_map('get_class', iterator_to_array($items, false)));
+print_r(array_map('get_class', iterator_to_array($items, true)));
+?>
+--EXPECT--
+Array
+(
+ [0] => DOMElement
+ [1] => DOMElement
+)
+Array
+(
+ [0] => DOMElement
+ [1] => DOMElement
+)
diff --git a/ext/spl/tests/bug60201.phpt b/ext/spl/tests/bug60201.phpt
new file mode 100644
index 0000000..68a5daa
--- /dev/null
+++ b/ext/spl/tests/bug60201.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #60201 (SplFileObject::setCsvControl does not expose third argument via Reflection)
+--FILE--
+<?php
+
+$method = new ReflectionMethod('SplFileObject', 'setCsvControl');
+$params = $method->getParameters();
+var_dump($params);
+
+?>
+===DONE===
+--EXPECTF--
+array(3) {
+ [0]=>
+ &object(ReflectionParameter)#%d (1) {
+ ["name"]=>
+ string(9) "delimiter"
+ }
+ [1]=>
+ &object(ReflectionParameter)#%d (1) {
+ ["name"]=>
+ string(9) "enclosure"
+ }
+ [2]=>
+ &object(ReflectionParameter)#%d (1) {
+ ["name"]=>
+ string(6) "escape"
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/bug61326.phpt b/ext/spl/tests/bug61326.phpt
new file mode 100644
index 0000000..85b5779
--- /dev/null
+++ b/ext/spl/tests/bug61326.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #61326: ArrayObject comparison
+--FILE--
+<?php
+$aobj1 = new ArrayObject(array(0));
+$aobj2 = new ArrayObject(array(1));
+var_dump($aobj1 == $aobj2);
+
+$aobj3 = new ArrayObject(array(0));
+var_dump($aobj1 == $aobj3);
+
+$aobj3->foo = 'bar';
+var_dump($aobj1 == $aobj3);
+--EXPECT--
+bool(false)
+bool(true)
+bool(false)
diff --git a/ext/spl/tests/bug61347.phpt b/ext/spl/tests/bug61347.phpt
new file mode 100644
index 0000000..cb09185
--- /dev/null
+++ b/ext/spl/tests/bug61347.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #61347 (inconsist isset behavior of Arrayobject)
+--FILE--
+<?php
+$a = array('b' => NULL, 37 => NULL);
+var_dump(isset($a['b'])); //false
+
+$b = new ArrayObject($a);
+var_dump(isset($b['b'])); //false
+var_dump(isset($b[37])); //false
+var_dump(isset($b['no_exists'])); //false
+var_dump(empty($b['b'])); //true
+var_dump(empty($b[37])); //true
+
+var_dump(array_key_exists('b', $b)); //true
+var_dump($b['b']);
+
+$a = array('b' => '', 37 => false);
+$b = new ArrayObject($a);
+var_dump(isset($b['b'])); //true
+var_dump(isset($b[37])); //true
+var_dump(isset($b['no_exists'])); //false
+var_dump(empty($b['b'])); //true
+var_dump(empty($b[37])); //true
+
+
+--EXPECT--
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+NULL
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
diff --git a/ext/spl/tests/bug61418.phpt b/ext/spl/tests/bug61418.phpt
new file mode 100644
index 0000000..c5d9db9
--- /dev/null
+++ b/ext/spl/tests/bug61418.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #61418: Segmentation fault using FiltesystemIterator & RegexIterator
+--FILE--
+<?php
+$fileIterator = new FilesystemIterator(__DIR__, FilesystemIterator::KEY_AS_FILENAME);
+$regexpIterator = new RegexIterator($fileIterator, '#.*#');
+foreach ($fileIterator as $key => $file)
+{
+}
+unset($regexpIterator);
+unset($fileIterator);
+
+$dirIterator = new DirectoryIterator(__DIR__);
+$regexpIterator2 = new RegexIterator($dirIterator, '#.*#');
+foreach ($dirIterator as $key => $file)
+{
+}
+unset($regexpIterator2);
+unset($dirIterator);
+?>
+==DONE==
+--EXPECT--
+==DONE==
diff --git a/ext/spl/tests/bug61453.phpt b/ext/spl/tests/bug61453.phpt
new file mode 100644
index 0000000..e5b1387
--- /dev/null
+++ b/ext/spl/tests/bug61453.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #61453: SplObjectStorage does not identify objects correctly
+--FILE--
+<?php
+$limit = 1000;
+$objects = new SplObjectStorage;
+for($i = 0; $i < $limit; $i++){
+ $object = new StdClass;
+
+ if(isset($objects[$object])){
+ die("this should never happen, but did after $i iteration");
+ }
+
+ $objects[$object] = 1;
+}
+?>
+==DONE==
+--EXPECT--
+==DONE==
diff --git a/ext/spl/tests/bug61527.phpt b/ext/spl/tests/bug61527.phpt
new file mode 100644
index 0000000..ab13c69
--- /dev/null
+++ b/ext/spl/tests/bug61527.phpt
@@ -0,0 +1,92 @@
+--TEST--
+Bug #61527 (Recursive/ArrayIterator gives misleading notice when array empty or moved to the end)
+--FILE--
+<?php
+$ao = new ArrayObject(array());
+$ai = $ao->getIterator();
+
+/* testing empty array, should no notice at all */
+$ai->next();
+var_dump($ai->key());
+var_dump($ai->current());
+
+/* testing array changing */
+$ao2 = new ArrayObject(array(1 => 1, 2, 3, 4, 5));
+$ai2 = $ao2->getIterator();
+
+$ao2->offsetUnset($ai2->key());
+$ai2->next();
+
+/* now point to 2 */
+$ao2->offsetUnset($ai2->key());
+var_dump($ai2->key());
+
+/* now point to 3 */
+$ao2->offsetUnset($ai2->key());
+var_dump($ai2->current());
+
+$ai2->next();
+var_dump($ai2->key());
+var_dump($ai2->current());
+
+/* should be at the end and no notice */
+$ai2->next();
+var_dump($ai2->key());
+var_dump($ai2->current());
+
+$ai2->rewind();
+$ai2->next();
+$ai2->next();
+/* should reached the end */
+var_dump($ai2->next());
+var_dump($ai2->key());
+
+/* testing RecursiveArrayIterator */
+$ao3 = new ArrayObject(array(), NULL, 'RecursiveArrayIterator');
+$ai3 = $ao3->getIterator();
+
+var_dump($ai3->getChildren());
+
+$ao4 = new ArrayObject(array(1, 2), NULL, 'RecursiveArrayIterator');
+$ai4 = $ao4->getIterator();
+
+$ai4->next();
+$ai4->next();
+$ai4->next();
+var_dump($ai4->hasChildren());
+
+$ai4->rewind();
+$ao4->offsetUnset($ai4->key());
+var_dump($ai4->hasChildren());
+
+$ao4->offsetUnset($ai4->key());
+var_dump($ai4->getChildren());
+?>
+==DONE==
+<?php exit(0); ?>
+--EXPECTF--
+NULL
+NULL
+
+Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d
+
+Notice: ArrayIterator::key(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d
+NULL
+
+Notice: ArrayIterator::current(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d
+NULL
+int(5)
+int(5)
+NULL
+NULL
+NULL
+NULL
+NULL
+bool(false)
+
+Notice: RecursiveArrayIterator::hasChildren(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d
+bool(false)
+
+Notice: RecursiveArrayIterator::getChildren(): Array was modified outside object and internal position is no longer valid in %sbug61527.php on line %d
+NULL
+==DONE==
diff --git a/ext/spl/tests/bug62073.phpt b/ext/spl/tests/bug62073.phpt
new file mode 100644
index 0000000..3bd3553
--- /dev/null
+++ b/ext/spl/tests/bug62073.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #62073 (different ways of iterating over an SplMaxHeap result in different keys)
+--FILE--
+<?php
+$heap = new SplMaxHeap();
+$heap->insert(42);
+foreach ($heap as $key => $value) {
+ var_dump($key);
+ var_dump($value);
+ break;
+}
+
+$heap = new SplMaxHeap();
+$heap->insert(42);
+var_dump($heap->key());
+var_dump($heap->current());
+?>
+--EXPECT--
+int(0)
+int(42)
+int(0)
+int(42)
diff --git a/ext/spl/tests/bug62262.phpt b/ext/spl/tests/bug62262.phpt
new file mode 100644
index 0000000..0e006ec
--- /dev/null
+++ b/ext/spl/tests/bug62262.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #62262: RecursiveArrayIterator does not implement Countable
+--FILE--
+<?php
+
+var_dump(new RecursiveArrayIterator(array()) instanceof Countable);
+
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/spl/tests/bug62328.phpt b/ext/spl/tests/bug62328.phpt
new file mode 100644
index 0000000..33a8aee
--- /dev/null
+++ b/ext/spl/tests/bug62328.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #62328 (cast_object takes precedence over __toString)
+--CREDITS--
+leight at gmail dot com
+--FILE--
+<?php
+
+class SplFileInfo62328 extends SplFileInfo
+{
+ public function __toString()
+ {
+ return '__toString';
+ }
+}
+
+$fi = new SplFileInfo62328(__FILE__);
+
+echo (string)$fi . PHP_EOL;
+echo (string)$fi->__toString() . PHP_EOL;
+
+?>
+--EXPECT--
+__toString
+__toString
diff --git a/ext/spl/tests/bug62433.phpt b/ext/spl/tests/bug62433.phpt
new file mode 100644
index 0000000..bfb3568
--- /dev/null
+++ b/ext/spl/tests/bug62433.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #62433 Inconsistent behavior of RecursiveDirectoryIterator to dot files (. and ..)
+--FILE--
+<?php
+$dots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__)));
+$ndots = array_keys(iterator_to_array(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS)));
+
+var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '.', $dots));
+var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '..', $dots));
+
+var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '.', $ndots));
+var_dump(in_array(__DIR__ . DIRECTORY_SEPARATOR . '..', $ndots));
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+bool(false)
diff --git a/ext/spl/tests/bug62616.phpt b/ext/spl/tests/bug62616.phpt
new file mode 100644
index 0000000..4e4be94
--- /dev/null
+++ b/ext/spl/tests/bug62616.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #62616 (ArrayIterator::count() from IteratorIterator instance gives Segmentation fault)
+--FILE--
+<?php
+$ai = new ArrayIterator(array(0,1));
+
+var_dump($ai->count());
+
+$ii = new IteratorIterator($ai);
+
+var_dump($ii->count());
+?>
+--EXPECTF--
+int(2)
+int(2)
diff --git a/ext/spl/tests/bug62904.phpt b/ext/spl/tests/bug62904.phpt
new file mode 100644
index 0000000..7e392da
--- /dev/null
+++ b/ext/spl/tests/bug62904.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #62904 (Crash when cloning an object which inherits SplFixedArray)
+--FILE--
+<?php
+
+class foo extends SplFixedArray {
+ public function __construct($size) {
+ }
+}
+
+$x = new foo(2);
+
+try {
+ $z = clone $x;
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+--EXPECTF--
+string(40) "The instance wasn't initialized properly"
diff --git a/ext/spl/tests/bug62978.phpt b/ext/spl/tests/bug62978.phpt
new file mode 100644
index 0000000..0d91609
--- /dev/null
+++ b/ext/spl/tests/bug62978.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Bug #62987 (Assigning to ArrayObject[null][something] overrides all undefined variables)
+--FILE--
+<?php
+$a = new ArrayObject();
+
+$b = array();
+
+$a[null]['hurr'] = 'durr';
+
+var_dump($a['epic_magic']);
+var_dump($b['epic_magic']);
+var_dump($c['epic_magic']); // Undefined var!!
+
+$d = array();
+var_dump($a['epic_magic']); // more magic!
+var_dump($d['epic_magic']);
+
+$e = 'srsly?';
+var_dump($a['epic_magic']); // srsly.
+var_dump(isset($a['epic_magic']));
+
+$fp = fopen(__FILE__, 'r');
+var_dump($a[$fp]);
+
+fclose($fp);
+--EXPECTF--
+Notice: Undefined index: epic_magic in %sbug62978.php on line %d
+NULL
+
+Notice: Undefined index: epic_magic in %sbug62978.php on line %d
+NULL
+
+Notice: Undefined variable: c in %sbug62978.php on line %d
+NULL
+
+Notice: Undefined index: epic_magic in %sbug62978.php on line %d
+NULL
+
+Notice: Undefined index: epic_magic in %sbug62978.php on line %d
+NULL
+
+Notice: Undefined index: epic_magic in %sbug62978.php on line %d
+NULL
+bool(false)
+
+Strict Standards: Resource ID#%d used as offset, casting to integer (%d) in %sbug62978.php on line %d
+
+Notice: Undefined offset: %d in %sbug62978.php on line %d
+NULL
diff --git a/ext/spl/tests/bug63680.phpt b/ext/spl/tests/bug63680.phpt
new file mode 100644
index 0000000..3a20c4b
--- /dev/null
+++ b/ext/spl/tests/bug63680.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #63680 (Memleak in splfixedarray with cycle reference)
+--FILE--
+<?php
+function dummy() {
+ $a = new SplFixedArray(1);
+ $b = new SplFixedArray(1);
+ $a[0] = $b;
+ $b[0] = $a;
+}
+
+dummy();
+var_dump(gc_collect_cycles());
+?>
+--EXPECT--
+int(2)
diff --git a/ext/spl/tests/bug64023.phpt b/ext/spl/tests/bug64023.phpt
new file mode 100644
index 0000000..2c177f9
--- /dev/null
+++ b/ext/spl/tests/bug64023.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #64023: Overloading __toString() in SplFileInfo has no effect
+--FILE--
+<?php
+class A extends \SplFileInfo
+{
+ public function __toString() {return ' -expected- ';}
+}
+
+$a = new A('/');
+
+// Works
+echo $a, $a->__toString(), $a->__toString() . '', "\n";
+
+// Does not work - outputs parent::__toString()
+echo $a . '', "\n";
+
+--EXPECT--
+ -expected- -expected- -expected-
+ -expected-
diff --git a/ext/spl/tests/bug64106.phpt b/ext/spl/tests/bug64106.phpt
new file mode 100644
index 0000000..855caef
--- /dev/null
+++ b/ext/spl/tests/bug64106.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #64106: Segfault on SplFixedArray[][x] = y when extended
+--FILE--
+<?php
+
+class MyFixedArray extends SplFixedArray {
+ public function offsetGet($offset) {}
+}
+
+$array = new MyFixedArray(10);
+$array[][1] = 10;
+
+?>
+--EXPECTF--
+Notice: Indirect modification of overloaded element of MyFixedArray has no effect in %s on line %d
diff --git a/ext/spl/tests/bug64228.phpt b/ext/spl/tests/bug64228.phpt
new file mode 100644
index 0000000..3f30dd2
--- /dev/null
+++ b/ext/spl/tests/bug64228.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS)
+--FILE--
+<?php
+$dirs = array();
+$empty_dir = __DIR__ . "/empty";
+@mkdir($empty_dir);
+
+$i = new RecursiveDirectoryIterator($empty_dir, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO); // Note the absence of FilesystemIterator::SKIP_DOTS
+foreach ($i as $key => $value) {
+ $dirs[] = $value->getFileName();
+}
+
+@rmdir($empty_dir);
+
+sort($dirs);
+print_r($dirs);
+?>
+--EXPECT--
+Array
+(
+ [0] => .
+ [1] => ..
+)
+
diff --git a/ext/spl/tests/bug64264.phpt b/ext/spl/tests/bug64264.phpt
new file mode 100644
index 0000000..e7b695b
--- /dev/null
+++ b/ext/spl/tests/bug64264.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #64264 (SPLFixedArray toArray problem)
+--FILE--
+<?php
+class MyFixedArray extends \SplFixedArray {
+ protected $foo;
+ protected $bar;
+}
+
+$myFixedArr = new MyFixedArray(1);
+$myFixedArr[0] = 'foo';
+$myFixedArr->setSize(2);
+$myFixedArr[1] = 'bar';
+$myFixedArr->setSize(5);
+$array = $myFixedArr->toArray();
+$array[2] = "ERROR";
+$array[3] = "ERROR";
+$array[4] = "ERROR";
+unset($array[4]);
+$myFixedArr->setSize(2);
+
+print_r($myFixedArr->toArray());
+?>
+--EXPECTF--
+Array
+(
+ [0] => foo
+ [1] => bar
+)
diff --git a/ext/spl/tests/class_implements_basic.phpt b/ext/spl/tests/class_implements_basic.phpt
new file mode 100644
index 0000000..1170b21
--- /dev/null
+++ b/ext/spl/tests/class_implements_basic.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: Test class_implements() function : basic
+--FILE--
+<?php
+/* Prototype : array class_implements(mixed what [, bool autoload ])
+ * Description: Return all classes and interfaces implemented by SPL
+ * Source code: ext/spl/php_spl.c
+ * Alias to functions:
+ */
+
+echo "*** Testing class_implements() : basic ***\n";
+
+
+interface foo { }
+class bar implements foo {}
+
+var_dump(class_implements(new bar));
+var_dump(class_implements('bar'));
+
+
+?>
+===DONE===
+--EXPECT--
+*** Testing class_implements() : basic ***
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+===DONE===
diff --git a/ext/spl/tests/class_implements_basic2.phpt b/ext/spl/tests/class_implements_basic2.phpt
new file mode 100644
index 0000000..ea25e5b
--- /dev/null
+++ b/ext/spl/tests/class_implements_basic2.phpt
@@ -0,0 +1,74 @@
+--TEST--
+SPL: Test class_implements() function : basic
+--FILE--
+<?php
+/* Prototype : array class_implements(mixed what [, bool autoload ])
+ * Description: Return all classes and interfaces implemented by SPL
+ * Source code: ext/spl/php_spl.c
+ * Alias to functions:
+ */
+
+echo "*** Testing class_implements() : basic ***\n";
+
+
+interface foo { }
+class fooImpl implements foo {}
+
+interface bar { }
+class barImpl implements bar {}
+
+class foobarImpl implements foo, bar {}
+
+class fooViaBarImpl extends barImpl implements foo {}
+
+class fooExtended extends fooImpl {}
+
+s_var_dump(class_implements(new foobarImpl));
+s_var_dump(class_implements('foobarImpl'));
+s_var_dump(class_implements(new fooViaBarImpl));
+s_var_dump(class_implements('fooViaBarImpl'));
+s_var_dump(class_implements(new fooExtended));
+s_var_dump(class_implements('fooExtended'));
+
+
+function s_var_dump($arr) {
+ krsort($arr);
+ var_dump($arr);
+}
+?>
+===DONE===
+--EXPECT--
+*** Testing class_implements() : basic ***
+array(2) {
+ ["foo"]=>
+ string(3) "foo"
+ ["bar"]=>
+ string(3) "bar"
+}
+array(2) {
+ ["foo"]=>
+ string(3) "foo"
+ ["bar"]=>
+ string(3) "bar"
+}
+array(2) {
+ ["foo"]=>
+ string(3) "foo"
+ ["bar"]=>
+ string(3) "bar"
+}
+array(2) {
+ ["foo"]=>
+ string(3) "foo"
+ ["bar"]=>
+ string(3) "bar"
+}
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+===DONE===
diff --git a/ext/spl/tests/class_implements_variation.phpt b/ext/spl/tests/class_implements_variation.phpt
new file mode 100644
index 0000000..52fdbca
--- /dev/null
+++ b/ext/spl/tests/class_implements_variation.phpt
@@ -0,0 +1,45 @@
+--TEST--
+SPL: Test class_implements() function : variation - no interfaces and autoload
+--FILE--
+<?php
+/* Prototype : array class_implements(mixed what [, bool autoload ])
+ * Description: Return all classes and interfaces implemented by SPL
+ * Source code: ext/spl/php_spl.c
+ * Alias to functions:
+ */
+
+echo "*** Testing class_implements() : variation ***\n";
+
+echo "--- testing no interfaces ---\n";
+class fs {}
+var_dump(class_implements(new fs));
+var_dump(class_implements('fs'));
+
+echo "\n--- testing autoload ---\n";
+var_dump(class_implements('non-existent'));
+var_dump(class_implements('non-existent2', false));
+
+
+function __autoload($classname) {
+ echo "attempting to autoload $classname\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing class_implements() : variation ***
+--- testing no interfaces ---
+array(0) {
+}
+array(0) {
+}
+
+--- testing autoload ---
+attempting to autoload non-existent
+
+Warning: class_implements(): Class non-existent does not exist and could not be loaded in %s on line %d
+bool(false)
+
+Warning: class_implements(): Class non-existent2 does not exist in %s on line %d
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/class_implements_variation1.phpt b/ext/spl/tests/class_implements_variation1.phpt
new file mode 100644
index 0000000..d8a45ce
--- /dev/null
+++ b/ext/spl/tests/class_implements_variation1.phpt
@@ -0,0 +1,221 @@
+--TEST--
+SPL: Test class_implements() function : variation
+--FILE--
+<?php
+/* Prototype : array class_implements(mixed what [, bool autoload ])
+ * Description: Return all classes and interfaces implemented by SPL
+ * Source code: ext/spl/php_spl.c
+ * Alias to functions:
+ */
+
+echo "*** Testing class_implements() : variation ***\n";
+
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$autoload = true;
+
+//resource
+$res = fopen(__FILE__,'r');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ //resource
+ 'resource' => $res,
+);
+
+// loop through each element of the array for pattern
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( class_implements($value, $autoload) );
+};
+
+fclose($res);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing class_implements() : variation ***
+
+--int 0--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - class_implements(): Class does not exist and could not be loaded, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - class_implements(): Class does not exist and could not be loaded, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+array(0) {
+}
+
+--instance of classWithoutToString--
+array(0) {
+}
+
+--undefined var--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+
+--resource--
+Error: 2 - class_implements(): object or string expected, %s(%d)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/class_implements_variation2.phpt b/ext/spl/tests/class_implements_variation2.phpt
new file mode 100644
index 0000000..f695357
--- /dev/null
+++ b/ext/spl/tests/class_implements_variation2.phpt
@@ -0,0 +1,259 @@
+--TEST--
+SPL: Test class_implements() function : variation
+--FILE--
+<?php
+/* Prototype : array class_implements(mixed what [, bool autoload ])
+ * Description: Return all classes and interfaces implemented by SPL
+ * Source code: ext/spl/php_spl.c
+ * Alias to functions:
+ */
+
+echo "*** Testing class_implements() : variation ***\n";
+
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$class = 'Iterator';
+
+//resource
+$res = fopen(__FILE__,'r');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ //resource
+ 'resource' => $res,
+);
+
+// loop through each element of the array for pattern
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( class_implements($class, $value) );
+};
+
+fclose($res);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing class_implements() : variation ***
+
+--int 0--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--int 1--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--int 12345--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--int -12345--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--float 10.5--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--float -10.5--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--float 12.3456789000e10--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--float -12.3456789000e10--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--float .5--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--empty array--
+Error: 2 - class_implements() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - class_implements() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - class_implements() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - class_implements() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--lowercase null--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--lowercase true--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--lowercase false--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--uppercase TRUE--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--uppercase FALSE--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--empty string DQ--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--empty string SQ--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--instance of classWithToString--
+Error: 2 - class_implements() expects parameter 2 to be boolean, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - class_implements() expects parameter 2 to be boolean, object given, %s(%d)
+bool(false)
+
+--undefined var--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--unset var--
+array(1) {
+ ["Traversable"]=>
+ string(11) "Traversable"
+}
+
+--resource--
+Error: 2 - class_implements() expects parameter 2 to be boolean, resource given, %s(%d)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/class_uses_basic.phpt b/ext/spl/tests/class_uses_basic.phpt
new file mode 100644
index 0000000..8aeb7b5
--- /dev/null
+++ b/ext/spl/tests/class_uses_basic.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: Test class_implements() function : basic
+--FILE--
+<?php
+/* Prototype : array class_uses(mixed what [, bool autoload ])
+ * Description: Return all traits used by a class
+ * Source code: ext/spl/php_spl.c
+ * Alias to functions:
+ */
+
+echo "*** Testing class_uses() : basic ***\n";
+
+
+trait foo { }
+class bar { use foo; }
+
+var_dump(class_uses(new bar));
+var_dump(class_uses('bar'));
+
+
+?>
+===DONE===
+--EXPECT--
+*** Testing class_uses() : basic ***
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+===DONE===
diff --git a/ext/spl/tests/class_uses_basic2.phpt b/ext/spl/tests/class_uses_basic2.phpt
new file mode 100644
index 0000000..a0ffe8b
--- /dev/null
+++ b/ext/spl/tests/class_uses_basic2.phpt
@@ -0,0 +1,69 @@
+--TEST--
+SPL: Test class_uses() function : basic
+--FILE--
+<?php
+/* Prototype : array class_uses(mixed what [, bool autoload ])
+ * Description: Return all traits used by a class
+ * Source code: ext/spl/php_spl.c
+ * Alias to functions:
+ */
+
+echo "*** Testing class_uses() : basic ***\n";
+
+
+trait foo { }
+class fooUser { use foo; }
+
+trait bar { }
+class barUser { use bar; }
+
+class foobarUser { use foo, bar; }
+
+/** There is no semantics for traits in the inheritance chain.
+ Traits are flattend into a class, and that semantics is nothing
+ like a type, or interface, and thus, not propergated. */
+class fooViaBarUser extends barUser { use foo; }
+
+class fooExtended extends fooUser {}
+
+s_var_dump(class_uses(new foobarUser));
+s_var_dump(class_uses('foobarUser'));
+s_var_dump(class_uses(new fooViaBarUser));
+s_var_dump(class_uses('fooViaBarUser'));
+s_var_dump(class_uses(new fooExtended));
+s_var_dump(class_uses('fooExtended'));
+
+
+function s_var_dump($arr) {
+ krsort($arr);
+ var_dump($arr);
+}
+?>
+===DONE===
+--EXPECT--
+*** Testing class_uses() : basic ***
+array(2) {
+ ["foo"]=>
+ string(3) "foo"
+ ["bar"]=>
+ string(3) "bar"
+}
+array(2) {
+ ["foo"]=>
+ string(3) "foo"
+ ["bar"]=>
+ string(3) "bar"
+}
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+array(0) {
+}
+array(0) {
+}
+===DONE===
diff --git a/ext/spl/tests/class_uses_variation.phpt b/ext/spl/tests/class_uses_variation.phpt
new file mode 100644
index 0000000..9c21521
--- /dev/null
+++ b/ext/spl/tests/class_uses_variation.phpt
@@ -0,0 +1,45 @@
+--TEST--
+SPL: Test class_uses() function : variation - no interfaces and autoload
+--FILE--
+<?php
+/* Prototype : array class_uses(mixed what [, bool autoload ])
+ * Description: Return all traits used by a class
+ * Source code: ext/spl/php_spl.c
+ * Alias to functions:
+ */
+
+echo "*** Testing class_uses() : variation ***\n";
+
+echo "--- testing no traits ---\n";
+class fs {}
+var_dump(class_uses(new fs));
+var_dump(class_uses('fs'));
+
+echo "\n--- testing autoload ---\n";
+var_dump(class_uses('non-existent'));
+var_dump(class_uses('non-existent2', false));
+
+
+function __autoload($classname) {
+ echo "attempting to autoload $classname\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing class_uses() : variation ***
+--- testing no traits ---
+array(0) {
+}
+array(0) {
+}
+
+--- testing autoload ---
+attempting to autoload non-existent
+
+Warning: class_uses(): Class non-existent does not exist and could not be loaded in %s on line %d
+bool(false)
+
+Warning: class_uses(): Class non-existent2 does not exist in %s on line %d
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/class_uses_variation1.phpt b/ext/spl/tests/class_uses_variation1.phpt
new file mode 100644
index 0000000..aa0ba35
--- /dev/null
+++ b/ext/spl/tests/class_uses_variation1.phpt
@@ -0,0 +1,221 @@
+--TEST--
+SPL: Test class_uses() function : variation
+--FILE--
+<?php
+/* Prototype : array class_uses(mixed what [, bool autoload ])
+ * Description: Return all traits used by a class
+ * Source code: ext/spl/php_spl.c
+ * Alias to functions:
+ */
+
+echo "*** Testing class_uses() : variation ***\n";
+
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$autoload = true;
+
+//resource
+$res = fopen(__FILE__,'r');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ //resource
+ 'resource' => $res,
+);
+
+// loop through each element of the array for pattern
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( class_uses($value, $autoload) );
+};
+
+fclose($res);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing class_uses() : variation ***
+
+--int 0--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - class_uses(): Class does not exist and could not be loaded, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - class_uses(): Class does not exist and could not be loaded, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+array(0) {
+}
+
+--instance of classWithoutToString--
+array(0) {
+}
+
+--undefined var--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+
+--resource--
+Error: 2 - class_uses(): object or string expected, %s(%d)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/class_uses_variation2.phpt b/ext/spl/tests/class_uses_variation2.phpt
new file mode 100644
index 0000000..36c9623
--- /dev/null
+++ b/ext/spl/tests/class_uses_variation2.phpt
@@ -0,0 +1,261 @@
+--TEST--
+SPL: Test class_uses() function : variation
+--FILE--
+<?php
+/* Prototype : array class_uses(mixed what [, bool autoload ])
+ * Description: Return all traits used by a class
+ * Source code: ext/spl/php_spl.c
+ * Alias to functions:
+ */
+
+echo "*** Testing class_uses() : variation ***\n";
+
+trait foo {}
+class fooUser { use foo; }
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$class = 'fooUser';
+
+//resource
+$res = fopen(__FILE__,'r');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ //resource
+ 'resource' => $res,
+);
+
+// loop through each element of the array for pattern
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( class_uses($class, $value) );
+};
+
+fclose($res);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing class_uses() : variation ***
+
+--int 0--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--int 1--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--int 12345--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--int -12345--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--float 10.5--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--float -10.5--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--float 12.3456789000e10--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--float -12.3456789000e10--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--float .5--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--empty array--
+Error: 2 - class_uses() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - class_uses() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - class_uses() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - class_uses() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--lowercase null--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--lowercase true--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--lowercase false--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--uppercase TRUE--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--uppercase FALSE--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--empty string DQ--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--empty string SQ--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--instance of classWithToString--
+Error: 2 - class_uses() expects parameter 2 to be boolean, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - class_uses() expects parameter 2 to be boolean, object given, %s(%d)
+bool(false)
+
+--undefined var--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--unset var--
+array(1) {
+ ["foo"]=>
+ string(3) "foo"
+}
+
+--resource--
+Error: 2 - class_uses() expects parameter 2 to be boolean, resource given, %s(%d)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/countable_class_basic1.phpt b/ext/spl/tests/countable_class_basic1.phpt
new file mode 100644
index 0000000..c64aad6
--- /dev/null
+++ b/ext/spl/tests/countable_class_basic1.phpt
@@ -0,0 +1,37 @@
+--TEST--
+SPL: Test shape of interface Countable.
+--SKIPIF--
+<?php
+// Skip the test case if Standard PHP Library(spl) is not installed
+ if( !extension_loaded('spl'))
+ {
+ die('skip spl is not installed');
+ }
+?>
+--FILE--
+<?php
+ReflectionClass::export('Countable');
+?>
+--EXPECTF--
+Interface [ <internal%s> interface Countable ] {
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [1] {
+ Method [ <internal%s> abstract public method count ] {
+
+ - Parameters [0] {
+ }
+ }
+ }
+}
diff --git a/ext/spl/tests/countable_count_variation1.phpt b/ext/spl/tests/countable_count_variation1.phpt
new file mode 100644
index 0000000..642887d
--- /dev/null
+++ b/ext/spl/tests/countable_count_variation1.phpt
@@ -0,0 +1,68 @@
+--TEST--
+SPL: Countable::count() with wrong return types and exception.
+--FILE--
+<?php
+
+Class returnNull implements Countable {
+ function count() {
+ }
+}
+
+Class returnString implements Countable {
+ function count() {
+ return "hello";
+ }
+}
+
+Class returnObject implements Countable {
+ function count() {
+ return new returnObject;
+ }
+}
+
+Class returnArray implements Countable {
+ function count() {
+ return array(1,2,3);
+ }
+}
+
+Class throwException implements Countable {
+ function count() {
+ throw new Exception('Thrown from count');
+ }
+}
+
+
+echo "Count returns null:\n";
+var_dump(count(new returnNull));
+
+echo "Count returns a string:\n";
+var_dump(count(new returnString));
+
+echo "Count returns an object:\n";
+var_dump(count(new returnObject));
+
+echo "Count returns an array:\n";
+var_dump(count(new returnArray));
+
+echo "Count throws an exception:\n";
+try {
+ echo count(new throwException);
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECTF--
+Count returns null:
+int(0)
+Count returns a string:
+int(0)
+Count returns an object:
+
+Notice: Object of class returnObject could not be converted to int in %s on line 40
+int(1)
+Count returns an array:
+int(1)
+Count throws an exception:
+Thrown from count \ No newline at end of file
diff --git a/ext/spl/tests/dit_001.phpt b/ext/spl/tests/dit_001.phpt
new file mode 100644
index 0000000..a56166d
--- /dev/null
+++ b/ext/spl/tests/dit_001.phpt
@@ -0,0 +1,28 @@
+--TEST--
+SPL: Problem with casting to string
+--SKIPIF--
+<?php
+if (!defined('GLOB_ERR')) print "skip";
+--FILE--
+<?php
+$d = new DirectoryIterator('.');
+var_dump($d);
+var_dump(is_string($d));
+preg_match('/x/', $d);
+var_dump(is_string($d));
+?>
+===DONE===
+--EXPECTF--
+object(DirectoryIterator)#%d (4) {
+ %s"pathName"%s"SplFileInfo":private]=>
+ %s(%d) ".%c%s"
+ %s"fileName"%s"SplFileInfo":private]=>
+ %s(%d) "%s"
+ %s"glob"%s"DirectoryIterator":private]=>
+ bool(false)
+ %s"subPathName"%s"RecursiveDirectoryIterator":private]=>
+ %s(0) ""
+}
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/dit_001_noglob.phpt b/ext/spl/tests/dit_001_noglob.phpt
new file mode 100644
index 0000000..acb2092
--- /dev/null
+++ b/ext/spl/tests/dit_001_noglob.phpt
@@ -0,0 +1,27 @@
+--TEST--
+SPL: Problem with casting to string (no glob version)
+--SKIPIF--
+<?php
+if (defined('GLOB_ERR')) print "skip";
+--FILE--
+<?php
+$d = new DirectoryIterator('.');
+var_dump($d);
+var_dump(is_string($d));
+preg_match('/x/', $d);
+var_dump(is_string($d));
+?>
+===DONE===
+--EXPECTF--
+object(DirectoryIterator)#%d (3) {
+ %s"pathName"%s"SplFileInfo":private]=>
+ %s(%d) ".%c%s"
+ %s"fileName"%s"SplFileInfo":private]=>
+ %s(%d) "%s"
+ %s"subPathName"%s"RecursiveDirectoryIterator":private]=>
+ %s(0) ""
+}
+bool(false)
+bool(false)
+===DONE===
+
diff --git a/ext/spl/tests/dit_002.phpt b/ext/spl/tests/dit_002.phpt
new file mode 100644
index 0000000..a266542
--- /dev/null
+++ b/ext/spl/tests/dit_002.phpt
@@ -0,0 +1,77 @@
+--TEST--
+SPL: DirectoryIterator defaults
+--SKIPIF--
+<?php if (!extension_loaded("spl") || !extension_loaded('reflection') || !defined('GLOB_ERR')) print "skip"; ?>
+--FILE--
+<?php
+
+$classes = array(
+ 'DirectoryIterator' => 0,
+ 'FilesystemIterator' => 1,
+ 'RecursiveDirectoryIterator' => 1,
+ 'GlobIterator' => 1,
+);
+
+foreach ($classes as $class => $flags) {
+ echo "===$class===\n";
+ $ref = new ReflectionClass($class);
+ $obj = $ref->newInstance('glob://*');
+ echo get_class($obj->current()) . "\n";
+ if ($flags)
+ {
+ var_dump($obj->getFlags());
+ $flags = array(
+ FilesystemIterator::CURRENT_AS_FILEINFO => 0,
+ FilesystemIterator::CURRENT_AS_SELF => 0,
+ FilesystemIterator::CURRENT_AS_PATHNAME => 1,
+ );
+ foreach($flags as $flag => $isstring) {
+ $obj->setFlags($flag);
+ $obj->rewind();
+ var_dump($obj->getFlags());
+ if ($isstring) {
+ $val = $obj->current();
+ if (is_string($val)) {
+ var_dump(true);
+ } else {
+ var_dump($val);
+ }
+ } else {
+ echo get_class($obj->current()) . "\n";
+ }
+ }
+ }
+}
+?>
+===DONE===
+--EXPECTF--
+===DirectoryIterator===
+DirectoryIterator
+===FilesystemIterator===
+SplFileInfo
+int(%d)
+int(0)
+SplFileInfo
+int(16)
+FilesystemIterator
+int(32)
+bool(true)
+===RecursiveDirectoryIterator===
+SplFileInfo
+int(0)
+int(0)
+SplFileInfo
+int(16)
+RecursiveDirectoryIterator
+int(32)
+bool(true)
+===GlobIterator===
+SplFileInfo
+int(0)
+int(0)
+SplFileInfo
+int(16)
+GlobIterator
+int(32)
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/dit_003.phpt b/ext/spl/tests/dit_003.phpt
new file mode 100644
index 0000000..4ffc292
--- /dev/null
+++ b/ext/spl/tests/dit_003.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: FilesystemIterator and foreach
+--FILE--
+<?php
+$count = 0;
+foreach(new FilesystemIterator(__DIR__) as $ent)
+{
+ ++$count;
+}
+var_dump($count > 0);
+?>
+===DONE===
+--EXPECTF--
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/dit_004.phpt b/ext/spl/tests/dit_004.phpt
new file mode 100644
index 0000000..4ad0e4b
--- /dev/null
+++ b/ext/spl/tests/dit_004.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: DirectoryIterator and clone
+--FILE--
+<?php
+$a = new DirectoryIterator(__DIR__);
+$b = clone $a;
+var_dump((string)$b == (string)$a);
+var_dump($a->key(), $b->key());
+$a->next();
+$a->next();
+$a->next();
+$c = clone $a;
+var_dump((string)$c == (string)$a);
+var_dump($a->key(), $c->key());
+?>
+===DONE===
+--EXPECTF--
+bool(true)
+int(0)
+int(0)
+bool(true)
+int(3)
+int(3)
+===DONE===
diff --git a/ext/spl/tests/dit_005.phpt b/ext/spl/tests/dit_005.phpt
new file mode 100644
index 0000000..52a3351
--- /dev/null
+++ b/ext/spl/tests/dit_005.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: FilesystemIterator and clone
+--FILE--
+<?php
+$a = new FileSystemIterator(__DIR__);
+$b = clone $a;
+var_dump((string)$b == (string)$a);
+var_dump($a->key() == $b->key());
+$a->next();
+$a->next();
+$a->next();
+$c = clone $a;
+var_dump((string)$c == (string)$a);
+var_dump($a->key() == $c->key());
+?>
+===DONE===
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/dit_006.phpt b/ext/spl/tests/dit_006.phpt
new file mode 100644
index 0000000..1e627a2
--- /dev/null
+++ b/ext/spl/tests/dit_006.phpt
@@ -0,0 +1,50 @@
+--TEST--
+SPL: DirectoryIterator and seek
+--FILE--
+<?php
+$di = new DirectoryIterator(__DIR__);
+$di->seek(2);
+
+$n = 0;
+while ($di->valid()) {
+ $n++;
+ $di->next();
+}
+
+echo "With seek(2) we get $n\n";
+$di->seek(0);
+
+$m = 0;
+while ($di->valid()) {
+ $m++;
+ $di->next();
+}
+echo "With seek(0) we get $m\n";
+
+$o = 0;
+$di->rewind();
+while ($di->valid()) {
+ $o++;
+ $di->next();
+}
+
+echo "Without seek we get $o\n";
+
+$p = 0;
+$di->seek($o+1);
+while ($di->valid()) {
+ $p++;
+ $di->next();
+}
+
+var_dump($n !== $m, $m === $o, $p === 0);
+?>
+===DONE===
+--EXPECTF--
+With seek(2) we get %d
+With seek(0) we get %d
+Without seek we get %d
+bool(true)
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/dllist_001.phpt b/ext/spl/tests/dllist_001.phpt
new file mode 100644
index 0000000..e27f23c
--- /dev/null
+++ b/ext/spl/tests/dllist_001.phpt
@@ -0,0 +1,63 @@
+--TEST--
+SPL: DoublyLinkedList: std operations
+--FILE--
+<?php
+$dll = new SplDoublyLinkedList();
+// errors
+try {
+ $dll->pop();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ $dll->shift();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+// data consistency
+$a = 2;
+$dll->push($a);
+echo $dll->pop()."\n";
+
+$a = 2;
+$dll->unshift($a);
+echo $dll->shift()."\n";
+
+// peakable
+$dll->push(1);
+$dll->push(2);
+echo $dll->top()."\n";
+echo $dll->bottom()."\n";
+$dll->pop();
+$dll->pop();
+
+// countable
+$dll->push(NULL);
+$dll->push(NULL);
+echo count($dll)."\n";
+echo $dll->count()."\n";
+var_dump($dll->pop());
+var_dump($dll->pop());
+
+// clonable
+$dll->push(2);
+$dll_clone = clone $dll;
+$dll_clone->pop();
+echo count($dll)."\n";
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Exception: Can't pop from an empty datastructure
+Exception: Can't shift from an empty datastructure
+2
+2
+2
+1
+2
+2
+NULL
+NULL
+1
+===DONE===
diff --git a/ext/spl/tests/dllist_002.phpt b/ext/spl/tests/dllist_002.phpt
new file mode 100644
index 0000000..e956de6
--- /dev/null
+++ b/ext/spl/tests/dllist_002.phpt
@@ -0,0 +1,60 @@
+--TEST--
+SPL: DoublyLinkedList: iterators
+--FILE--
+<?php
+$dll = new SplDoublyLinkedList();
+$dll->push(2);
+$dll->push(3);
+$dll->push(4);
+
+$dll2 = clone $dll;
+
+// std iterator
+foreach($dll as $k=>$v) {
+ echo "$k=>$v\n";
+ // inner iterator
+ foreach($dll as $k2=>$v2) {
+ echo "->$k2=>$v2\n";
+ }
+}
+
+echo "# deleted\n";
+
+foreach($dll as $k=>$v) {
+ echo "$k=>$v\n";
+ unset($dll);
+}
+
+echo "# while popping\n";
+
+foreach($dll2 as $k=>$v) {
+ echo "$k=>$v\n";
+ echo "popped ".$dll2->pop()."\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+0=>2
+->0=>2
+->1=>3
+->2=>4
+1=>3
+->0=>2
+->1=>3
+->2=>4
+2=>4
+->0=>2
+->1=>3
+->2=>4
+# deleted
+0=>2
+1=>3
+2=>4
+# while popping
+0=>2
+popped 4
+1=>3
+popped 3
+===DONE===
diff --git a/ext/spl/tests/dllist_003.phpt b/ext/spl/tests/dllist_003.phpt
new file mode 100644
index 0000000..9a95568
--- /dev/null
+++ b/ext/spl/tests/dllist_003.phpt
@@ -0,0 +1,43 @@
+--TEST--
+SPL: DoublyLinkedList: iterator modes
+--FILE--
+<?php
+$dll = new SplDoublyLinkedList();
+$dll->push(2);
+$dll->push(3);
+$dll->push(4);
+
+$dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
+
+foreach ($dll as $k => $v) {
+ echo "$k=>$v\n";
+}
+
+$dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
+foreach ($dll as $k => $v) {
+ echo "$k=>$v\n";
+}
+
+$dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_DELETE);
+var_dump($dll->count());
+foreach ($dll as $k => $v) {
+ echo "$k=>$v\n";
+}
+var_dump($dll->count());
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+2=>4
+1=>3
+0=>2
+0=>2
+1=>3
+2=>4
+int(3)
+0=>2
+0=>3
+0=>4
+int(0)
+===DONE===
diff --git a/ext/spl/tests/dllist_004.phpt b/ext/spl/tests/dllist_004.phpt
new file mode 100644
index 0000000..44d9611
--- /dev/null
+++ b/ext/spl/tests/dllist_004.phpt
@@ -0,0 +1,61 @@
+--TEST--
+SPL: DoublyLinkedList: Stacks
+--FILE--
+<?php
+$stack = new SplStack();
+// errors
+try {
+ $stack->pop();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ $stack->shift();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+// data consistency
+$a = 2;
+$stack->push($a);
+echo $stack->pop()."\n";
+
+// peakable
+$stack->push(1);
+$stack->push(2);
+echo $stack->top()."\n";
+
+// iterable
+foreach ($stack as $elem) {
+ echo "[$elem]\n";
+}
+
+// countable
+$stack->push(NULL);
+$stack->push(NULL);
+echo count($stack)."\n";
+echo $stack->count()."\n";
+var_dump($stack->pop());
+var_dump($stack->pop());
+
+// clonable
+$stack->push(2);
+$stack_clone = clone $stack;
+$stack_clone->pop();
+echo count($stack)."\n";
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Exception: Can't pop from an empty datastructure
+Exception: Can't shift from an empty datastructure
+2
+2
+[2]
+[1]
+4
+4
+NULL
+NULL
+3
+===DONE===
diff --git a/ext/spl/tests/dllist_005.phpt b/ext/spl/tests/dllist_005.phpt
new file mode 100644
index 0000000..33161ba
--- /dev/null
+++ b/ext/spl/tests/dllist_005.phpt
@@ -0,0 +1,61 @@
+--TEST--
+SPL: DoublyLinkedList: Queues
+--FILE--
+<?php
+$queue = new SplQueue();
+// errors
+try {
+ $queue->dequeue();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ $queue->shift();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+// data consistency
+$a = 2;
+$queue->enqueue($a);
+echo $queue->dequeue()."\n";
+
+// peakable
+$queue->enqueue(1);
+$queue->enqueue(2);
+echo $queue->top()."\n";
+
+// iterable
+foreach ($queue as $elem) {
+ echo "[$elem]\n";
+}
+
+// countable
+$queue->enqueue(NULL);
+$queue->enqueue(NULL);
+echo count($queue)."\n";
+echo $queue->count()."\n";
+var_dump($queue->dequeue());
+var_dump($queue->dequeue());
+
+// clonable
+$queue->enqueue(2);
+$queue_clone = clone $queue;
+$queue_clone->dequeue();
+echo count($queue)."\n";
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Exception: Can't shift from an empty datastructure
+Exception: Can't shift from an empty datastructure
+2
+2
+[1]
+[2]
+4
+4
+int(1)
+int(2)
+3
+===DONE===
diff --git a/ext/spl/tests/dllist_006.phpt b/ext/spl/tests/dllist_006.phpt
new file mode 100644
index 0000000..b4055dc
--- /dev/null
+++ b/ext/spl/tests/dllist_006.phpt
@@ -0,0 +1,62 @@
+--TEST--
+SPL: DoublyLinkedList: ArrayAccess
+--FILE--
+<?php
+$a = new SplDoublyLinkedList();
+$a->push(1);
+$a->push(2);
+$a->push(3);
+
+$a[] = "foo";
+$a[3] = 4;
+
+var_dump($a[0]);
+var_dump($a[1]);
+var_dump($a[2]);
+var_dump($a[3]);
+
+echo "Unsetting..\n";
+var_dump($a[2]);
+unset($a[2]);
+var_dump($a[2]);
+
+
+try {
+ var_dump($a["1"]);
+} catch (OutOfRangeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+try {
+ var_dump($a["a"]);
+} catch (OutOfRangeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+try {
+ var_dump($a["0"]);
+} catch (OutOfRangeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+try {
+ var_dump($a["9"]);
+} catch (OutOfRangeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(1)
+int(2)
+int(3)
+int(4)
+Unsetting..
+int(3)
+int(4)
+int(2)
+Exception: Offset invalid or out of range
+int(1)
+Exception: Offset invalid or out of range
+===DONE===
diff --git a/ext/spl/tests/dllist_007.phpt b/ext/spl/tests/dllist_007.phpt
new file mode 100644
index 0000000..38f801f
--- /dev/null
+++ b/ext/spl/tests/dllist_007.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: DoublyLinkedList: Iterator
+--FILE--
+<?php
+$a = new SplDoublyLinkedList();
+$a->push(1);
+$a->push(2);
+$a->push(3);
+
+$a->rewind();
+while ($a->valid()) {
+ var_dump($a->current(), $a->next());
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(1)
+NULL
+int(2)
+NULL
+int(3)
+NULL
+===DONE===
diff --git a/ext/spl/tests/dllist_008.phpt b/ext/spl/tests/dllist_008.phpt
new file mode 100644
index 0000000..ab37d83
--- /dev/null
+++ b/ext/spl/tests/dllist_008.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: SplDoublyLinkedList with overriden count()
+--FILE--
+<?php
+$obj = new SplDoublyLinkedList();
+$obj[] = 1;
+$obj[] = 2;
+var_dump(count($obj));
+class SplDoublyLinkedList2 extends SplDoublyLinkedList{
+ public function count() {
+ return -parent::count();
+ }
+}
+$obj = new SplDoublyLinkedList2();
+$obj[] = 1;
+$obj[] = 2;
+var_dump(count($obj));
+?>
+--EXPECT--
+int(2)
+int(-2)
diff --git a/ext/spl/tests/dllist_010.phpt b/ext/spl/tests/dllist_010.phpt
new file mode 100644
index 0000000..7e38955
--- /dev/null
+++ b/ext/spl/tests/dllist_010.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: DoublyLinkedList: prev
+--FILE--
+<?php
+$dll = new SplDoublyLinkedList();
+$dll->push(1);
+$dll->push(2);
+$dll->push(3);
+$dll->push(4);
+
+
+$dll->rewind();
+$dll->prev();
+var_dump($dll->current());
+$dll->rewind();
+var_dump($dll->current());
+$dll->next();
+var_dump($dll->current());
+$dll->next();
+$dll->next();
+var_dump($dll->current());
+$dll->prev();
+var_dump($dll->current());
+
+?>
+===DONE===
+--EXPECT--
+NULL
+int(1)
+int(2)
+int(4)
+int(3)
+===DONE===
diff --git a/ext/spl/tests/dllist_011.phpt b/ext/spl/tests/dllist_011.phpt
new file mode 100644
index 0000000..b9be872
--- /dev/null
+++ b/ext/spl/tests/dllist_011.phpt
@@ -0,0 +1,13 @@
+--TEST--
+SPL: DoublyLinkedList: prev
+--FILE--
+<?php
+$dll = new SplDoublyLinkedList();
+$dll->rewind();
+$dll->prev();
+var_dump($dll->current());
+?>
+===DONE===
+--EXPECT--
+NULL
+===DONE===
diff --git a/ext/spl/tests/dllist_012.phpt b/ext/spl/tests/dllist_012.phpt
new file mode 100644
index 0000000..4eec9bd
--- /dev/null
+++ b/ext/spl/tests/dllist_012.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: DoublyLinkedList: recursive var_dump
+--FILE--
+<?php
+$a = new SplDoublyLinkedList;
+$a[] = $a;
+
+var_dump($a);
+?>
+===DONE===
+--EXPECTF--
+object(SplDoublyLinkedList)#%d (2) {
+ ["flags":"SplDoublyLinkedList":private]=>
+ int(0)
+ ["dllist":"SplDoublyLinkedList":private]=>
+ array(1) {
+ [0]=>
+ *RECURSION*
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/dllist_memleak.phpt b/ext/spl/tests/dllist_memleak.phpt
new file mode 100644
index 0000000..9bae68b
--- /dev/null
+++ b/ext/spl/tests/dllist_memleak.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: DoublyLinkedList: memory leak when iterator pointer isn't at the last element
+--FILE--
+<?php
+$dll = new SplDoublyLinkedList();
+$dll->push(1);
+$dll->push(2);
+$dll->push(3);
+$dll->push(4);
+
+
+$dll->rewind();
+echo $dll->current()."\n";
+$dll->next();
+$dll->next();
+echo $dll->current()."\n";
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+1
+3
+===DONE===
diff --git a/ext/spl/tests/fileobject_001.phpt b/ext/spl/tests/fileobject_001.phpt
new file mode 100644
index 0000000..61f688d
--- /dev/null
+++ b/ext/spl/tests/fileobject_001.phpt
@@ -0,0 +1,88 @@
+--TEST--
+SPL: SplFileObject::seek'ing
+--FILE--
+<?php
+
+$o = new SplFileObject(dirname(__FILE__) . '/fileobject_001a.txt');
+
+var_dump($o->key());
+var_dump($o->current());
+$o->setFlags(SplFileObject::DROP_NEW_LINE);
+var_dump($o->key());
+var_dump($o->current());
+var_dump($o->key());
+$o->next();
+var_dump($o->key());
+var_dump($o->current());
+var_dump($o->key());
+$o->rewind();
+var_dump($o->key());
+var_dump($o->current());
+var_dump($o->key());
+$o->seek(4);
+var_dump($o->key());
+var_dump($o->current());
+var_dump($o->key());
+
+echo "===A===\n";
+foreach($o as $n => $l)
+{
+ var_dump($n, $l);
+}
+
+echo "===B===\n";
+$o = new SplFileObject(dirname(__FILE__) . '/fileobject_001b.txt');
+$o->setFlags(SplFileObject::DROP_NEW_LINE);
+foreach($o as $n => $l)
+{
+ var_dump($n, $l);
+}
+
+?>
+===DONE===
+--EXPECT--
+int(0)
+string(2) "0
+"
+int(0)
+string(2) "0
+"
+int(0)
+int(1)
+string(1) "1"
+int(1)
+int(0)
+string(1) "0"
+int(0)
+int(4)
+string(1) "4"
+int(4)
+===A===
+int(0)
+string(1) "0"
+int(1)
+string(1) "1"
+int(2)
+string(1) "2"
+int(3)
+string(1) "3"
+int(4)
+string(1) "4"
+int(5)
+string(1) "5"
+int(6)
+string(0) ""
+===B===
+int(0)
+string(1) "0"
+int(1)
+string(1) "1"
+int(2)
+string(1) "2"
+int(3)
+string(1) "3"
+int(4)
+string(1) "4"
+int(5)
+string(1) "5"
+===DONE===
diff --git a/ext/spl/tests/fileobject_001a.txt b/ext/spl/tests/fileobject_001a.txt
new file mode 100755
index 0000000..e8371f0
--- /dev/null
+++ b/ext/spl/tests/fileobject_001a.txt
@@ -0,0 +1,6 @@
+0
+1
+2
+3
+4
+5
diff --git a/ext/spl/tests/fileobject_001b.txt b/ext/spl/tests/fileobject_001b.txt
new file mode 100755
index 0000000..0c4a8b5
--- /dev/null
+++ b/ext/spl/tests/fileobject_001b.txt
@@ -0,0 +1,6 @@
+0
+1
+2
+3
+4
+5 \ No newline at end of file
diff --git a/ext/spl/tests/fileobject_002.phpt b/ext/spl/tests/fileobject_002.phpt
new file mode 100644
index 0000000..8031e98
--- /dev/null
+++ b/ext/spl/tests/fileobject_002.phpt
@@ -0,0 +1,122 @@
+--TEST--
+SPL: SplFileObject::fgetc
+--FILE--
+<?php
+
+function test($name)
+{
+ echo "===$name===\n";
+
+ $o = new SplFileObject(dirname(__FILE__) . '/' . $name);
+
+ var_dump($o->key());
+ while(($c = $o->fgetc()) !== false)
+ {
+ var_dump($o->key(), $c, $o->eof());
+ }
+ echo "===EOF?===\n";
+ var_dump($o->eof());
+ var_dump($o->key());
+ var_dump($o->eof());
+}
+
+test('fileobject_001a.txt');
+test('fileobject_001b.txt');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+===fileobject_001a.txt===
+int(0)
+int(0)
+string(1) "0"
+bool(false)
+int(1)
+string(1) "
+"
+bool(false)
+int(1)
+string(1) "1"
+bool(false)
+int(2)
+string(1) "
+"
+bool(false)
+int(2)
+string(1) "2"
+bool(false)
+int(3)
+string(1) "
+"
+bool(false)
+int(3)
+string(1) "3"
+bool(false)
+int(4)
+string(1) "
+"
+bool(false)
+int(4)
+string(1) "4"
+bool(false)
+int(5)
+string(1) "
+"
+bool(false)
+int(5)
+string(1) "5"
+bool(false)
+int(6)
+string(1) "
+"
+bool(false)
+===EOF?===
+bool(true)
+int(6)
+bool(true)
+===fileobject_001b.txt===
+int(0)
+int(0)
+string(1) "0"
+bool(false)
+int(1)
+string(1) "
+"
+bool(false)
+int(1)
+string(1) "1"
+bool(false)
+int(2)
+string(1) "
+"
+bool(false)
+int(2)
+string(1) "2"
+bool(false)
+int(3)
+string(1) "
+"
+bool(false)
+int(3)
+string(1) "3"
+bool(false)
+int(4)
+string(1) "
+"
+bool(false)
+int(4)
+string(1) "4"
+bool(false)
+int(5)
+string(1) "
+"
+bool(false)
+int(5)
+string(1) "5"
+bool(false)
+===EOF?===
+bool(true)
+int(5)
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/fileobject_003.phpt b/ext/spl/tests/fileobject_003.phpt
new file mode 100644
index 0000000..6cc650b
--- /dev/null
+++ b/ext/spl/tests/fileobject_003.phpt
@@ -0,0 +1,114 @@
+--TEST--
+SPL: SplFileInfo cloning
+--FILE--
+<?php
+
+function test($name, $lc, $lp)
+{
+ static $i = 0;
+ echo "===$i===\n";
+ $i++;
+
+ $o = new SplFileInfo($name);
+
+ var_dump($o);
+ $c = clone $o;
+ var_dump($c);
+ var_dump($o === $c);
+ var_dump($o == $c);
+ var_dump($o->getPathname() == $c->getPathname());
+
+ try {
+ $f = new SplFileObject($name);
+ var_dump($name);
+ var_dump($f->getPathName());
+ $l = substr($f->getPathName(), -1);
+ var_dump($l != '/' && $l != '\\' && $l == $lc);
+ var_dump($f->getFileName());
+ $l = substr($f->getFileName(), -1);
+ var_dump($l != '/' && $l != '\\' && $l == $lc);
+ var_dump($f->getPath());
+ $l = substr($f->getPath(), -1);
+ var_dump($l != '/' && $l != '\\' && $l == $lp);
+ } catch (LogicException $e) {
+ echo "LogicException: ".$e->getMessage()."\n";
+ }
+ try {
+ $fo = $o->openFile();
+ var_dump($fo->getPathName(), $fo->getFileName(), $fo->getPath());
+ } catch (LogicException $e) {
+ echo "LogicException: ".$e->getMessage()."\n";
+ }
+}
+
+test(dirname(__FILE__) . '/' . 'fileobject_001a.txt', 't', substr(dirname(__FILE__),-1));
+test(dirname(__FILE__) . '/', substr(dirname(__FILE__),-1), 'l');
+test(dirname(__FILE__), substr(dirname(__FILE__),-1), 'l');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===0===
+object(SplFileInfo)#%d (2) {
+ ["pathName":"SplFileInfo":private]=>
+ string(%d) "%s"
+ ["fileName":"SplFileInfo":private]=>
+ string(%d) "fileobject_001a.txt"
+}
+object(SplFileInfo)#%d (2) {
+ ["pathName":"SplFileInfo":private]=>
+ string(%d) "%s"
+ ["fileName":"SplFileInfo":private]=>
+ string(%d) "fileobject_001a.txt"
+}
+bool(false)
+bool(true)
+bool(true)
+%s(%d) "%sfileobject_001a.txt"
+string(%d) "%sfileobject_001a.txt"
+bool(true)
+string(19) "fileobject_001a.txt"
+bool(true)
+string(%d) "%stests"
+bool(true)
+string(%d) "%sfileobject_001a.txt"
+string(19) "fileobject_001a.txt"
+string(%d) "%stests"
+===1===
+object(SplFileInfo)#%d (2) {
+ ["pathName":"SplFileInfo":private]=>
+ string(%d) "%s"
+ ["fileName":"SplFileInfo":private]=>
+ string(%d) "%s"
+}
+object(SplFileInfo)#%d (2) {
+ ["pathName":"SplFileInfo":private]=>
+ string(%d) "%s"
+ ["fileName":"SplFileInfo":private]=>
+ string(%d) "%s"
+}
+bool(false)
+bool(true)
+bool(true)
+LogicException: Cannot use SplFileObject with directories
+LogicException: Cannot use SplFileObject with directories
+===2===
+object(SplFileInfo)#%d (2) {
+ ["pathName":"SplFileInfo":private]=>
+ string(%d) "%s"
+ ["fileName":"SplFileInfo":private]=>
+ string(%d) "%s"
+}
+object(SplFileInfo)#%d (2) {
+ ["pathName":"SplFileInfo":private]=>
+ string(%d) "%s"
+ ["fileName":"SplFileInfo":private]=>
+ string(%d) "%s"
+}
+bool(false)
+bool(true)
+bool(true)
+LogicException: Cannot use SplFileObject with directories
+LogicException: Cannot use SplFileObject with directories
+===DONE===
diff --git a/ext/spl/tests/fileobject_004.phpt b/ext/spl/tests/fileobject_004.phpt
new file mode 100644
index 0000000..02e6725
--- /dev/null
+++ b/ext/spl/tests/fileobject_004.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplFileObject realpath and include_path
+--FILE--
+<?php
+
+set_include_path('tests');
+
+chdir(dirname(dirname(__FILE__))); // ext/spl
+
+
+$fo = new SplFileObject('fileobject_004.phpt', 'r', true);
+
+var_dump($fo->getPath());
+var_dump($fo->getFilename());
+var_dump($fo->getRealPath());
+?>
+==DONE==
+--EXPECTF--
+string(%d) "%sspl%stests"
+string(19) "fileobject_004.phpt"
+string(%d) "%sspl%stests%sfileobject_004.phpt"
+==DONE==
diff --git a/ext/spl/tests/fileobject_005.phpt b/ext/spl/tests/fileobject_005.phpt
new file mode 100644
index 0000000..fa9e6db
--- /dev/null
+++ b/ext/spl/tests/fileobject_005.phpt
@@ -0,0 +1,42 @@
+--TEST--
+SPL: SplFileObject truncate tests
+--CREDITS--
+Mark Ammann
+#Hackday Webtuesday 2008-05-24
+--FILE--
+<?php
+
+set_include_path(dirname(dirname(__FILE__)));
+
+$path = dirname(__FILE__).DIRECTORY_SEPARATOR.'fileobject_005.txt';
+touch($path);
+
+$fo = new SplFileObject('tests'.DIRECTORY_SEPARATOR.'fileobject_005.txt', 'w+', true);
+$fo->fwrite("blahlubba");
+var_dump($fo->ftruncate(4));
+
+$fo->rewind();
+var_dump($fo->fgets(8));
+
+$fo->rewind();
+$fo->fwrite("blahlubba");
+
+// This should throw a warning and return NULL since an argument is missing
+var_dump($fo->ftruncate());
+
+?>
+==DONE==
+--CLEAN--
+<?php
+$path = dirname(__FILE__).DIRECTORY_SEPARATOR.'fileobject_005.txt';
+unlink($path);
+?>
+--EXPECTF--
+bool(true)
+
+Warning: SplFileObject::fgets() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: SplFileObject::ftruncate() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+==DONE== \ No newline at end of file
diff --git a/ext/spl/tests/fileobject_checktype_basic.phpt b/ext/spl/tests/fileobject_checktype_basic.phpt
new file mode 100644
index 0000000..650204e
--- /dev/null
+++ b/ext/spl/tests/fileobject_checktype_basic.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: SplFileObject::isFile/isDir/isLink
+--CREDITS--
+H�vard Eide <nucleuz at gmail.com>
+#Testfest php.no
+--FILE--
+<?php
+$s = new SplFileObject(__FILE__);
+var_dump($s->isFile());
+var_dump($s->isDir());
+var_dump($s->isLink());
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(false)
diff --git a/ext/spl/tests/fileobject_getbasename_basic.phpt b/ext/spl/tests/fileobject_getbasename_basic.phpt
new file mode 100644
index 0000000..34fecdc
--- /dev/null
+++ b/ext/spl/tests/fileobject_getbasename_basic.phpt
@@ -0,0 +1,13 @@
+--TEST--
+SPL: SplFileObject::getBasename
+--CREDITS--
+H�vard Eide <nucleuz at gmail.com>
+#Testfest php.no
+--FILE--
+<?php
+$file = __FILE__;
+$s = new SplFileObject( __FILE__ );
+echo $s->getBasename();
+?>
+--EXPECT--
+fileobject_getbasename_basic.php
diff --git a/ext/spl/tests/fileobject_getcurrentline_basic.phpt b/ext/spl/tests/fileobject_getcurrentline_basic.phpt
new file mode 100644
index 0000000..607fce6
--- /dev/null
+++ b/ext/spl/tests/fileobject_getcurrentline_basic.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: SplFileObject::getCurrentLine
+--CREDITS--
+H�vard Eide <nucleuz at gmail.com>
+#Testfest php.no
+--FILE--
+<?php
+//line 2
+//line 3
+//line 4
+//line 5
+$s = new SplFileObject(__FILE__);
+$s->seek(1);
+echo $s->getCurrentLine();
+echo $s->getCurrentLine();
+?>
+--EXPECT--
+//line 3
+//line 4
diff --git a/ext/spl/tests/fileobject_getfileinfo_basic.phpt b/ext/spl/tests/fileobject_getfileinfo_basic.phpt
new file mode 100644
index 0000000..97d0de2
--- /dev/null
+++ b/ext/spl/tests/fileobject_getfileinfo_basic.phpt
@@ -0,0 +1,44 @@
+--TEST--
+SPL: SplFileObject::getFileInfo
+--CREDITS--
+H�vard Eide <nucleuz at gmail.com>
+#Testfest php.no
+--INI--
+include_path=.
+--FILE--
+<?php
+$file = __FILE__;
+$s = new SplFileObject( $file );
+var_dump($fi = $s->getFileInfo(), (string)$fi);
+
+$d = new SplFileInfo( __DIR__ );
+echo "\n";
+var_dump($fi = $d->getFileInfo(), (string)$fi);
+$d = new SplFileInfo( __DIR__."/" );
+echo "\n";
+var_dump($fi = $d->getFileInfo(), (string)$fi);
+?>
+--EXPECTF--
+object(SplFileInfo)#%d (2) {
+ ["pathName":"SplFileInfo":private]=>
+ string(%d) "%sext%espl%etests%efileobject_getfileinfo_basic.php"
+ ["fileName":"SplFileInfo":private]=>
+ string(%d) "fileobject_getfileinfo_basic.php"
+}
+string(%d) "%sext%espl%etests%efileobject_getfileinfo_basic.php"
+
+object(SplFileInfo)#%d (2) {
+ ["pathName":"SplFileInfo":private]=>
+ string(%d) "%sext%espl%etests"
+ ["fileName":"SplFileInfo":private]=>
+ string(%d) "tests"
+}
+string(%d) "%sext%espl%etests"
+
+object(SplFileInfo)#%d (2) {
+ ["pathName":"SplFileInfo":private]=>
+ string(%d) "%sext%espl%etests"
+ ["fileName":"SplFileInfo":private]=>
+ string(%d) "tests"
+}
+string(%d) "%sext%espl%etests"
diff --git a/ext/spl/tests/fileobject_getmaxlinelen_basic.phpt b/ext/spl/tests/fileobject_getmaxlinelen_basic.phpt
new file mode 100644
index 0000000..b08a711
--- /dev/null
+++ b/ext/spl/tests/fileobject_getmaxlinelen_basic.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: SplFileObject::getMaxLineLen()
+--CREDITS--
+H�vard Eide <nucleuz at gmail.com>
+#Testfest php.no
+--INI--
+include_path=.
+--FILE--
+<?php
+$s = new SplFileObject( __FILE__ );
+$s->setMaxLineLen( 7 );
+echo $s->getMaxLineLen();
+?>
+--EXPECT--
+7
diff --git a/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt b/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt
new file mode 100644
index 0000000..3c0c9ee
--- /dev/null
+++ b/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SPL: SplFileObject::getMaxLineLen error 001
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--INI--
+include_path=.
+--FILE--
+<?php
+$s = new SplFileObject( __FILE__ );
+$s->getMaxLineLen('string');
+
+?>
+--EXPECTF--
+Warning: SplFileObject::getMaxLineLen() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/fileobject_getsize_basic.phpt b/ext/spl/tests/fileobject_getsize_basic.phpt
new file mode 100644
index 0000000..da9f708
--- /dev/null
+++ b/ext/spl/tests/fileobject_getsize_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplFileObject::getSize
+--CREDITS--
+H�vard Eide <nucleuz at gmail.com>
+#Testfest php.no
+--INI--
+include_path=.
+--FILE--
+<?php
+$file = __DIR__ ."/data.txt";
+file_put_contents($file, "foobar");
+
+$s = new SplFileObject( $file );
+echo $s->getSize();
+?>
+--CLEAN--
+<?php
+$file = __DIR__ ."/data.txt";
+unlink($file);
+?>
+--EXPECT--
+6
diff --git a/ext/spl/tests/fileobject_setmaxlinelen_basic.phpt b/ext/spl/tests/fileobject_setmaxlinelen_basic.phpt
new file mode 100644
index 0000000..c230766
--- /dev/null
+++ b/ext/spl/tests/fileobject_setmaxlinelen_basic.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: SplFileObject::setMaxLineLen
+--CREDITS--
+H�vard Eide <nucleuz at gmail.com>
+#Testfest php.no
+--INI--
+include_path=.
+--FILE--
+<?php
+$s = new SplFileObject( __FILE__ );
+$s->setMaxLineLen( 3);
+echo $s->getCurrentLine();
+?>
+--EXPECT--
+<?
diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt
new file mode 100644
index 0000000..6bfdfdc
--- /dev/null
+++ b/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: SplFileObject::setMaxLineLen error 001()
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--FILE--
+<?php
+$s = new SplFileObject( __FILE__ );
+try {
+ $s->setMaxLineLen(-1);
+}
+catch (DomainException $e) {
+ echo 'DomainException thrown';
+}
+
+?>
+--EXPECT--
+DomainException thrown
diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt
new file mode 100644
index 0000000..dad59fc
--- /dev/null
+++ b/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplFileObject::setMaxLineLen error 002
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--FILE--
+<?php
+$s = new SplFileObject( __FILE__ );
+$s->setMaxLineLen();
+
+?>
+--EXPECTF--
+Warning: SplFileObject::setMaxLineLen() expects exactly 1 parameter, 0 given in %s on line %d
diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt
new file mode 100644
index 0000000..8dc50d5
--- /dev/null
+++ b/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplFileObject::setMaxLineLen error 003
+--CREDITS--
+Erwin Poeze <erwin.poeze at gmail.com>
+--FILE--
+<?php
+$s = new SplFileObject( __FILE__ );
+$s->setMaxLineLen('string');
+
+?>
+--EXPECTF--
+Warning: SplFileObject::setMaxLineLen() expects parameter 1 to be long, string given in %s on line %d
diff --git a/ext/spl/tests/filesystemiterator_flags.phpt b/ext/spl/tests/filesystemiterator_flags.phpt
new file mode 100644
index 0000000..6353456
--- /dev/null
+++ b/ext/spl/tests/filesystemiterator_flags.phpt
@@ -0,0 +1,40 @@
+--TEST--
+SPL: FilesystemIterator::getFlags() basic tests
+--CREDITS--
+Joshua Thijssen <jthijssen@noxlogic.nl>
+--FILE--
+<?php
+
+$it = new FileSystemIterator(".");
+printflags($it);
+
+$it->setFlags(FileSystemIterator::CURRENT_AS_SELF |
+ FileSystemIterator::KEY_AS_FILENAME |
+ FileSystemIterator::SKIP_DOTS |
+ FileSystemIterator::UNIX_PATHS);
+printflags($it);
+
+$it->setFlags(-1);
+printflags($it);
+
+function printflags($it) {
+ printf("%08X\n", $it->getFlags());
+ printf("%08X\n", ($it->getFlags() & FileSystemIterator::CURRENT_MODE_MASK));
+ printf("%08X\n", ($it->getFlags() & FileSystemIterator::KEY_MODE_MASK));
+ printf("%08X\n", ($it->getFlags() & FileSystemIterator::OTHER_MODE_MASK));
+}
+
+?>
+--EXPECT--
+00001000
+00000000
+00000000
+00001000
+00003110
+00000010
+00000100
+00003000
+00003FF0
+000000F0
+00000F00
+00003000
diff --git a/ext/spl/tests/fixedarray_001.phpt b/ext/spl/tests/fixedarray_001.phpt
new file mode 100644
index 0000000..8276333
--- /dev/null
+++ b/ext/spl/tests/fixedarray_001.phpt
@@ -0,0 +1,60 @@
+--TEST--
+SPL: FixedArray: std operations
+--FILE--
+<?php
+$a = new SplFixedArray(0);
+// errors
+try {
+ $a[0] = "value1";
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ var_dump($a["asdf"]);
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ unset($a[-1]);
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+$a->setSize(10);
+
+
+$a[0] = "value0";
+$a[1] = "value1";
+$a[2] = "value2";
+$a[3] = "value3";
+$ref = "value4";
+$ref2 =&$ref;
+$a[4] = $ref;
+$ref = "value5";
+
+unset($a[1]);
+
+var_dump($a[0], $a[2], $a[3], $a[4]);
+
+// countable
+
+var_dump(count($a), $a->getSize(), count($a) == $a->getSize());
+
+// clonable
+$b = clone $a;
+$a[0] = "valueNew";
+var_dump($b[0]);
+?>
+===DONE===
+--EXPECTF--
+Exception: Index invalid or out of range
+Exception: Index invalid or out of range
+Exception: Index invalid or out of range
+string(6) "value0"
+string(6) "value2"
+string(6) "value3"
+string(6) "value4"
+int(10)
+int(10)
+bool(true)
+string(6) "value0"
+===DONE===
diff --git a/ext/spl/tests/fixedarray_002.phpt b/ext/spl/tests/fixedarray_002.phpt
new file mode 100644
index 0000000..534d41f
--- /dev/null
+++ b/ext/spl/tests/fixedarray_002.phpt
@@ -0,0 +1,100 @@
+--TEST--
+SPL: FixedArray: overloading
+--FILE--
+<?php
+class A extends SplFixedArray {
+ public function count() {
+ return 2;
+ }
+
+ public function offsetGet($n) {
+ echo "A::offsetGet\n";
+ return parent::offsetGet($n);
+ }
+ public function offsetSet($n, $v) {
+ echo "A::offsetSet\n";
+ return parent::offsetSet($n, $v);
+ }
+ public function offsetUnset($n) {
+ echo "A::offsetUnset\n";
+ return parent::offsetUnset($n);
+ }
+ public function offsetExists($n) {
+ echo "A::offsetExists\n";
+ return parent::offsetExists($n);
+ }
+}
+
+$a = new A;
+
+// errors
+try {
+ $a[0] = "value1";
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ var_dump($a["asdf"]);
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ unset($a[-1]);
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+$a->setSize(10);
+
+
+$a[0] = "value0";
+$a[1] = "value1";
+$a[2] = "value2";
+$a[3] = "value3";
+$ref = "value4";
+$ref2 =&$ref;
+$a[4] = $ref;
+$ref = "value5";
+
+unset($a[1]);
+var_dump(isset($a[1]), isset($a[2]), empty($a[1]), empty($a[2]));
+
+var_dump($a[0], $a[2], $a[3], $a[4]);
+
+// countable
+
+var_dump(count($a), $a->getSize(), count($a) == $a->getSize());
+?>
+===DONE===
+--EXPECTF--
+A::offsetSet
+Exception: Index invalid or out of range
+A::offsetGet
+Exception: Index invalid or out of range
+A::offsetUnset
+Exception: Index invalid or out of range
+A::offsetSet
+A::offsetSet
+A::offsetSet
+A::offsetSet
+A::offsetSet
+A::offsetUnset
+A::offsetExists
+A::offsetExists
+A::offsetExists
+A::offsetExists
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+A::offsetGet
+A::offsetGet
+A::offsetGet
+A::offsetGet
+string(6) "value0"
+string(6) "value2"
+string(6) "value3"
+string(6) "value4"
+int(2)
+int(10)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/fixedarray_003.phpt b/ext/spl/tests/fixedarray_003.phpt
new file mode 100644
index 0000000..b6c5eb5
--- /dev/null
+++ b/ext/spl/tests/fixedarray_003.phpt
@@ -0,0 +1,86 @@
+--TEST--
+SPL: FixedArray: Iterators
+--FILE--
+<?php
+class A extends SplFixedArray {
+
+ public function current() {
+ echo "A::current\n";
+ return parent::current();
+ }
+ public function key() {
+ echo "A::key\n";
+ return parent::key();
+ }
+ public function rewind() {
+ echo "A::rewind\n";
+ return parent::rewind();
+ }
+ public function valid() {
+ echo "A::valid\n";
+ return parent::valid();
+ }
+ public function next() {
+ echo "A::next\n";
+ return parent::next();
+ }
+}
+
+echo "==Direct instance==\n";
+$a = new SplFixedArray(5);
+$a[0] = "a";
+$a[1] = "c";
+$a[2] = "d";
+$a[3] = "e";
+$a[4] = "f";
+foreach ($a as $k => $v) {
+ echo "$k => $v\n";
+}
+echo "==Child instance==\n";
+$a = new A(5);
+$a[0] = "a";
+$a[1] = "c";
+$a[2] = "d";
+$a[3] = "e";
+$a[4] = "f";
+foreach ($a as $k => $v) {
+ echo "$k => $v\n";
+}
+?>
+===DONE===
+--EXPECTF--
+==Direct instance==
+0 => a
+1 => c
+2 => d
+3 => e
+4 => f
+==Child instance==
+A::rewind
+A::valid
+A::current
+A::key
+0 => a
+A::next
+A::valid
+A::current
+A::key
+1 => c
+A::next
+A::valid
+A::current
+A::key
+2 => d
+A::next
+A::valid
+A::current
+A::key
+3 => e
+A::next
+A::valid
+A::current
+A::key
+4 => f
+A::next
+A::valid
+===DONE===
diff --git a/ext/spl/tests/fixedarray_004.phpt b/ext/spl/tests/fixedarray_004.phpt
new file mode 100644
index 0000000..cb62e0c
--- /dev/null
+++ b/ext/spl/tests/fixedarray_004.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SPL: FixedArray: adding new elements
+--FILE--
+<?php
+
+$a = new SplFixedArray(10);
+
+try {
+ $a[] = 1;
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+?>
+===DONE===
+--EXPECTF--
+string(29) "Index invalid or out of range"
+===DONE===
diff --git a/ext/spl/tests/fixedarray_005.phpt b/ext/spl/tests/fixedarray_005.phpt
new file mode 100644
index 0000000..9ccc693
--- /dev/null
+++ b/ext/spl/tests/fixedarray_005.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: FixedArray: Trying to instantiate passing object to constructor parameter
+--FILE--
+<?php
+
+$b = new stdClass;
+
+$a = new SplFixedArray($b);
+
+?>
+--EXPECTF--
+Warning: SplFixedArray::__construct() expects parameter 1 to be long, object given in %s on line %d
diff --git a/ext/spl/tests/fixedarray_006.phpt b/ext/spl/tests/fixedarray_006.phpt
new file mode 100644
index 0000000..8641821
--- /dev/null
+++ b/ext/spl/tests/fixedarray_006.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: FixedArray: Assigning objects
+--FILE--
+<?php
+
+$b = 10000;
+$a = new SplFixedArray($b);
+
+try {
+ for ($i = 0; $i < 100; $i++) {
+ $a[] = new stdClass;
+ }
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+print "ok\n";
+
+?>
+--EXPECT--
+Index invalid or out of range
+ok
diff --git a/ext/spl/tests/fixedarray_007.phpt b/ext/spl/tests/fixedarray_007.phpt
new file mode 100644
index 0000000..308ce31
--- /dev/null
+++ b/ext/spl/tests/fixedarray_007.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SPL: FixedArray: Assigning the itself object
+--FILE--
+<?php
+
+$b = 10;
+$a = new SplFixedArray($b);
+
+try {
+ $a[1] = $a;
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+foreach ($a as $c) {
+ if ($c) {
+ echo $c->getSize(), "\n";
+ }
+}
+
+print "ok\n";
+
+?>
+--EXPECT--
+10
+ok
diff --git a/ext/spl/tests/fixedarray_008.phpt b/ext/spl/tests/fixedarray_008.phpt
new file mode 100644
index 0000000..8775d61
--- /dev/null
+++ b/ext/spl/tests/fixedarray_008.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: FixedArray: Assigning the itself object testing the reference
+--FILE--
+<?php
+
+$b = 3;
+$a = new SplFixedArray($b);
+
+$a[0] = 1;
+$a[1] = 2;
+$a[2] = $a;
+
+$a[2][0] = 3;
+
+foreach ($a as $x) {
+ if (is_object($x)) {
+ var_dump($x[0]);
+ } else {
+ var_dump($x);
+ }
+}
+
+var_dump($a->getSize());
+
+?>
+--EXPECT--
+int(3)
+int(2)
+int(3)
+int(3)
diff --git a/ext/spl/tests/fixedarray_009.phpt b/ext/spl/tests/fixedarray_009.phpt
new file mode 100644
index 0000000..936d210
--- /dev/null
+++ b/ext/spl/tests/fixedarray_009.phpt
@@ -0,0 +1,10 @@
+--TEST--
+SPL: FixedArray: Trying to instantiate passing string to construtor parameter
+--FILE--
+<?php
+
+$a = new SplFixedArray('FOO');
+
+?>
+--EXPECTF--
+Warning: SplFixedArray::__construct() expects parameter 1 to be long, string given in %s on line %d
diff --git a/ext/spl/tests/fixedarray_010.phpt b/ext/spl/tests/fixedarray_010.phpt
new file mode 100644
index 0000000..472e8b0
--- /dev/null
+++ b/ext/spl/tests/fixedarray_010.phpt
@@ -0,0 +1,50 @@
+--TEST--
+SPL: FixedArray: Setting size
+--FILE--
+<?php
+
+$a = new SplFixedArray(0);
+$a = new SplFixedArray(3);
+
+$a[0] = 1;
+
+$a->setSize(2);
+$a->setSize(3);
+$a->setSize(0);
+
+$a = new SplFixedArray(0);
+$a->setSize(0);
+var_dump($a->getSize());
+
+$a = new SplFixedArray(10);
+$a->setSize(10);
+var_dump($a->getSize());
+
+$a = new SplFixedArray(1);
+$a->setSize(5);
+var_dump($a->getSize());
+
+$a = new SplFixedArray(20);
+$a->setSize(3);
+var_dump($a->getSize());
+
+$a = new SplFixedArray(3);
+
+$a[0] = "test";
+$a[1] = array(1,2,"blah");
+$a[2] = 1;
+$a[0] = "test";
+
+$a->setSize(0);
+var_dump($a->getSize());
+
+print "ok\n";
+
+?>
+--EXPECT--
+int(0)
+int(10)
+int(5)
+int(3)
+int(0)
+ok
diff --git a/ext/spl/tests/fixedarray_011.phpt b/ext/spl/tests/fixedarray_011.phpt
new file mode 100644
index 0000000..eddf320
--- /dev/null
+++ b/ext/spl/tests/fixedarray_011.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SPL: FixedArray: Testing setSize() with NULL
+--FILE--
+<?php
+
+$a = new SplFixedArray(100);
+
+$a->setSize(NULL);
+
+print "ok\n";
+
+?>
+--EXPECT--
+ok
diff --git a/ext/spl/tests/fixedarray_012.phpt b/ext/spl/tests/fixedarray_012.phpt
new file mode 100644
index 0000000..3461b3a
--- /dev/null
+++ b/ext/spl/tests/fixedarray_012.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: FixedArray: Assigning the object to another variable using []
+--FILE--
+<?php
+
+$a = new SplFixedArray(100);
+
+try {
+ $b = &$a[];
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+print "ok\n";
+
+?>
+--EXPECT--
+Index invalid or out of range
+ok
diff --git a/ext/spl/tests/fixedarray_013.phpt b/ext/spl/tests/fixedarray_013.phpt
new file mode 100644
index 0000000..52ae3c1
--- /dev/null
+++ b/ext/spl/tests/fixedarray_013.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: FixedArray: Passing the object using [] as parameter
+--FILE--
+<?php
+
+$a = new SplFixedArray(100);
+
+
+function test(SplFixedArray &$arr) {
+ print "ok\n";
+}
+
+try {
+ test($a[]);
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Index invalid or out of range
diff --git a/ext/spl/tests/fixedarray_014.phpt b/ext/spl/tests/fixedarray_014.phpt
new file mode 100644
index 0000000..de8e214
--- /dev/null
+++ b/ext/spl/tests/fixedarray_014.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: FixedArray: Trying to access inexistent item
+--FILE--
+<?php
+
+try {
+ $a = new SplFixedArray(NULL);
+ echo $a[0]++;
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECT--
+Index invalid or out of range
diff --git a/ext/spl/tests/fixedarray_015.phpt b/ext/spl/tests/fixedarray_015.phpt
new file mode 100644
index 0000000..60fc4d1
--- /dev/null
+++ b/ext/spl/tests/fixedarray_015.phpt
@@ -0,0 +1,49 @@
+--TEST--
+SPL: FixedArray: accessing uninitialized array
+--FILE--
+<?php
+
+$a = new SplFixedArray('');
+
+try {
+ var_dump($a[1]);
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ $a[1] = 1;
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ var_dump(count($a[1]));
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ var_dump($a->getSize());
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ foreach ($a as $v) {
+ }
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ var_dump($a->setSize(10));
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: SplFixedArray::__construct() expects parameter 1 to be long, string given in %s on line %d
+Index invalid or out of range
+Index invalid or out of range
+Index invalid or out of range
+int(0)
+bool(true)
+Done
diff --git a/ext/spl/tests/fixedarray_016.phpt b/ext/spl/tests/fixedarray_016.phpt
new file mode 100644
index 0000000..fb61ee3
--- /dev/null
+++ b/ext/spl/tests/fixedarray_016.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: FixedArray: var_dump
+--FILE--
+<?php
+$a = new SplFixedArray(2);
+$a[0] = "foo";
+var_dump(empty($a[0]), empty($a[1]), $a);
+?>
+--EXPECTF--
+bool(false)
+bool(true)
+object(SplFixedArray)#%d (2) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ NULL
+}
diff --git a/ext/spl/tests/fixedarray_017.phpt b/ext/spl/tests/fixedarray_017.phpt
new file mode 100644
index 0000000..fb61ee3
--- /dev/null
+++ b/ext/spl/tests/fixedarray_017.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: FixedArray: var_dump
+--FILE--
+<?php
+$a = new SplFixedArray(2);
+$a[0] = "foo";
+var_dump(empty($a[0]), empty($a[1]), $a);
+?>
+--EXPECTF--
+bool(false)
+bool(true)
+object(SplFixedArray)#%d (2) {
+ [0]=>
+ string(3) "foo"
+ [1]=>
+ NULL
+}
diff --git a/ext/spl/tests/fixedarray_018.phpt b/ext/spl/tests/fixedarray_018.phpt
new file mode 100644
index 0000000..84ab109
--- /dev/null
+++ b/ext/spl/tests/fixedarray_018.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: FixedArray: overriden count()
+--FILE--
+<?php
+$obj = new SplFixedArray(2);
+var_dump(count($obj));
+class SplFixedArray2 extends SplFixedArray {
+ public function count() {
+ return -parent::count();
+ }
+}
+$obj = new SplFixedArray2(2);
+var_dump(count($obj));
+?>
+--EXPECT--
+int(2)
+int(-2)
diff --git a/ext/spl/tests/fixedarray_019.phpt b/ext/spl/tests/fixedarray_019.phpt
new file mode 100644
index 0000000..f28edfd
--- /dev/null
+++ b/ext/spl/tests/fixedarray_019.phpt
@@ -0,0 +1,51 @@
+--TEST--
+SPL: FixedArray: overriden iterator methods
+--FILE--
+<?php
+class SplFixedArray2 extends SplFixedArray {
+ public function rewind() {
+ echo "rewind\n";
+ return parent::rewind();
+ }
+ public function valid() {
+ echo "valid\n";
+ return parent::valid();
+ }
+ public function next() {
+ echo "next\n";
+ return parent::next();
+ }
+ public function current() {
+ echo "current\n";
+ return parent::current();
+ }
+ public function key() {
+ echo "key\n";
+ return parent::key();
+ }
+}
+
+$fa = new SplFixedArray2(3);
+foreach($fa as $k=>$v) {
+ echo "$k=>";
+ var_dump($v);
+}
+?>
+--EXPECT--
+rewind
+valid
+current
+key
+0=>NULL
+next
+valid
+current
+key
+1=>NULL
+next
+valid
+current
+key
+2=>NULL
+next
+valid
diff --git a/ext/spl/tests/fixedarray_020.phpt b/ext/spl/tests/fixedarray_020.phpt
new file mode 100644
index 0000000..c0ff6e3
--- /dev/null
+++ b/ext/spl/tests/fixedarray_020.phpt
@@ -0,0 +1,36 @@
+--TEST--
+SPL: FixedArray: fromArray/toArray + get_properties
+--FILE--
+<?php
+$a = array(1=>'foo', 2=>'bar', 0=>'gee');
+$fa = SplFixedArray::fromArray($a, false);
+var_dump(count($fa), $fa->toArray() === array_values($a));
+
+$fa = SplFixedArray::fromArray($a, true);
+var_dump(count($fa), $fa->toArray() === $a, $fa->toArray() === (array)$fa);
+
+try {
+ echo "From Array with string keys, no preserve\n";
+ SplFixedArray::fromArray(array("foo"=>"bar"), false);
+ echo "No exception\n";
+} catch (Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ echo "From Array with string keys, preserve\n";
+ SplFixedArray::fromArray(array("foo"=>"bar"), true);
+ echo "No exception\n";
+} catch (Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+?>
+--EXPECT--
+int(3)
+bool(true)
+int(3)
+bool(false)
+bool(true)
+From Array with string keys, no preserve
+No exception
+From Array with string keys, preserve
+Exception: array must contain only positive integer keys
diff --git a/ext/spl/tests/fixedarray_021.phpt b/ext/spl/tests/fixedarray_021.phpt
new file mode 100644
index 0000000..97b0a70
--- /dev/null
+++ b/ext/spl/tests/fixedarray_021.phpt
@@ -0,0 +1,78 @@
+--TEST--
+SPL: FixedArray: misc small tests
+--FILE--
+<?php
+
+/* empty count */
+$a = new SplFixedArray();
+
+var_dump(count($a));
+var_dump($a->count());
+
+/* negative init value */
+try {
+ $b = new SplFixedArray(-10);
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+/* resize and negative value */
+$b = new SplFixedArray();
+try {
+ $b->setSize(-5);
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+/* calling __construct() twice */
+$c = new SplFixedArray(0);
+var_dump($c->__construct());
+
+/* fromArray() from empty array */
+$d = new SplFixedArray();
+$d->fromArray(array());
+
+var_dump(count($a));
+var_dump($a->count());
+var_dump($a);
+
+/* foreach by ref */
+$e = new SplFixedArray(10);
+$e[0] = 1;
+$e[1] = 5;
+$e[2] = 10;
+
+try {
+ foreach ($e as $k=>&$v) {
+ var_dump($v);
+ }
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+}
+
+//non-long indexes
+$a = new SplFixedArray(4);
+$a["2"] = "foo";
+$a["1"] = "foo";
+$a["3"] = "0";
+
+var_dump(isset($a["0"], $a[-1]), $a["1"]);
+var_dump(empty($a["3"]));
+
+?>
+==DONE==
+--EXPECTF--
+int(0)
+int(0)
+string(35) "array size cannot be less than zero"
+string(35) "array size cannot be less than zero"
+NULL
+int(0)
+int(0)
+object(SplFixedArray)#%d (0) {
+}
+string(52) "An iterator cannot be used with foreach by reference"
+bool(false)
+string(3) "foo"
+bool(true)
+==DONE==
diff --git a/ext/spl/tests/heap_001.phpt b/ext/spl/tests/heap_001.phpt
new file mode 100644
index 0000000..da4dde8
--- /dev/null
+++ b/ext/spl/tests/heap_001.phpt
@@ -0,0 +1,53 @@
+--TEST--
+SPL: SplMaxHeap: std operations
+--FILE--
+<?php
+$h = new SplMaxHeap();
+
+// errors
+try {
+ $h->extract();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+
+$h->insert(1);
+$h->insert(2);
+$h->insert(3);
+$h->insert(3);
+$h->insert(3);
+
+echo $h->count()."\n";
+echo $h->extract()."\n";
+echo $h->extract()."\n";
+echo $h->extract()."\n";
+echo $h->extract()."\n";
+echo $h->extract()."\n";
+echo $h->count()."\n";
+
+echo "--\n";
+
+$b = 4;
+$h->insert($b);
+$b = 5;
+
+$h2 = clone $h;
+echo $h->extract()."\n";
+echo $h2->extract()."\n";
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Exception: Can't extract from an empty heap
+5
+3
+3
+3
+2
+1
+0
+--
+4
+4
+===DONE===
diff --git a/ext/spl/tests/heap_002.phpt b/ext/spl/tests/heap_002.phpt
new file mode 100644
index 0000000..387510f
--- /dev/null
+++ b/ext/spl/tests/heap_002.phpt
@@ -0,0 +1,50 @@
+--TEST--
+SPL: SplMinHeap: std operations
+--FILE--
+<?php
+$h = new SplMinHeap();
+
+// errors
+try {
+ $h->extract();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+
+$h->insert(1);
+$h->insert(2);
+$h->insert(3);
+$h->insert(3);
+$h->insert(3);
+
+echo $h->count()."\n";
+echo $h->extract()."\n";
+echo $h->extract()."\n";
+echo $h->extract()."\n";
+echo $h->extract()."\n";
+echo $h->extract()."\n";
+echo $h->count()."\n";
+
+echo "--\n";
+
+$b = 4;
+$h->insert($b);
+$b = 5;
+
+echo $h->extract()."\n";
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Exception: Can't extract from an empty heap
+5
+1
+2
+3
+3
+3
+0
+--
+4
+===DONE===
diff --git a/ext/spl/tests/heap_003.phpt b/ext/spl/tests/heap_003.phpt
new file mode 100644
index 0000000..87f95e9
--- /dev/null
+++ b/ext/spl/tests/heap_003.phpt
@@ -0,0 +1,44 @@
+--TEST--
+SPL: SplHeap: comparison callback
+--FILE--
+<?php
+class myHeap extends SplHeap {
+ public function compare($a, $b) {
+ if ($a > $b) {
+ $result = 1;
+ } else if ($a < $b) {
+ $result = -1;
+ } else {
+ $result = 0;
+ }
+ return $result;
+ }
+}
+
+$h = new myHeap;
+
+$in = range(0,10);
+shuffle($in);
+foreach ($in as $i) {
+ $h->insert($i);
+}
+
+foreach ($h as $out) {
+ echo $out."\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+10
+9
+8
+7
+6
+5
+4
+3
+2
+1
+0
+===DONE===
diff --git a/ext/spl/tests/heap_004.phpt b/ext/spl/tests/heap_004.phpt
new file mode 100644
index 0000000..7b00ebf
--- /dev/null
+++ b/ext/spl/tests/heap_004.phpt
@@ -0,0 +1,67 @@
+--TEST--
+SPL: SplHeap: exceptions
+--FILE--
+<?php
+class myHeap extends SplHeap {
+ public function compare($a, $b) {
+ throw new exception("foo");
+ }
+}
+
+$h = new myHeap;
+
+try {
+ $h->insert(1);
+ echo "inserted 1\n";
+ $h->insert(2);
+ echo "inserted 2\n";
+ $h->insert(3);
+ echo "inserted 3\n";
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+try {
+ $h->insert(4);
+ echo "inserted 4\n";
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+try {
+ var_dump($h->extract());
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ var_dump($h->extract());
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+echo "Recovering..\n";
+$h->recoverFromCorruption();
+
+try {
+ var_dump($h->extract());
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ var_dump($h->extract());
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+inserted 1
+Exception: foo
+Exception: Heap is corrupted, heap properties are no longer ensured.
+Exception: Heap is corrupted, heap properties are no longer ensured.
+Exception: Heap is corrupted, heap properties are no longer ensured.
+Recovering..
+int(1)
+int(2)
+===DONE===
diff --git a/ext/spl/tests/heap_005.phpt b/ext/spl/tests/heap_005.phpt
new file mode 100644
index 0000000..1291cda
--- /dev/null
+++ b/ext/spl/tests/heap_005.phpt
@@ -0,0 +1,121 @@
+--TEST--
+SPL: SplMinHeap: large unordered input iterated
+--FILE--
+<?php
+$input = range(1,100);
+shuffle($input);
+
+$h = new SplMinHeap();
+
+foreach($input as $i) {
+ $h->insert($i);
+}
+
+foreach ($h as $k => $o) {
+ echo "$k => $o\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+99 => 1
+98 => 2
+97 => 3
+96 => 4
+95 => 5
+94 => 6
+93 => 7
+92 => 8
+91 => 9
+90 => 10
+89 => 11
+88 => 12
+87 => 13
+86 => 14
+85 => 15
+84 => 16
+83 => 17
+82 => 18
+81 => 19
+80 => 20
+79 => 21
+78 => 22
+77 => 23
+76 => 24
+75 => 25
+74 => 26
+73 => 27
+72 => 28
+71 => 29
+70 => 30
+69 => 31
+68 => 32
+67 => 33
+66 => 34
+65 => 35
+64 => 36
+63 => 37
+62 => 38
+61 => 39
+60 => 40
+59 => 41
+58 => 42
+57 => 43
+56 => 44
+55 => 45
+54 => 46
+53 => 47
+52 => 48
+51 => 49
+50 => 50
+49 => 51
+48 => 52
+47 => 53
+46 => 54
+45 => 55
+44 => 56
+43 => 57
+42 => 58
+41 => 59
+40 => 60
+39 => 61
+38 => 62
+37 => 63
+36 => 64
+35 => 65
+34 => 66
+33 => 67
+32 => 68
+31 => 69
+30 => 70
+29 => 71
+28 => 72
+27 => 73
+26 => 74
+25 => 75
+24 => 76
+23 => 77
+22 => 78
+21 => 79
+20 => 80
+19 => 81
+18 => 82
+17 => 83
+16 => 84
+15 => 85
+14 => 86
+13 => 87
+12 => 88
+11 => 89
+10 => 90
+9 => 91
+8 => 92
+7 => 93
+6 => 94
+5 => 95
+4 => 96
+3 => 97
+2 => 98
+1 => 99
+0 => 100
+===DONE===
diff --git a/ext/spl/tests/heap_006.phpt b/ext/spl/tests/heap_006.phpt
new file mode 100644
index 0000000..3218bdf
--- /dev/null
+++ b/ext/spl/tests/heap_006.phpt
@@ -0,0 +1,121 @@
+--TEST--
+SPL: SplMaxHeap: large unordered input iterated
+--FILE--
+<?php
+$input = range(1,100);
+shuffle($input);
+
+$h = new SplMaxHeap();
+
+foreach($input as $i) {
+ $h->insert($i);
+}
+
+foreach ($h as $k => $o) {
+ echo "$k => $o\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+99 => 100
+98 => 99
+97 => 98
+96 => 97
+95 => 96
+94 => 95
+93 => 94
+92 => 93
+91 => 92
+90 => 91
+89 => 90
+88 => 89
+87 => 88
+86 => 87
+85 => 86
+84 => 85
+83 => 84
+82 => 83
+81 => 82
+80 => 81
+79 => 80
+78 => 79
+77 => 78
+76 => 77
+75 => 76
+74 => 75
+73 => 74
+72 => 73
+71 => 72
+70 => 71
+69 => 70
+68 => 69
+67 => 68
+66 => 67
+65 => 66
+64 => 65
+63 => 64
+62 => 63
+61 => 62
+60 => 61
+59 => 60
+58 => 59
+57 => 58
+56 => 57
+55 => 56
+54 => 55
+53 => 54
+52 => 53
+51 => 52
+50 => 51
+49 => 50
+48 => 49
+47 => 48
+46 => 47
+45 => 46
+44 => 45
+43 => 44
+42 => 43
+41 => 42
+40 => 41
+39 => 40
+38 => 39
+37 => 38
+36 => 37
+35 => 36
+34 => 35
+33 => 34
+32 => 33
+31 => 32
+30 => 31
+29 => 30
+28 => 29
+27 => 28
+26 => 27
+25 => 26
+24 => 25
+23 => 24
+22 => 23
+21 => 22
+20 => 21
+19 => 20
+18 => 19
+17 => 18
+16 => 17
+15 => 16
+14 => 15
+13 => 14
+12 => 13
+11 => 12
+10 => 11
+9 => 10
+8 => 9
+7 => 8
+6 => 7
+5 => 6
+4 => 5
+3 => 4
+2 => 3
+1 => 2
+0 => 1
+===DONE===
diff --git a/ext/spl/tests/heap_007.phpt b/ext/spl/tests/heap_007.phpt
new file mode 100644
index 0000000..e8d5c99
--- /dev/null
+++ b/ext/spl/tests/heap_007.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: SplHeap: iteration through methods
+--FILE--
+<?php
+$h = new SplMaxHeap();
+
+$h->insert(1);
+$h->insert(5);
+$h->insert(0);
+$h->insert(4);
+
+$h->rewind();
+echo "count(\$h) = ".count($h)."\n";
+echo "\$h->count() = ".$h->count()."\n";
+
+while ($h->valid()) {
+ $k = $h->key();
+ $v = $h->current();
+ echo "$k=>$v\n";
+ $h->next();
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+count($h) = 4
+$h->count() = 4
+3=>5
+2=>4
+1=>1
+0=>0
+===DONE===
diff --git a/ext/spl/tests/heap_008.phpt b/ext/spl/tests/heap_008.phpt
new file mode 100644
index 0000000..178f546
--- /dev/null
+++ b/ext/spl/tests/heap_008.phpt
@@ -0,0 +1,34 @@
+--TEST--
+SPL: SplHeap: var_dump
+--FILE--
+<?php
+$h = new SplMaxHeap();
+
+$h->insert(1);
+$h->insert(5);
+$h->insert(0);
+$h->insert(4);
+
+var_dump($h);
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+object(SplMaxHeap)#1 (3) {
+ ["flags":"SplHeap":private]=>
+ int(0)
+ ["isCorrupted":"SplHeap":private]=>
+ bool(false)
+ ["heap":"SplHeap":private]=>
+ array(4) {
+ [0]=>
+ int(5)
+ [1]=>
+ int(4)
+ [2]=>
+ int(0)
+ [3]=>
+ int(1)
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/heap_009.phpt b/ext/spl/tests/heap_009.phpt
new file mode 100644
index 0000000..f660b24
--- /dev/null
+++ b/ext/spl/tests/heap_009.phpt
@@ -0,0 +1,56 @@
+--TEST--
+SPL: SplHeap and friends, throw: An iterator cannot be used with foreach by reference
+--CREDITS--
+Thomas Koch <thomas@koch.ro>
+#Hackday Webtuesday 2008-05-24
+--FILE--
+<?php
+function testForException( $heap )
+{
+ try
+ {
+ foreach( $heap as &$item );
+ }
+ catch( RuntimeException $e )
+ {
+ echo $e->getMessage(),"\n";
+ }
+}
+
+// 1. SplMinHeap emtpy
+$heap = new SplMinHeap;
+testForException( $heap );
+
+// 2. SplMinHeap non-emtpy
+$heap = new SplMinHeap;
+$heap->insert( 1 );
+testForException( $heap );
+
+// 3. SplMaxHeap emtpy
+$heap = new SplMaxHeap;
+testForException( $heap );
+
+// 4. SplMaxHeap non-emtpy
+$heap = new SplMaxHeap;
+$heap->insert( 1 );
+testForException( $heap );
+
+// 5. SplPriorityQueue empty
+$heap = new SplPriorityQueue;
+testForException( $heap );
+
+// 6. SplPriorityQueue non-empty
+$heap = new SplPriorityQueue;
+$heap->insert( 1, 2 );
+testForException( $heap );
+
+?>
+==DONE==
+--EXPECT--
+An iterator cannot be used with foreach by reference
+An iterator cannot be used with foreach by reference
+An iterator cannot be used with foreach by reference
+An iterator cannot be used with foreach by reference
+An iterator cannot be used with foreach by reference
+An iterator cannot be used with foreach by reference
+==DONE==
diff --git a/ext/spl/tests/heap_010.phpt b/ext/spl/tests/heap_010.phpt
new file mode 100644
index 0000000..8c7d8d5
--- /dev/null
+++ b/ext/spl/tests/heap_010.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: SplHeap with overriden count()
+--FILE--
+<?php
+$obj = new SplMaxHeap();
+$obj->insert(1);
+$obj->insert(2);
+var_dump(count($obj));
+class SplMaxHeap2 extends SplMaxHeap{
+ public function count() {
+ return -parent::count();
+ }
+}
+$obj = new SplMaxHeap2();
+$obj->insert(1);
+$obj->insert(2);
+var_dump(count($obj));
+?>
+--EXPECT--
+int(2)
+int(-2)
diff --git a/ext/spl/tests/heap_011.phpt b/ext/spl/tests/heap_011.phpt
new file mode 100644
index 0000000..1689abf
--- /dev/null
+++ b/ext/spl/tests/heap_011.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: SplHeap with overriden compare()
+--FILE--
+<?php
+class SplMinHeap2 extends SplMinHeap {
+ public function compare($a, $b) {
+ return -parent::compare($a,$b);
+ }
+}
+$h = new SplMinHeap2();
+$h->insert(1);
+$h->insert(6);
+$h->insert(5);
+$h->insert(2);
+var_dump($h->top());
+
+class SplMaxHeap2 extends SplMaxHeap {
+ public function compare($a, $b) {
+ return -parent::compare($a,$b);
+ }
+}
+$h = new SplMaxHeap2();
+$h->insert(1);
+$h->insert(6);
+$h->insert(5);
+$h->insert(2);
+var_dump($h->top());
+?>
+--EXPECT--
+int(6)
+int(1)
diff --git a/ext/spl/tests/heap_012.phpt b/ext/spl/tests/heap_012.phpt
new file mode 100644
index 0000000..f86f14f
--- /dev/null
+++ b/ext/spl/tests/heap_012.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplHeap recursive var_dump
+--FILE--
+<?php
+$a = new SplMaxHeap;
+$a->insert($a);
+var_dump($a)
+?>
+===DONE===
+--EXPECTF--
+object(SplMaxHeap)#%d (3) {
+ ["flags":"SplHeap":private]=>
+ int(0)
+ ["isCorrupted":"SplHeap":private]=>
+ bool(false)
+ ["heap":"SplHeap":private]=>
+ array(1) {
+ [0]=>
+ *RECURSION*
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/heap_corruption.phpt b/ext/spl/tests/heap_corruption.phpt
new file mode 100644
index 0000000..284ee1d
--- /dev/null
+++ b/ext/spl/tests/heap_corruption.phpt
@@ -0,0 +1,62 @@
+--TEST--
+SPL: SplHeap - heap corruption via compare exception (with top element deletion)
+--CREDITS--
+Mike Sullivan <mikesul@php.net>
+#TestFest 2009 (London)
+--FILE--
+<?php
+
+class myHeap extends SplHeap
+{
+ public $allow_compare = true;
+
+ public function compare($v1, $v2)
+ {
+ if ($this->allow_compare == true)
+ {
+ if ($v1 > $v2)
+ {
+ return 1;
+ }
+ else if ($v1 < $v2)
+ {
+ return -1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ throw new Exception('Compare exception');
+ }
+ }
+}
+
+$heap = new myHeap();
+$heap->insert(1);
+$heap->insert(2);
+$heap->insert(3);
+$heap->insert(4);
+
+$heap->allow_compare = false;
+
+try {
+ $heap->extract();
+}
+catch (Exception $e) {
+ echo "Compare Exception: " . $e->getMessage() . PHP_EOL;
+}
+
+try {
+ $heap->top();
+}
+catch (Exception $e) {
+ echo "Corruption Exception: " . $e->getMessage() . PHP_EOL;
+}
+
+?>
+--EXPECT--
+Compare Exception: Compare exception
+Corruption Exception: Heap is corrupted, heap properties are no longer ensured. \ No newline at end of file
diff --git a/ext/spl/tests/heap_current_variation_001.phpt b/ext/spl/tests/heap_current_variation_001.phpt
new file mode 100644
index 0000000..eb6df2b
--- /dev/null
+++ b/ext/spl/tests/heap_current_variation_001.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplHeap::current - get current value from empty heap
+--CREDITS--
+Mike Sullivan <mikesul@php.net>
+#TestFest 2009 (London)
+--FILE--
+<?php
+
+class myHeap extends SplHeap
+{
+ public function compare($v1, $v2)
+ {
+ throw new Exception('');
+ }
+}
+
+$heap = new myHeap();
+var_dump($heap->current());
+
+?>
+--EXPECT--
+NULL \ No newline at end of file
diff --git a/ext/spl/tests/heap_isempty_variation_001.phpt b/ext/spl/tests/heap_isempty_variation_001.phpt
new file mode 100644
index 0000000..dac470f
--- /dev/null
+++ b/ext/spl/tests/heap_isempty_variation_001.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: SplHeap: isEmpty argument variation.
+--FILE--
+<?php
+class SplHeap2 extends SplHeap{
+
+ public function compare() {
+ return -parent::compare();
+ }
+}
+
+$h = new SplHeap2;
+$h->isEmpty(1);
+?>
+--EXPECTF--
+Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/heap_it_current_empty.phpt b/ext/spl/tests/heap_it_current_empty.phpt
new file mode 100644
index 0000000..24230db
--- /dev/null
+++ b/ext/spl/tests/heap_it_current_empty.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplHeap current, check looping through an empty heap gives you no values
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplMinHeap();
+
+foreach ($h as $val) { echo 'FAIL'; }
+?>
+--EXPECT--
diff --git a/ext/spl/tests/heap_top_variation_001.phpt b/ext/spl/tests/heap_top_variation_001.phpt
new file mode 100644
index 0000000..9953cf9
--- /dev/null
+++ b/ext/spl/tests/heap_top_variation_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+SPL: SplHeap top, illegal number of args
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplMinHeap();
+$h->insert(5);
+// top doesn't take any args, lets see what happens if we give it one
+$h->top('bogus');
+?>
+--EXPECTF--
+Warning: SplHeap::top() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/heap_top_variation_002.phpt b/ext/spl/tests/heap_top_variation_002.phpt
new file mode 100644
index 0000000..cd6a8d0
--- /dev/null
+++ b/ext/spl/tests/heap_top_variation_002.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: SplHeap top, corrupted heap
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+// override heap to force corruption by throwing exception in compare
+class SplMinHeap2 extends SplMinHeap {
+ public function compare($a, $b) {
+ throw new Exception('Corrupt heap');
+ }
+}
+
+$h = new SplMinHeap2();
+
+// insert 2 elements to hit our overridden compare
+$h->insert(4);
+try {
+ $h->insert(5);
+} catch (Exception $e) {}
+
+// call top, should fail with corrupted heap
+try {
+ $h->top();
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+?>
+--EXPECTF--
+Heap is corrupted, heap properties are no longer ensured.
diff --git a/ext/spl/tests/heap_top_variation_003.phpt b/ext/spl/tests/heap_top_variation_003.phpt
new file mode 100644
index 0000000..7a91a9c
--- /dev/null
+++ b/ext/spl/tests/heap_top_variation_003.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: SplHeap top of empty heap
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplMinHeap();
+try {
+ $h->top();
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+?>
+--EXPECTF--
+Can't peek at an empty heap
diff --git a/ext/spl/tests/iterator_001.phpt b/ext/spl/tests/iterator_001.phpt
new file mode 100644
index 0000000..26df62e
--- /dev/null
+++ b/ext/spl/tests/iterator_001.phpt
@@ -0,0 +1,171 @@
+--TEST--
+SPL: Iterator aggregating inner iterator's methods
+--FILE--
+<?php
+
+class NumericArrayIterator implements Iterator
+{
+ protected $a;
+ protected $i = 0;
+
+ public function __construct($a)
+ {
+ echo __METHOD__ . "\n";
+ $this->a = $a;
+ }
+
+ public function rewind()
+ {
+ echo __METHOD__ . "\n";
+ $this->i = 0;
+ }
+
+ public function valid()
+ {
+ $ret = $this->i < count($this->a);
+ echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n";
+ return $ret;
+ }
+
+ public function key()
+ {
+ echo __METHOD__ . "\n";
+ return $this->i;
+ }
+
+ public function current()
+ {
+ echo __METHOD__ . "\n";
+ return $this->a[$this->i];
+ }
+
+ public function next()
+ {
+ echo __METHOD__ . "\n";
+ $this->i++;
+ }
+
+ public function greaterThan($comp)
+ {
+ echo get_class($this) . '::' . __FUNCTION__ . '(' . $comp . ")\n";
+ return $this->current() > $comp;
+ }
+}
+
+class SeekableNumericArrayIterator extends NumericArrayIterator implements SeekableIterator
+{
+ public function seek($index)
+ {
+ if ($index < count($this->a)) {
+ $this->i = $index;
+ }
+ echo __METHOD__ . '(' . $index . ")\n";
+ }
+}
+
+$a = array(1, 2, 3, 4, 5);
+$it = new LimitIterator(new NumericArrayIterator($a), 1, 3);
+foreach ($it as $v)
+{
+ print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n";
+}
+
+echo "===SEEKABLE===\n";
+$a = array(1, 2, 3, 4, 5);
+$it = new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3);
+foreach($it as $v)
+{
+ print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n";
+}
+
+echo "===STACKED===\n";
+echo "Shows '2 is greater than 2' because the test is actually done with the current value which is 3.\n";
+$a = array(1, 2, 3, 4, 5);
+$it = new CachingIterator(new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3));
+foreach($it as $v)
+{
+ print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+NumericArrayIterator::__construct
+NumericArrayIterator::rewind
+NumericArrayIterator::valid(true)
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+NumericArrayIterator::greaterThan(2)
+NumericArrayIterator::current
+2 is less than or equal 2
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+NumericArrayIterator::greaterThan(2)
+NumericArrayIterator::current
+3 is greater than 2
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+NumericArrayIterator::greaterThan(2)
+NumericArrayIterator::current
+4 is greater than 2
+NumericArrayIterator::next
+===SEEKABLE===
+NumericArrayIterator::__construct
+NumericArrayIterator::rewind
+SeekableNumericArrayIterator::seek(1)
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+SeekableNumericArrayIterator::greaterThan(2)
+NumericArrayIterator::current
+2 is less than or equal 2
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+SeekableNumericArrayIterator::greaterThan(2)
+NumericArrayIterator::current
+3 is greater than 2
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+SeekableNumericArrayIterator::greaterThan(2)
+NumericArrayIterator::current
+4 is greater than 2
+NumericArrayIterator::next
+===STACKED===
+Shows '2 is greater than 2' because the test is actually done with the current value which is 3.
+NumericArrayIterator::__construct
+NumericArrayIterator::rewind
+SeekableNumericArrayIterator::seek(1)
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+SeekableNumericArrayIterator::greaterThan(2)
+NumericArrayIterator::current
+2 is greater than 2
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+SeekableNumericArrayIterator::greaterThan(2)
+NumericArrayIterator::current
+3 is greater than 2
+NumericArrayIterator::next
+SeekableNumericArrayIterator::greaterThan(2)
+NumericArrayIterator::current
+4 is greater than 2
+===DONE===
diff --git a/ext/spl/tests/iterator_002.phpt b/ext/spl/tests/iterator_002.phpt
new file mode 100644
index 0000000..527fe6b
--- /dev/null
+++ b/ext/spl/tests/iterator_002.phpt
@@ -0,0 +1,55 @@
+--TEST--
+SPL: Iterator using getInnerIterator
+--FILE--
+<?php
+
+class RecursiceArrayIterator extends ArrayIterator implements RecursiveIterator
+{
+ function hasChildren()
+ {
+ return is_array($this->current());
+ }
+
+ function getChildren()
+ {
+ return new RecursiceArrayIterator($this->current());
+ }
+}
+
+class CrashIterator extends FilterIterator implements RecursiveIterator
+{
+ function accept()
+ {
+ return true;
+ }
+
+ function hasChildren()
+ {
+ return $this->getInnerIterator()->hasChildren();
+ }
+
+ function getChildren()
+ {
+ return new RecursiceArrayIterator($this->getInnerIterator()->current());
+ }
+}
+
+$array = array(1, 2 => array(21, 22 => array(221, 222), 23 => array(231)), 3);
+
+$dir = new RecursiveIteratorIterator(new CrashIterator(new RecursiceArrayIterator($array)), RecursiveIteratorIterator::LEAVES_ONLY);
+
+foreach ($dir as $file) {
+ print "$file\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+1
+21
+221
+222
+231
+3
+===DONE===
diff --git a/ext/spl/tests/iterator_003.phpt b/ext/spl/tests/iterator_003.phpt
new file mode 100644
index 0000000..11d37b3
--- /dev/null
+++ b/ext/spl/tests/iterator_003.phpt
@@ -0,0 +1,95 @@
+--TEST--
+SPL: CachingIterator and __toString()
+--FILE--
+<?php
+
+class Student
+{
+ private $id;
+ private $name;
+
+ public function __construct($id, $name)
+ {
+ $this->id = $id;
+ $this->name = $name;
+ }
+
+ public function __toString()
+ {
+ return $this->id . ', ' . $this->name;
+ }
+
+ public function getId()
+ {
+ return $this->id;
+ }
+}
+
+class StudentIdFilter extends FilterIterator
+{
+ private $id;
+
+ public function __construct(ArrayObject $students, Student $other)
+ {
+ FilterIterator::__construct($students->getIterator());
+ $this->id = $other->getId();
+ }
+
+ public function accept()
+ {
+ echo "ACCEPT ".$this->current()->getId()." == ".$this->id."\n";
+ return $this->current()->getId() == $this->id;
+ }
+}
+
+class StudentList implements IteratorAggregate
+{
+ private $students;
+
+ public function __construct()
+ {
+ $this->students = new ArrayObject(array());
+ }
+
+ public function add(Student $student)
+ {
+ if (!$this->contains($student)) {
+ $this->students[] = $student;
+ }
+ }
+
+ public function contains(Student $student)
+ {
+ foreach ($this->students as $s)
+ {
+ if ($s->getId() == $student->getId()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public function getIterator() {
+ return new CachingIterator($this->students->getIterator(), true);
+ }
+}
+
+$students = new StudentList();
+$students->add(new Student('01234123', 'Joe'));
+$students->add(new Student('00000014', 'Bob'));
+$students->add(new Student('00000014', 'Foo'));
+
+// The goal is to verify we can access the cached string value even if it was
+// generated by a call to __toString(). To check this we need to access the
+// iterator's __toString() method.
+$it = $students->getIterator();
+foreach ($it as $student) {
+ echo $it->__toString(), "\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+01234123, Joe
+00000014, Bob
+===DONE===
diff --git a/ext/spl/tests/iterator_004.phpt b/ext/spl/tests/iterator_004.phpt
new file mode 100644
index 0000000..e07cd32
--- /dev/null
+++ b/ext/spl/tests/iterator_004.phpt
@@ -0,0 +1,142 @@
+--TEST--
+SPL: SeekableIterator and string keys
+--FILE--
+<?php
+
+class NumericArrayIterator implements Iterator
+{
+ protected $a;
+ protected $i;
+
+ public function __construct($a)
+ {
+ echo __METHOD__ . "\n";
+ $this->a = $a;
+ }
+
+ public function rewind()
+ {
+ echo __METHOD__ . "\n";
+ $this->i = 0;
+ }
+
+ public function valid()
+ {
+ $ret = $this->i < count($this->a);
+ echo __METHOD__ . '(' . ($ret ? 'true' : 'false') . ")\n";
+ return $ret;
+ }
+
+ public function key()
+ {
+ echo __METHOD__ . "\n";
+ return $this->i;
+ }
+
+ public function current()
+ {
+ echo __METHOD__ . "\n";
+ return $this->a[$this->i];
+ }
+
+ public function next()
+ {
+ echo __METHOD__ . "\n";
+ $this->i++;
+ }
+}
+
+class SeekableNumericArrayIterator extends NumericArrayIterator implements SeekableIterator
+{
+ public function seek($index)
+ {
+ if ($index < count($this->a)) {
+ $this->i = $index;
+ }
+ echo __METHOD__ . '(' . $index . ")\n";
+ }
+}
+
+$a = array(1, 2, 3, 4, 5);
+foreach (new LimitIterator(new NumericArrayIterator($a), 1, 3) as $v)
+{
+ print "$v\n";
+}
+
+echo "===SEEKABLE===\n";
+$a = array(1, 2, 3, 4, 5);
+foreach(new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3) as $v)
+{
+ print "$v\n";
+}
+
+echo "===SEEKING===\n";
+$a = array(1, 2, 3, 4, 5);
+$l = new LimitIterator(new SeekableNumericArrayIterator($a));
+for($i = 1; $i < 4; $i++)
+{
+ $l->seek($i);
+ print $l->current() . "\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+NumericArrayIterator::__construct
+NumericArrayIterator::rewind
+NumericArrayIterator::valid(true)
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+2
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+3
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+4
+NumericArrayIterator::next
+===SEEKABLE===
+NumericArrayIterator::__construct
+NumericArrayIterator::rewind
+SeekableNumericArrayIterator::seek(1)
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+2
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+3
+NumericArrayIterator::next
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+4
+NumericArrayIterator::next
+===SEEKING===
+NumericArrayIterator::__construct
+SeekableNumericArrayIterator::seek(1)
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+2
+SeekableNumericArrayIterator::seek(2)
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+3
+SeekableNumericArrayIterator::seek(3)
+NumericArrayIterator::valid(true)
+NumericArrayIterator::current
+NumericArrayIterator::key
+4
+===DONE===
diff --git a/ext/spl/tests/iterator_005.phpt b/ext/spl/tests/iterator_005.phpt
new file mode 100644
index 0000000..640ca9f
--- /dev/null
+++ b/ext/spl/tests/iterator_005.phpt
@@ -0,0 +1,52 @@
+--TEST--
+SPL: IteratorIterator and ArrayIterator/Object
+--FILE--
+<?php
+
+class ArrayIteratorEx extends ArrayIterator
+{
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ return parent::rewind();
+ }
+}
+
+$it = new ArrayIteratorEx(range(0,3));
+
+foreach(new IteratorIterator($it) as $v)
+{
+ var_dump($v);
+}
+
+class ArrayObjectEx extends ArrayObject
+{
+ function getIterator()
+ {
+ echo __METHOD__ . "\n";
+ return parent::getIterator();
+ }
+}
+
+$it = new ArrayObjectEx(range(0,3));
+
+foreach(new IteratorIterator($it) as $v)
+{
+ var_dump($v);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+ArrayIteratorEx::rewind
+int(0)
+int(1)
+int(2)
+int(3)
+ArrayObjectEx::getIterator
+int(0)
+int(1)
+int(2)
+int(3)
+===DONE===
diff --git a/ext/spl/tests/iterator_006.phpt b/ext/spl/tests/iterator_006.phpt
new file mode 100644
index 0000000..54da89c
--- /dev/null
+++ b/ext/spl/tests/iterator_006.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: IteratorIterator and SimpleXMlElement
+--SKIPIF--
+<?php if (!extension_loaded('simplexml')) print "skip SimpleXML required"; ?>
+--FILE--
+<?php
+
+$root = simplexml_load_string(b'<?xml version="1.0"?>
+<root>
+ <child>Hello</child>
+ <child>World</child>
+</root>
+');
+
+foreach (new IteratorIterator($root->child) as $child) {
+ echo $child."\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+Hello
+World
+===DONE===
diff --git a/ext/spl/tests/iterator_007.phpt b/ext/spl/tests/iterator_007.phpt
new file mode 100644
index 0000000..d26c01e
--- /dev/null
+++ b/ext/spl/tests/iterator_007.phpt
@@ -0,0 +1,166 @@
+--TEST--
+SPL: NoRewindIterator
+--FILE--
+<?php
+
+class ArrayIteratorEx extends ArrayIterator
+{
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ parent::rewind();
+ }
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ return parent::valid();
+ }
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return parent::current();
+ }
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return parent::key();
+ }
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ parent::next();
+ }
+}
+
+class NoRewindIteratorEx extends NoRewindIterator
+{
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ parent::rewind();
+ }
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ return parent::valid();
+ }
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return parent::current();
+ }
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return parent::key();
+ }
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ parent::next();
+ }
+}
+
+$it = new NoRewindIteratorEx(new ArrayIteratorEx(range(0,3)));
+
+echo "===0===\n";
+foreach ($it->getInnerIterator() as $v) {
+ var_dump($v);
+}
+
+echo "===1===\n";
+foreach ($it as $v) {
+ var_dump($v);
+}
+
+$pos =0;
+
+$it = new NoRewindIteratorEx(new ArrayIteratorEx(range(0,3)));
+
+echo "===2===\n";
+foreach ($it as $v) {
+ var_dump($v);
+ if ($pos++ > 1) {
+ break;
+ }
+}
+
+echo "===3===\n";
+foreach ($it as $v) {
+ var_dump($v);
+}
+
+echo "===4===\n";
+foreach ($it as $v) {
+ var_dump($v);
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+===0===
+ArrayIteratorEx::rewind
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+int(0)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+int(1)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+int(2)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+int(3)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+===1===
+NoRewindIteratorEx::rewind
+NoRewindIteratorEx::valid
+ArrayIteratorEx::valid
+===2===
+NoRewindIteratorEx::rewind
+NoRewindIteratorEx::valid
+ArrayIteratorEx::valid
+NoRewindIteratorEx::current
+ArrayIteratorEx::current
+int(0)
+NoRewindIteratorEx::next
+ArrayIteratorEx::next
+NoRewindIteratorEx::valid
+ArrayIteratorEx::valid
+NoRewindIteratorEx::current
+ArrayIteratorEx::current
+int(1)
+NoRewindIteratorEx::next
+ArrayIteratorEx::next
+NoRewindIteratorEx::valid
+ArrayIteratorEx::valid
+NoRewindIteratorEx::current
+ArrayIteratorEx::current
+int(2)
+===3===
+NoRewindIteratorEx::rewind
+NoRewindIteratorEx::valid
+ArrayIteratorEx::valid
+NoRewindIteratorEx::current
+int(2)
+NoRewindIteratorEx::next
+ArrayIteratorEx::next
+NoRewindIteratorEx::valid
+ArrayIteratorEx::valid
+NoRewindIteratorEx::current
+ArrayIteratorEx::current
+int(3)
+NoRewindIteratorEx::next
+ArrayIteratorEx::next
+NoRewindIteratorEx::valid
+ArrayIteratorEx::valid
+===4===
+NoRewindIteratorEx::rewind
+NoRewindIteratorEx::valid
+ArrayIteratorEx::valid
+===DONE===
diff --git a/ext/spl/tests/iterator_008.phpt b/ext/spl/tests/iterator_008.phpt
new file mode 100644
index 0000000..04f8c00
--- /dev/null
+++ b/ext/spl/tests/iterator_008.phpt
@@ -0,0 +1,89 @@
+--TEST--
+SPL: InfiniteIterator
+--FILE--
+<?php
+
+class ArrayIteratorEx extends ArrayIterator
+{
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ parent::rewind();
+ }
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ return parent::valid();
+ }
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return parent::current();
+ }
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return parent::key();
+ }
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ parent::next();
+ }
+}
+
+$it = new InfiniteIterator(new ArrayIteratorEx(range(0,2)));
+
+$pos =0;
+
+foreach ($it as $v) {
+ var_dump($v);
+ if ($pos++ > 5) {
+ break;
+ }
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+ArrayIteratorEx::rewind
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+ArrayIteratorEx::key
+int(0)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+ArrayIteratorEx::key
+int(1)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+ArrayIteratorEx::key
+int(2)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+ArrayIteratorEx::rewind
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+ArrayIteratorEx::key
+int(0)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+ArrayIteratorEx::key
+int(1)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+ArrayIteratorEx::key
+int(2)
+ArrayIteratorEx::next
+ArrayIteratorEx::valid
+ArrayIteratorEx::rewind
+ArrayIteratorEx::valid
+ArrayIteratorEx::current
+ArrayIteratorEx::key
+int(0)
+===DONE===
diff --git a/ext/spl/tests/iterator_009.phpt b/ext/spl/tests/iterator_009.phpt
new file mode 100644
index 0000000..0bfe74e
--- /dev/null
+++ b/ext/spl/tests/iterator_009.phpt
@@ -0,0 +1,45 @@
+--TEST--
+SPL: EmptyIterator
+--FILE--
+<?php
+
+class EmptyIteratorEx extends EmptyIterator
+{
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ parent::rewind();
+ }
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ return parent::valid();
+ }
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return parent::current();
+ }
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return parent::key();
+ }
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ parent::next();
+ }
+}
+
+foreach (new EmptyIteratorEx() as $v) {
+ var_dump($v);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+EmptyIteratorEx::rewind
+EmptyIteratorEx::valid
+===DONE===
diff --git a/ext/spl/tests/iterator_010.phpt b/ext/spl/tests/iterator_010.phpt
new file mode 100644
index 0000000..39d1000
--- /dev/null
+++ b/ext/spl/tests/iterator_010.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SPL: EmptyIterator
+--FILE--
+<?php
+
+echo "===EmptyIterator===\n";
+
+foreach(new LimitIterator(new EmptyIterator(), 0, 3) as $key => $val)
+{
+ echo "$key=>$val\n";
+}
+
+?>
+===DONE===
+<?php exit(0);
+--EXPECTF--
+===EmptyIterator===
+===DONE===
diff --git a/ext/spl/tests/iterator_011.phpt b/ext/spl/tests/iterator_011.phpt
new file mode 100644
index 0000000..fca159a
--- /dev/null
+++ b/ext/spl/tests/iterator_011.phpt
@@ -0,0 +1,51 @@
+--TEST--
+SPL: InfiniteIterator
+--FILE--
+<?php
+
+echo "===EmptyIterator===\n";
+
+foreach(new LimitIterator(new InfiniteIterator(new EmptyIterator()), 0, 3) as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===InfiniteIterator===\n";
+
+$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D'));
+$it = new InfiniteIterator($it);
+$it = new LimitIterator($it, 2, 5);
+foreach($it as $val=>$key)
+{
+ echo "$val=>$key\n";
+}
+
+echo "===Infinite/LimitIterator===\n";
+
+$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D'));
+$it = new LimitIterator($it, 1, 2);
+$it = new InfiniteIterator($it);
+$it = new LimitIterator($it, 2, 5);
+foreach($it as $val=>$key)
+{
+ echo "$val=>$key\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===EmptyIterator===
+===InfiniteIterator===
+2=>C
+3=>D
+0=>A
+1=>B
+2=>C
+===Infinite/LimitIterator===
+1=>B
+2=>C
+1=>B
+2=>C
+1=>B
+===DONE===
diff --git a/ext/spl/tests/iterator_012.phpt b/ext/spl/tests/iterator_012.phpt
new file mode 100644
index 0000000..81bc02f
--- /dev/null
+++ b/ext/spl/tests/iterator_012.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: NoRewindIterator
+--FILE--
+<?php
+
+echo "===Current===\n";
+
+$it = new NoRewindIterator(new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C')));
+
+echo $it->key() . '=>' . $it->current() . "\n";
+
+echo "===Next===\n";
+
+$it->next();
+
+echo "===Foreach===\n";
+
+foreach($it as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===Current===
+0=>A
+===Next===
+===Foreach===
+1=>B
+2=>C
+===DONE===
diff --git a/ext/spl/tests/iterator_013.phpt b/ext/spl/tests/iterator_013.phpt
new file mode 100644
index 0000000..119631c
--- /dev/null
+++ b/ext/spl/tests/iterator_013.phpt
@@ -0,0 +1,66 @@
+--TEST--
+SPL: AppendIterator
+--FILE--
+<?php
+
+echo "===Empty===\n";
+
+$it = new AppendIterator;
+
+foreach($it as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===Append===\n";
+
+$it->append(new ArrayIterator(array(0 => 'A', 1 => 'B')));
+
+foreach($it as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===Rewind===\n";
+
+foreach($it as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===Append===\n";
+
+$it->append(new ArrayIterator(array(2 => 'C', 3 => 'D')));
+
+foreach(new NoRewindIterator($it) as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===Rewind===\n";
+
+foreach($it as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===Empty===
+===Append===
+0=>A
+1=>B
+===Rewind===
+0=>A
+1=>B
+===Append===
+2=>C
+3=>D
+===Rewind===
+0=>A
+1=>B
+2=>C
+3=>D
+===DONE===
diff --git a/ext/spl/tests/iterator_014.phpt b/ext/spl/tests/iterator_014.phpt
new file mode 100644
index 0000000..119fad0
--- /dev/null
+++ b/ext/spl/tests/iterator_014.phpt
@@ -0,0 +1,138 @@
+--TEST--
+SPL: RecursiveIteratorIterator and beginChildren/endChildren
+--FILE--
+<?php
+
+class MyRecursiveArrayIterator extends RecursiveArrayIterator
+{
+ function valid()
+ {
+ if (!parent::valid())
+ {
+ echo __METHOD__ . " = false\n";
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ function getChildren()
+ {
+ echo __METHOD__ . "\n";
+ return parent::getChildren();
+ }
+}
+
+class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
+{
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ parent::rewind();
+ }
+
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ return parent::valid();
+ }
+
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return parent::current();
+ }
+
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return parent::key();
+ }
+
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ parent::next();
+ }
+
+ function beginChildren()
+ {
+ echo __METHOD__ . "(".$this->getDepth().")\n";
+ }
+
+ function endChildren()
+ {
+ echo __METHOD__ . "(".$this->getDepth().")\n";
+ }
+}
+
+foreach(new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d"))) as $k=>$v)
+{
+ echo "$k=>$v\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+RecursiveArrayIteratorIterator::rewind
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>a
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::getChildren
+RecursiveArrayIteratorIterator::beginChildren(1)
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>ba
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::getChildren
+RecursiveArrayIteratorIterator::beginChildren(2)
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>bba
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+1=>bbb
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(2)
+MyRecursiveArrayIterator::getChildren
+RecursiveArrayIteratorIterator::beginChildren(2)
+MyRecursiveArrayIterator::getChildren
+RecursiveArrayIteratorIterator::beginChildren(3)
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>bcaa
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(3)
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(2)
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(1)
+MyRecursiveArrayIterator::getChildren
+RecursiveArrayIteratorIterator::beginChildren(1)
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>ca
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(1)
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+3=>d
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::valid
+MyRecursiveArrayIterator::valid = false
+===DONE===
diff --git a/ext/spl/tests/iterator_015.phpt b/ext/spl/tests/iterator_015.phpt
new file mode 100644
index 0000000..aa30f79
--- /dev/null
+++ b/ext/spl/tests/iterator_015.phpt
@@ -0,0 +1,62 @@
+--TEST--
+SPL: RecursiveIteratorIterator and beginChildren/endChildren
+--FILE--
+<?php
+
+class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
+{
+ function rewind()
+ {
+ echo "<ul>\n";
+ parent::rewind();
+ }
+ function beginChildren()
+ {
+ echo str_repeat(' ',$this->getDepth())."<ul>\n";
+ }
+
+ function endChildren()
+ {
+ echo str_repeat(' ',$this->getDepth())."</ul>\n";
+ }
+ function valid()
+ {
+ if (!parent::valid()) {
+ echo "<ul>\n";
+ return false;
+ }
+ return true;
+ }
+}
+
+$arr = array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d");
+$obj = new RecursiveArrayIterator($arr);
+$rit = new RecursiveArrayIteratorIterator($obj);
+foreach($rit as $k=>$v)
+{
+ echo str_repeat(' ',$rit->getDepth()+1)."$k=>$v\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+<ul>
+ 0=>a
+ <ul>
+ 0=>ba
+ <ul>
+ 0=>bba
+ 1=>bbb
+ </ul>
+ <ul>
+ <ul>
+ 0=>bcaa
+ </ul>
+ </ul>
+ </ul>
+ <ul>
+ 0=>ca
+ </ul>
+ 3=>d
+<ul>
+===DONE===
diff --git a/ext/spl/tests/iterator_016.phpt b/ext/spl/tests/iterator_016.phpt
new file mode 100644
index 0000000..f231c6e
--- /dev/null
+++ b/ext/spl/tests/iterator_016.phpt
@@ -0,0 +1,76 @@
+--TEST--
+SPL: RecursiveIteratorIterator and beginChildren/endChildren
+--FILE--
+<?php
+
+class Menu extends ArrayObject
+{
+ function getIterator()
+ {
+ echo __METHOD__ . "\n";
+ return new RecursiveArrayIterator($this);
+ }
+}
+
+class MenuOutput extends RecursiveIteratorIterator
+{
+ function __construct(Menu $it)
+ {
+ parent::__construct($it);
+ }
+ function rewind()
+ {
+ echo "<ul>\n";
+ parent::rewind();
+ }
+ function beginChildren()
+ {
+ echo str_repeat(' ',$this->getDepth())."<ul>\n";
+ }
+
+ function endChildren()
+ {
+ echo str_repeat(' ',$this->getDepth())."</ul>\n";
+ }
+ function valid()
+ {
+ if (!parent::valid()) {
+ echo "<ul>\n";
+ return false;
+ }
+ return true;
+ }
+}
+
+$arr = array("a", array("ba", array("bba", "bbb"), array(array("bcaa"))), array("ca"), "d");
+$obj = new Menu($arr);
+$rit = new MenuOutput($obj);
+foreach($rit as $k=>$v)
+{
+ echo str_repeat(' ',$rit->getDepth()+1)."$k=>$v\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Menu::getIterator
+<ul>
+ 0=>a
+ <ul>
+ 0=>ba
+ <ul>
+ 0=>bba
+ 1=>bbb
+ </ul>
+ <ul>
+ <ul>
+ 0=>bcaa
+ </ul>
+ </ul>
+ </ul>
+ <ul>
+ 0=>ca
+ </ul>
+ 3=>d
+<ul>
+===DONE===
diff --git a/ext/spl/tests/iterator_017.phpt b/ext/spl/tests/iterator_017.phpt
new file mode 100644
index 0000000..39d1000
--- /dev/null
+++ b/ext/spl/tests/iterator_017.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SPL: EmptyIterator
+--FILE--
+<?php
+
+echo "===EmptyIterator===\n";
+
+foreach(new LimitIterator(new EmptyIterator(), 0, 3) as $key => $val)
+{
+ echo "$key=>$val\n";
+}
+
+?>
+===DONE===
+<?php exit(0);
+--EXPECTF--
+===EmptyIterator===
+===DONE===
diff --git a/ext/spl/tests/iterator_018.phpt b/ext/spl/tests/iterator_018.phpt
new file mode 100644
index 0000000..9c234bb
--- /dev/null
+++ b/ext/spl/tests/iterator_018.phpt
@@ -0,0 +1,51 @@
+--TEST--
+SPL: InfiniteIterator
+--FILE--
+<?php
+
+echo "===EmptyIterator===\n";
+
+foreach(new LimitIterator(new InfiniteIterator(new EmptyIterator()), 0, 3) as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===InfiniteIterator===\n";
+
+$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D'));
+$it = new InfiniteIterator($it);
+$it = new LimitIterator($it, 2, 5);
+foreach($it as $val=>$key)
+{
+ echo "$val=>$key\n";
+}
+
+echo "===Infinite/LimitIterator===\n";
+
+$it = new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D'));
+$it = new LimitIterator($it, 1, 2);
+$it = new InfiniteIterator($it);
+$it = new LimitIterator($it, 2, 5);
+foreach($it as $val=>$key)
+{
+ echo "$val=>$key\n";
+}
+
+?>
+===DONE===
+<?php exit(0);
+--EXPECTF--
+===EmptyIterator===
+===InfiniteIterator===
+2=>C
+3=>D
+0=>A
+1=>B
+2=>C
+===Infinite/LimitIterator===
+1=>B
+2=>C
+1=>B
+2=>C
+1=>B
+===DONE===
diff --git a/ext/spl/tests/iterator_019.phpt b/ext/spl/tests/iterator_019.phpt
new file mode 100644
index 0000000..81bc02f
--- /dev/null
+++ b/ext/spl/tests/iterator_019.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: NoRewindIterator
+--FILE--
+<?php
+
+echo "===Current===\n";
+
+$it = new NoRewindIterator(new ArrayIterator(array(0 => 'A', 1 => 'B', 2 => 'C')));
+
+echo $it->key() . '=>' . $it->current() . "\n";
+
+echo "===Next===\n";
+
+$it->next();
+
+echo "===Foreach===\n";
+
+foreach($it as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===Current===
+0=>A
+===Next===
+===Foreach===
+1=>B
+2=>C
+===DONE===
diff --git a/ext/spl/tests/iterator_020.phpt b/ext/spl/tests/iterator_020.phpt
new file mode 100644
index 0000000..119631c
--- /dev/null
+++ b/ext/spl/tests/iterator_020.phpt
@@ -0,0 +1,66 @@
+--TEST--
+SPL: AppendIterator
+--FILE--
+<?php
+
+echo "===Empty===\n";
+
+$it = new AppendIterator;
+
+foreach($it as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===Append===\n";
+
+$it->append(new ArrayIterator(array(0 => 'A', 1 => 'B')));
+
+foreach($it as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===Rewind===\n";
+
+foreach($it as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===Append===\n";
+
+$it->append(new ArrayIterator(array(2 => 'C', 3 => 'D')));
+
+foreach(new NoRewindIterator($it) as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+echo "===Rewind===\n";
+
+foreach($it as $key=>$val)
+{
+ echo "$key=>$val\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===Empty===
+===Append===
+0=>A
+1=>B
+===Rewind===
+0=>A
+1=>B
+===Append===
+2=>C
+3=>D
+===Rewind===
+0=>A
+1=>B
+2=>C
+3=>D
+===DONE===
diff --git a/ext/spl/tests/iterator_021.phpt b/ext/spl/tests/iterator_021.phpt
new file mode 100644
index 0000000..4f2395a
--- /dev/null
+++ b/ext/spl/tests/iterator_021.phpt
@@ -0,0 +1,180 @@
+--TEST--
+SPL: RecursiveIteratorIterator and hasChildren
+--FILE--
+<?php
+
+class MyRecursiveArrayIterator extends RecursiveArrayIterator
+{
+ function valid()
+ {
+ if (!parent::valid())
+ {
+ echo __METHOD__ . " = false\n";
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ function getChildren()
+ {
+ echo __METHOD__ . "\n";
+ return parent::getChildren();
+ }
+}
+
+class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
+{
+ private $max_depth;
+ private $over = 0;
+ private $skip = false;
+
+ function __construct($it, $max_depth)
+ {
+ $this->max_depth = $max_depth;
+ parent::__construct($it);
+ }
+
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ $this->skip = false;
+ parent::rewind();
+ }
+
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ if ($this->skip)
+ {
+ $this->skip = false;
+ $this->next();
+ }
+ return parent::valid();
+ }
+
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return parent::current();
+ }
+
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return parent::key();
+ }
+
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ parent::next();
+ }
+
+ function callHasChildren()
+ {
+ $this->skip = false;
+ $has = parent::callHasChildren();
+ $res = $this->getDepth() < $this->max_depth && $has;
+ echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n";
+ if ($has && !$res)
+ {
+ $this->over++;
+ if ($this->over == 2) {
+ $this->skip = true;
+ }
+ }
+ return $res;
+ }
+
+ function beginChildren()
+ {
+ echo __METHOD__ . "(".$this->getDepth().")\n";
+ }
+
+ function endChildren()
+ {
+ echo __METHOD__ . "(".$this->getDepth().")\n";
+ }
+}
+
+foreach(new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v)
+{
+ if (is_array($v)) $v = join('',$v);
+ echo "$k=>$v\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+RecursiveArrayIteratorIterator::rewind
+RecursiveArrayIteratorIterator::callHasChildren(0) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>a
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes
+MyRecursiveArrayIterator::getChildren
+RecursiveArrayIteratorIterator::beginChildren(1)
+RecursiveArrayIteratorIterator::callHasChildren(1) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>ba
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
+MyRecursiveArrayIterator::getChildren
+RecursiveArrayIteratorIterator::beginChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>bba
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+1=>bbb
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
+MyRecursiveArrayIterator::getChildren
+RecursiveArrayIteratorIterator::beginChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>bcaa
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(2)
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(1)
+RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes
+MyRecursiveArrayIterator::getChildren
+RecursiveArrayIteratorIterator::beginChildren(1)
+RecursiveArrayIteratorIterator::callHasChildren(1) = no/no
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>ca
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(1)
+RecursiveArrayIteratorIterator::callHasChildren(0) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+3=>d
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::valid
+MyRecursiveArrayIterator::valid = false
+===DONE===
diff --git a/ext/spl/tests/iterator_022.phpt b/ext/spl/tests/iterator_022.phpt
new file mode 100644
index 0000000..8d05531
--- /dev/null
+++ b/ext/spl/tests/iterator_022.phpt
@@ -0,0 +1,186 @@
+--TEST--
+SPL: RecursiveIteratorIterator and callHasChildren/callGetChildren
+--FILE--
+<?php
+
+class MyRecursiveArrayIterator extends RecursiveArrayIterator
+{
+ function getChildren()
+ {
+ echo __METHOD__ . "\n";
+ return $this->current();
+ }
+
+ function valid()
+ {
+ if (!parent::valid())
+ {
+ echo __METHOD__ . " = false\n";
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+}
+
+class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
+{
+ private $max_depth;
+ private $over = 0;
+ private $skip = false;
+
+ function __construct($it, $max_depth)
+ {
+ $this->max_depth = $max_depth;
+ parent::__construct($it);
+ }
+
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ $this->skip = false;
+ parent::rewind();
+ }
+
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ if ($this->skip)
+ {
+ $this->skip = false;
+ $this->next();
+ }
+ return parent::valid();
+ }
+
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return parent::current();
+ }
+
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return parent::key();
+ }
+
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ parent::next();
+ }
+
+ function callHasChildren()
+ {
+ $this->skip = false;
+ $has = parent::callHasChildren();
+ $res = $this->getDepth() < $this->max_depth && $has;
+ echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n";
+ if ($has && !$res)
+ {
+ $this->over++;
+ if ($this->over == 2) {
+ $this->skip = true;
+ }
+ }
+ return $res;
+ }
+
+ function callGetChildren()
+ {
+ if ($this->over == 2)
+ {
+ echo __METHOD__ . "(skip)\n";
+ return NULL;
+ }
+ echo __METHOD__ . "(ok:{$this->over})\n";
+ return new MyRecursiveArrayIterator($this->current());
+ }
+
+ function beginChildren()
+ {
+ echo __METHOD__ . "(".$this->getDepth().")\n";
+ }
+
+ function endChildren()
+ {
+ echo __METHOD__ . "(".$this->getDepth().")\n";
+ }
+}
+
+try
+{
+ foreach(new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v)
+ {
+ if (is_array($v)) $v = join('',$v);
+ echo "$k=>$v\n";
+ }
+}
+catch(UnexpectedValueException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+RecursiveArrayIteratorIterator::rewind
+RecursiveArrayIteratorIterator::callHasChildren(0) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>a
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes
+RecursiveArrayIteratorIterator::callGetChildren(ok:0)
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::beginChildren(1)
+RecursiveArrayIteratorIterator::callHasChildren(1) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>ba
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
+RecursiveArrayIteratorIterator::callGetChildren(ok:0)
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::beginChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>bba
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+1=>bbb
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
+RecursiveArrayIteratorIterator::callGetChildren(ok:0)
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::beginChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>bcaa
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(2)
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(1)
+RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes
+RecursiveArrayIteratorIterator::callGetChildren(skip)
+Objects returned by RecursiveIterator::getChildren() must implement RecursiveIterator
+===DONE===
diff --git a/ext/spl/tests/iterator_023.phpt b/ext/spl/tests/iterator_023.phpt
new file mode 100644
index 0000000..1b6b468
--- /dev/null
+++ b/ext/spl/tests/iterator_023.phpt
@@ -0,0 +1,193 @@
+--TEST--
+SPL: RecursiveIteratorIterator and catch getChildren
+--FILE--
+<?php
+
+class MyRecursiveArrayIterator extends RecursiveArrayIterator
+{
+ function getChildren()
+ {
+ echo __METHOD__ . "\n";
+ return $this->current();
+ }
+
+ function valid()
+ {
+ if (!parent::valid())
+ {
+ echo __METHOD__ . " = false\n";
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+}
+
+class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
+{
+ private $max_depth;
+ private $over = 0;
+ private $skip = false;
+
+ function __construct($it, $max_depth)
+ {
+ $this->max_depth = $max_depth;
+ parent::__construct($it, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+ }
+
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ $this->skip = false;
+ parent::rewind();
+ }
+
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ if ($this->skip)
+ {
+ $this->skip = false;
+ $this->next();
+ }
+ return parent::valid();
+ }
+
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return parent::current();
+ }
+
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return parent::key();
+ }
+
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ parent::next();
+ }
+
+ function callHasChildren()
+ {
+ $this->skip = false;
+ $has = parent::callHasChildren();
+ $res = $this->getDepth() < $this->max_depth && $has;
+ echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n";
+ if ($has && !$res)
+ {
+ $this->over++;
+ if ($this->over == 2) {
+ $this->skip = true;
+ }
+ }
+ return $res;
+ }
+
+ function callGetChildren()
+ {
+ if ($this->over == 2)
+ {
+ echo __METHOD__ . "(throw)\n";
+ throw new Exception("Thrown in callGetChildren()");
+ }
+ echo __METHOD__ . "(ok:{$this->over})\n";
+ return new MyRecursiveArrayIterator($this->current());
+ }
+
+ function beginChildren()
+ {
+ echo __METHOD__ . "(".$this->getDepth().")\n";
+ }
+
+ function endChildren()
+ {
+ echo __METHOD__ . "(".$this->getDepth().")\n";
+ }
+}
+
+try
+{
+ foreach(new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2) as $k=>$v)
+ {
+ if (is_array($v)) $v = join('',$v);
+ echo "$k=>$v\n";
+ }
+}
+catch(UnexpectedValueException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+RecursiveArrayIteratorIterator::rewind
+RecursiveArrayIteratorIterator::callHasChildren(0) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>a
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes
+RecursiveArrayIteratorIterator::callGetChildren(ok:0)
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::beginChildren(1)
+RecursiveArrayIteratorIterator::callHasChildren(1) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>ba
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
+RecursiveArrayIteratorIterator::callGetChildren(ok:0)
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::beginChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>bba
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/no
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+1=>bbb
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
+RecursiveArrayIteratorIterator::callGetChildren(ok:0)
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::beginChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+0=>bcaa
+RecursiveArrayIteratorIterator::next
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
+RecursiveArrayIteratorIterator::valid
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(2)
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::endChildren(1)
+RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes
+RecursiveArrayIteratorIterator::callGetChildren(throw)
+RecursiveArrayIteratorIterator::callHasChildren(0) = no/no
+RecursiveArrayIteratorIterator::current
+RecursiveArrayIteratorIterator::key
+3=>d
+RecursiveArrayIteratorIterator::next
+MyRecursiveArrayIterator::valid = false
+RecursiveArrayIteratorIterator::valid
+MyRecursiveArrayIterator::valid = false
+===DONE===
diff --git a/ext/spl/tests/iterator_024.phpt b/ext/spl/tests/iterator_024.phpt
new file mode 100644
index 0000000..0c7dea1
--- /dev/null
+++ b/ext/spl/tests/iterator_024.phpt
@@ -0,0 +1,49 @@
+--TEST--
+SPL: RecursiveIteratorIterator with custom iterator class
+--FILE--
+<?php
+
+$ar = array(1, 2, array(31, 32, array(331)), 4);
+
+foreach(new RecursiveIteratorIterator(new ArrayObject($ar, 0, "RecursiveArrayIterator")) as $v) echo "$v\n";
+
+$it = new ArrayObject($ar);
+var_dump($it->getIteratorClass());
+
+try
+{
+ foreach(new RecursiveIteratorIterator(new ArrayObject($ar)) as $v) echo "$v\n";
+}
+catch (InvalidArgumentException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+echo "===MANUAL===\n";
+
+$it->setIteratorClass("RecursiveArrayIterator");
+var_dump($it->getIteratorClass());
+foreach(new RecursiveIteratorIterator($it) as $v) echo "$v\n";
+
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+1
+2
+31
+32
+331
+4
+string(13) "ArrayIterator"
+An instance of RecursiveIterator or IteratorAggregate creating it is required
+===MANUAL===
+string(22) "RecursiveArrayIterator"
+1
+2
+31
+32
+331
+4
+===DONE===
diff --git a/ext/spl/tests/iterator_025.phpt b/ext/spl/tests/iterator_025.phpt
new file mode 100644
index 0000000..e582b1f
--- /dev/null
+++ b/ext/spl/tests/iterator_025.phpt
@@ -0,0 +1,92 @@
+--TEST--
+SPL: RecursiveIteratorIterator and begin/endIteration()
+--FILE--
+<?php
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator
+{
+ function beginIteration()
+ {
+ echo __METHOD__ . "()\n";
+ }
+
+ function endIteration()
+ {
+ echo __METHOD__ . "()\n";
+ }
+}
+
+$ar = array(1, 2, array(31, 32, array(331)), 4);
+
+$it = new MyRecursiveIteratorIterator(new ArrayObject($ar, 0, "RecursiveArrayIterator"));
+
+foreach($it as $v) echo "$v\n";
+
+echo "===MORE===\n";
+
+foreach($it as $v) echo "$v\n";
+
+echo "===MORE===\n";
+
+$it->rewind();
+foreach($it as $v) echo "$v\n";
+var_dump($it->valid());
+
+echo "===MANUAL===\n";
+
+$it->rewind();
+while($it->valid())
+{
+ echo $it->current() . "\n";
+ $it->next();
+ break;
+}
+$it->rewind();
+while($it->valid())
+{
+ echo $it->current() . "\n";
+ $it->next();
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+MyRecursiveIteratorIterator::beginIteration()
+1
+2
+31
+32
+331
+4
+MyRecursiveIteratorIterator::endIteration()
+===MORE===
+MyRecursiveIteratorIterator::beginIteration()
+1
+2
+31
+32
+331
+4
+MyRecursiveIteratorIterator::endIteration()
+===MORE===
+MyRecursiveIteratorIterator::beginIteration()
+1
+2
+31
+32
+331
+4
+MyRecursiveIteratorIterator::endIteration()
+bool(false)
+===MANUAL===
+MyRecursiveIteratorIterator::beginIteration()
+1
+1
+2
+31
+32
+331
+4
+MyRecursiveIteratorIterator::endIteration()
+===DONE===
diff --git a/ext/spl/tests/iterator_026.phpt b/ext/spl/tests/iterator_026.phpt
new file mode 100644
index 0000000..8eb77a7
--- /dev/null
+++ b/ext/spl/tests/iterator_026.phpt
@@ -0,0 +1,38 @@
+--TEST--
+SPL: CachingIterator::hasNext()
+--FILE--
+<?php
+
+$ar = array(1, 2, array(31, 32, array(331)), 4);
+
+$it = new RecursiveArrayIterator($ar);
+$it = new RecursiveCachingIterator($it);
+$it = new RecursiveIteratorIterator($it);
+
+foreach($it as $k=>$v)
+{
+ echo "$k=>$v\n";
+ echo "hasNext: " . ($it->getInnerIterator()->hasNext() ? "yes" : "no") . "\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+0=>1
+hasNext: yes
+1=>2
+hasNext: yes
+
+Notice: Array to string conversion in %siterator_026.php on line %d
+0=>31
+hasNext: yes
+1=>32
+hasNext: yes
+
+Notice: Array to string conversion in %siterator_026.php on line %d
+0=>331
+hasNext: no
+3=>4
+hasNext: no
+===DONE===
diff --git a/ext/spl/tests/iterator_027.phpt b/ext/spl/tests/iterator_027.phpt
new file mode 100644
index 0000000..fd9ba70
--- /dev/null
+++ b/ext/spl/tests/iterator_027.phpt
@@ -0,0 +1,83 @@
+--TEST--
+SPL: CachingIterator::FULL_CACHE
+--FILE--
+<?php
+
+$ar = array(1, 2, array(31, 32, array(331)), 4);
+
+$it = new RecursiveArrayIterator($ar);
+$it = new RecursiveIteratorIterator($it);
+$it = new CachingIterator($it, CachingIterator::FULL_CACHE);
+
+foreach($it as $k=>$v)
+{
+ echo "$k=>$v\n";
+}
+
+echo "===CHECK===\n";
+
+for ($i = 0; $i < 4; $i++)
+{
+ if (isset($it[$i]))
+ {
+ var_dump($i, $it[$i]);
+ }
+}
+
+$it[2] = 'foo';
+$it[3] = 'bar';
+$it['baz'] = '25';
+
+var_dump($it[2]);
+var_dump($it[3]);
+var_dump($it['baz']);
+
+unset($it[0]);
+unset($it[2]);
+unset($it['baz']);
+
+var_dump(isset($it[0])); // unset
+var_dump(isset($it[1])); // still present
+var_dump(isset($it[2])); // unset
+var_dump(isset($it[3])); // still present
+var_dump(isset($it['baz']));
+
+echo "===REWIND===\n";
+
+$it->rewind(); // cleans and reads first element
+var_dump(isset($it[0])); // pre-fetched
+var_dump(isset($it[1])); // deleted
+var_dump(isset($it[2])); // unset
+var_dump(isset($it[3])); // deleted
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+0=>1
+1=>2
+0=>31
+1=>32
+0=>331
+3=>4
+===CHECK===
+int(0)
+int(331)
+int(1)
+int(32)
+int(3)
+int(4)
+string(3) "foo"
+string(3) "bar"
+string(2) "25"
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+===REWIND===
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/iterator_028.phpt b/ext/spl/tests/iterator_028.phpt
new file mode 100644
index 0000000..8b53b21
--- /dev/null
+++ b/ext/spl/tests/iterator_028.phpt
@@ -0,0 +1,112 @@
+--TEST--
+SPL: RecursiveIteratorIterator and setMaxDepth()
+--FILE--
+<?php
+
+$ar = array(1, 2, array(31, 32, array(331, array(3321, array(33221)))), 4);
+
+$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($ar));
+
+echo "===?===\n";
+var_dump($it->getMaxDepth());
+foreach($it as $v) echo $it->getDepth() . ": $v\n";
+
+echo "===2===\n";
+$it->setMaxDepth(2);
+var_dump($it->getMaxDepth());
+foreach($it as $v) echo $it->getDepth() . ": $v\n";
+
+echo "===X===\n";
+$it->setMaxDepth();
+var_dump($it->getMaxDepth());
+foreach($it as $v) echo $it->getDepth() . ": $v\n";
+
+echo "===3===\n";
+$it->setMaxDepth(3);
+var_dump($it->getMaxDepth());
+foreach($it as $v) echo $it->getDepth() . ": $v\n";
+
+echo "===5===\n";
+$it->setMaxDepth(5);
+var_dump($it->getMaxDepth());
+foreach($it as $v) echo $it->getDepth() . ": $v\n";
+
+echo "===0===\n";
+$it->setMaxDepth(0);
+var_dump($it->getMaxDepth());
+foreach($it as $v) echo $it->getDepth() . ": $v\n";
+
+echo "===-1===\n";
+$it->setMaxDepth(-1);
+var_dump($it->getMaxDepth());
+try
+{
+ $it->setMaxDepth(4);
+ $it->setMaxDepth(-2);
+}
+catch(Exception $e)
+{
+ var_dump($e->getMessage());
+}
+var_dump($it->getMaxDepth());
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+===?===
+bool(false)
+0: 1
+0: 2
+1: 31
+1: 32
+2: 331
+3: 3321
+4: 33221
+0: 4
+===2===
+int(2)
+0: 1
+0: 2
+1: 31
+1: 32
+2: 331
+0: 4
+===X===
+bool(false)
+0: 1
+0: 2
+1: 31
+1: 32
+2: 331
+3: 3321
+4: 33221
+0: 4
+===3===
+int(3)
+0: 1
+0: 2
+1: 31
+1: 32
+2: 331
+3: 3321
+0: 4
+===5===
+int(5)
+0: 1
+0: 2
+1: 31
+1: 32
+2: 331
+3: 3321
+4: 33221
+0: 4
+===0===
+int(0)
+0: 1
+0: 2
+0: 4
+===-1===
+bool(false)
+string(33) "Parameter max_depth must be >= -1"
+int(4)
+===DONE===
diff --git a/ext/spl/tests/iterator_029.phpt b/ext/spl/tests/iterator_029.phpt
new file mode 100644
index 0000000..e5bfde0
--- /dev/null
+++ b/ext/spl/tests/iterator_029.phpt
@@ -0,0 +1,38 @@
+--TEST--
+SPL: RegexIterator
+--FILE--
+<?php
+
+$ar = array(0, "123", 123, 22 => "abc", "a2b", 22, "a2d" => 7, 42);
+
+foreach(new RegexIterator(new ArrayIterator($ar), "/2/") as $k => $v)
+{
+ echo "$k=>$v\n";
+}
+
+?>
+===KEY===
+<?php
+
+foreach(new RegexIterator(new ArrayIterator($ar), "/2/", 0, RegexIterator::USE_KEY) as $k => $v)
+{
+ echo "$k=>$v\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+1=>123
+2=>123
+23=>a2b
+24=>22
+25=>42
+===KEY===
+2=>123
+22=>abc
+23=>a2b
+24=>22
+a2d=>7
+25=>42
+===DONE===
diff --git a/ext/spl/tests/iterator_030.phpt b/ext/spl/tests/iterator_030.phpt
new file mode 100644
index 0000000..29d147f
--- /dev/null
+++ b/ext/spl/tests/iterator_030.phpt
@@ -0,0 +1,44 @@
+--TEST--
+SPL: EmptyIterator access
+--FILE--
+<?php
+
+$it = new EmptyIterator;
+
+var_dump($it->valid());
+$it->rewind();
+var_dump($it->valid());
+$it->next();
+var_dump($it->valid());
+
+try
+{
+ var_dump($it->key());
+}
+catch(BadMethodCallException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+try
+{
+ var_dump($it->current());
+}
+catch(BadMethodCallException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+var_dump($it->valid());
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+bool(false)
+bool(false)
+bool(false)
+Accessing the key of an EmptyIterator
+Accessing the value of an EmptyIterator
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/iterator_031.phpt b/ext/spl/tests/iterator_031.phpt
new file mode 100644
index 0000000..40342f4
--- /dev/null
+++ b/ext/spl/tests/iterator_031.phpt
@@ -0,0 +1,116 @@
+--TEST--
+SPL: AppendIterator::append() rewinds when neccessary
+--FILE--
+<?php
+
+class MyArrayIterator extends ArrayIterator
+{
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ parent::rewind();
+ }
+}
+
+$it = new MyArrayIterator(array(1,2));
+
+foreach($it as $k=>$v)
+{
+ echo "$k=>$v\n";
+}
+
+class MyAppendIterator extends AppendIterator
+{
+ function __construct()
+ {
+ echo __METHOD__ . "\n";
+ }
+
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ parent::rewind();
+ }
+
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ return parent::valid();
+ }
+
+ function append(Iterator $what)
+ {
+ echo __METHOD__ . "\n";
+ parent::append($what);
+ }
+
+ function parent__construct()
+ {
+ parent::__construct();
+ }
+}
+
+$ap = new MyAppendIterator;
+
+try
+{
+ $ap->append($it);
+}
+catch(LogicException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+$ap->parent__construct();
+
+try
+{
+ $ap->parent__construct($it);
+}
+catch(BadMethodCallException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+$ap->append($it);
+$ap->append($it);
+$ap->append($it);
+
+foreach($ap as $k=>$v)
+{
+ echo "$k=>$v\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+MyArrayIterator::rewind
+0=>1
+1=>2
+MyAppendIterator::__construct
+MyAppendIterator::append
+The object is in an invalid state as the parent constructor was not called
+AppendIterator::getIterator() must be called exactly once per instance
+MyAppendIterator::append
+MyArrayIterator::rewind
+MyAppendIterator::append
+MyAppendIterator::append
+MyAppendIterator::rewind
+MyArrayIterator::rewind
+MyAppendIterator::valid
+0=>1
+MyAppendIterator::valid
+1=>2
+MyArrayIterator::rewind
+MyAppendIterator::valid
+0=>1
+MyAppendIterator::valid
+1=>2
+MyArrayIterator::rewind
+MyAppendIterator::valid
+0=>1
+MyAppendIterator::valid
+1=>2
+MyAppendIterator::valid
+===DONE===
diff --git a/ext/spl/tests/iterator_032.phpt b/ext/spl/tests/iterator_032.phpt
new file mode 100644
index 0000000..84eb8e6
--- /dev/null
+++ b/ext/spl/tests/iterator_032.phpt
@@ -0,0 +1,50 @@
+--TEST--
+SPL: LimitIterator::getPosition()
+--FILE--
+<?php
+
+$it = new LimitIterator(new ArrayIterator(array(1,2,3,4)), 1, 2);
+
+foreach($it as $k=>$v)
+{
+ echo "$k=>$v\n";
+ var_dump($it->getPosition());
+}
+
+try
+{
+ $it->seek(0);
+}
+catch(OutOfBoundsException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+$it->seek(2);
+var_dump($it->current());
+
+try
+{
+ $it->seek(3);
+}
+catch(OutOfBoundsException $e)
+{
+ echo $e->getMessage() . "\n";
+}
+
+$it->next();
+var_dump($it->valid());
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+1=>2
+int(1)
+2=>3
+int(2)
+Cannot seek to 0 which is below the offset 1
+int(3)
+Cannot seek to 3 which is behind offset 1 plus count 2
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/iterator_033.phpt b/ext/spl/tests/iterator_033.phpt
new file mode 100644
index 0000000..548759c
--- /dev/null
+++ b/ext/spl/tests/iterator_033.phpt
@@ -0,0 +1,44 @@
+--TEST--
+SPL: ParentIterator
+--FILE--
+<?php
+
+$it = new ParentIterator(new RecursiveArrayIterator(array(1,array(21,22, array(231)),3)));
+
+foreach(new RecursiveIteratorIterator($it) as $k=>$v)
+{
+ var_dump($k);
+ var_dump($v);
+}
+
+echo "==SECOND==\n";
+
+foreach(new RecursiveIteratorIterator($it, 1) as $k=>$v)
+{
+ var_dump($k);
+ var_dump($v);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+==SECOND==
+int(1)
+array(3) {
+ [0]=>
+ int(21)
+ [1]=>
+ int(22)
+ [2]=>
+ array(1) {
+ [0]=>
+ int(231)
+ }
+}
+int(2)
+array(1) {
+ [0]=>
+ int(231)
+}
+===DONE===
diff --git a/ext/spl/tests/iterator_034.phpt b/ext/spl/tests/iterator_034.phpt
new file mode 100644
index 0000000..3329e74
--- /dev/null
+++ b/ext/spl/tests/iterator_034.phpt
@@ -0,0 +1,188 @@
+--TEST--
+SPL: RecursiveIteratorIterator and break deep
+--FILE--
+<?php
+
+class MyRecursiveArrayIterator extends RecursiveArrayIterator
+{
+ function valid()
+ {
+ if (!parent::valid())
+ {
+ echo __METHOD__ . "() = false\n";
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ function getChildren()
+ {
+ echo __METHOD__ . "()\n";
+ return parent::getChildren();
+ }
+
+ function rewind()
+ {
+ echo __METHOD__ . "()\n";
+ parent::rewind();
+ }
+}
+
+class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator
+{
+ private $max_depth;
+ private $over = 0;
+
+ function __construct($it, $max_depth)
+ {
+ $this->max_depth = $max_depth;
+ parent::__construct($it);
+ }
+
+ function rewind()
+ {
+ echo __METHOD__ . "() - BEGIN\n";
+ parent::rewind();
+ echo __METHOD__ . "() - DONE\n";
+ }
+
+ function valid()
+ {
+ echo __METHOD__ . "()\n";
+ return parent::valid();
+ }
+
+ function current()
+ {
+ echo __METHOD__ . "()\n";
+ return parent::current();
+ }
+
+ function key()
+ {
+ echo __METHOD__ . "()\n";
+ return parent::key();
+ }
+
+ function next()
+ {
+ echo __METHOD__ . "()\n";
+ parent::next();
+ }
+
+ function callHasChildren()
+ {
+ $has = parent::callHasChildren();
+ $res = $this->getDepth() < $this->max_depth && $has;
+ echo __METHOD__ . "(".$this->getDepth().") = ".($res?"yes":"no")."/".($has?"yes":"no")."\n";
+ return $res;
+ }
+
+ function beginChildren()
+ {
+ echo __METHOD__ . "(".$this->getDepth().")\n";
+ parent::beginChildren();
+ }
+
+ function endChildren()
+ {
+ echo __METHOD__ . "(".$this->getDepth().")\n";
+ parent::endChildren();
+ }
+}
+
+$p = 0;
+$it = new RecursiveArrayIteratorIterator(new MyRecursiveArrayIterator(array("a", array("ba", array("bba", "bbb"), array(array("bcaa"), array("bcba"))), array("ca"), "d")), 2);
+foreach($it as $k=>$v)
+{
+ if (is_array($v)) $v = join('',$v);
+ echo "$k=>$v\n";
+ if ($p++ == 5)
+ {
+ echo "===BREAK===\n";
+ break;
+ }
+}
+
+echo "===FOREND===\n";
+
+$it->rewind();
+
+echo "===CHECK===\n";
+
+var_dump($it->valid());
+var_dump($it->current() == "a");
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+RecursiveArrayIteratorIterator::rewind() - BEGIN
+MyRecursiveArrayIterator::rewind()
+RecursiveArrayIteratorIterator::callHasChildren(0) = no/no
+RecursiveArrayIteratorIterator::rewind() - DONE
+RecursiveArrayIteratorIterator::valid()
+RecursiveArrayIteratorIterator::current()
+RecursiveArrayIteratorIterator::key()
+0=>a
+RecursiveArrayIteratorIterator::next()
+RecursiveArrayIteratorIterator::callHasChildren(0) = yes/yes
+MyRecursiveArrayIterator::getChildren()
+MyRecursiveArrayIterator::rewind()
+RecursiveArrayIteratorIterator::beginChildren(1)
+RecursiveArrayIteratorIterator::callHasChildren(1) = no/no
+RecursiveArrayIteratorIterator::valid()
+RecursiveArrayIteratorIterator::current()
+RecursiveArrayIteratorIterator::key()
+0=>ba
+RecursiveArrayIteratorIterator::next()
+RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
+MyRecursiveArrayIterator::getChildren()
+MyRecursiveArrayIterator::rewind()
+RecursiveArrayIteratorIterator::beginChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/no
+RecursiveArrayIteratorIterator::valid()
+RecursiveArrayIteratorIterator::current()
+RecursiveArrayIteratorIterator::key()
+0=>bba
+RecursiveArrayIteratorIterator::next()
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/no
+RecursiveArrayIteratorIterator::valid()
+RecursiveArrayIteratorIterator::current()
+RecursiveArrayIteratorIterator::key()
+1=>bbb
+RecursiveArrayIteratorIterator::next()
+MyRecursiveArrayIterator::valid() = false
+RecursiveArrayIteratorIterator::endChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(1) = yes/yes
+MyRecursiveArrayIterator::getChildren()
+MyRecursiveArrayIterator::rewind()
+RecursiveArrayIteratorIterator::beginChildren(2)
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
+RecursiveArrayIteratorIterator::valid()
+RecursiveArrayIteratorIterator::current()
+RecursiveArrayIteratorIterator::key()
+0=>bcaa
+RecursiveArrayIteratorIterator::next()
+RecursiveArrayIteratorIterator::callHasChildren(2) = no/yes
+RecursiveArrayIteratorIterator::valid()
+RecursiveArrayIteratorIterator::current()
+RecursiveArrayIteratorIterator::key()
+1=>bcba
+===BREAK===
+===FOREND===
+RecursiveArrayIteratorIterator::rewind() - BEGIN
+RecursiveArrayIteratorIterator::endChildren(1)
+RecursiveArrayIteratorIterator::endChildren(0)
+MyRecursiveArrayIterator::rewind()
+RecursiveArrayIteratorIterator::callHasChildren(0) = no/no
+RecursiveArrayIteratorIterator::rewind() - DONE
+===CHECK===
+RecursiveArrayIteratorIterator::valid()
+bool(true)
+RecursiveArrayIteratorIterator::current()
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/iterator_035.phpt b/ext/spl/tests/iterator_035.phpt
new file mode 100644
index 0000000..9ce098b
--- /dev/null
+++ b/ext/spl/tests/iterator_035.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: ArrayIterator and values assigned by reference
+--FILE--
+<?php
+
+$tmp = 1;
+
+$a = new ArrayIterator();
+$a[] = $tmp;
+$a[] = &$tmp;
+
+echo "Done\n";
+?>
+--EXPECTF--
+Fatal error: Cannot assign by reference to overloaded object in %s on line %d
diff --git a/ext/spl/tests/iterator_036.phpt b/ext/spl/tests/iterator_036.phpt
new file mode 100644
index 0000000..9a9e66b
--- /dev/null
+++ b/ext/spl/tests/iterator_036.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: CachingIterator and __toString and flags = 0
+--FILE--
+<?php
+
+function test($it)
+{
+ foreach($it as $v)
+ {
+ var_dump((string)$it);
+ }
+}
+
+$ar = new ArrayIterator(array(1, 2, 3));
+
+test(new CachingIterator($ar, 0));
+
+?>
+===DONE===
+--EXPECTF--
+
+Fatal error: Method CachingIterator::__toString() must not throw an exception in %siterator_036.php on line %d
diff --git a/ext/spl/tests/iterator_037.phpt b/ext/spl/tests/iterator_037.phpt
new file mode 100644
index 0000000..2aa61bb
--- /dev/null
+++ b/ext/spl/tests/iterator_037.phpt
@@ -0,0 +1,131 @@
+--TEST--
+SPL: CachingIterator and __toString
+--FILE--
+<?php
+
+function test($ar, $flags)
+{
+ echo "===$flags===\n";
+ $it = new CachingIterator($ar, 0);
+ try
+ {
+ $it->setFlags($flags);
+ }
+ catch (Exception $e)
+ {
+ echo 'Exception: ' . $e->getMessage() . "\n";
+ var_dump($it->getFlags());
+ return;
+ }
+ var_dump($it->getFlags());
+ try
+ {
+ foreach($it as $v)
+ {
+ var_dump((string)$it);
+ }
+ }
+ catch (Exception $e)
+ {
+ echo 'Exception: ' . $e->getMessage() . "\n";
+ }
+}
+
+class MyItem
+{
+ function __construct($value)
+ {
+ $this->value = $value;
+ }
+
+ function __toString()
+ {
+ return (string)$this->value;
+ }
+}
+
+class MyArrayIterator extends ArrayIterator
+{
+ function __toString()
+ {
+ return $this->key() . ':' . $this->current();
+ }
+}
+
+$ar = new MyArrayIterator(array(1, 2, 3));
+
+test($ar, CachingIterator::CALL_TOSTRING);
+test($ar, CachingIterator::TOSTRING_USE_KEY);
+test($ar, CachingIterator::TOSTRING_USE_CURRENT);
+
+$ar = new MyArrayIterator(array(new MyItem(1), new MyItem(2), new MyItem(3)));
+
+test($ar, CachingIterator::TOSTRING_USE_INNER);
+test($ar, CachingIterator::CALL_TOSTRING | CachingIterator::TOSTRING_USE_KEY);
+test($ar, CachingIterator::CALL_TOSTRING | CachingIterator::TOSTRING_USE_CURRENT);
+test($ar, CachingIterator::CALL_TOSTRING | CachingIterator::TOSTRING_USE_INNER);
+test($ar, CachingIterator::TOSTRING_USE_KEY | CachingIterator::TOSTRING_USE_CURRENT);
+test($ar, CachingIterator::TOSTRING_USE_KEY | CachingIterator::TOSTRING_USE_INNER);
+
+echo "===X===\n";
+try
+{
+ $it = new CachingIterator($ar, CachingIterator::CALL_TOSTRING);
+ $it->setFlags(0);
+}
+catch (Exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+try
+{
+ $it = new CachingIterator($ar, CachingIterator::TOSTRING_USE_INNER);
+ $it->setFlags(0);
+}
+catch (Exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+===1===
+int(1)
+string(1) "1"
+string(1) "2"
+string(1) "3"
+===2===
+int(2)
+string(1) "0"
+string(1) "1"
+string(1) "2"
+===4===
+int(4)
+string(1) "1"
+string(1) "2"
+string(1) "3"
+===8===
+int(8)
+string(3) "0:1"
+string(3) "1:2"
+string(3) "2:3"
+===3===
+Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER
+int(0)
+===5===
+Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER
+int(0)
+===9===
+Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER
+int(0)
+===6===
+Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER
+int(0)
+===10===
+Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER
+int(0)
+===X===
+Exception: Unsetting flag CALL_TO_STRING is not possible
+Exception: Unsetting flag TOSTRING_USE_INNER is not possible
+===DONE===
diff --git a/ext/spl/tests/iterator_038.phpt b/ext/spl/tests/iterator_038.phpt
new file mode 100644
index 0000000..9b890e2
--- /dev/null
+++ b/ext/spl/tests/iterator_038.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: RoRewindIterator and string keys
+--FILE--
+<?php
+
+foreach(new NoRewindIterator(new ArrayIterator(array('Hello'=>0, 'World'=>1))) as $k => $v)
+{
+ var_dump($v);
+ var_dump($k);
+}
+
+?>
+===DONE===
+--EXPECT--
+int(0)
+string(5) "Hello"
+int(1)
+string(5) "World"
+===DONE===
diff --git a/ext/spl/tests/iterator_039.phpt b/ext/spl/tests/iterator_039.phpt
new file mode 100644
index 0000000..17c9bc1
--- /dev/null
+++ b/ext/spl/tests/iterator_039.phpt
@@ -0,0 +1,121 @@
+--TEST--
+SPL: LimitIterator and backward seeking
+--FILE--
+<?php
+
+class NumericArrayIterator implements Iterator
+{
+ protected $a;
+ protected $i = 0;
+
+ public function __construct($a)
+ {
+ echo __METHOD__ . "\n";
+ $this->a = $a;
+ }
+
+ public function valid()
+ {
+ echo __METHOD__ . "\n";
+ return $this->i < count($this->a);
+ }
+
+ public function rewind()
+ {
+ echo __METHOD__ . "\n";
+ $this->i = 0;
+ }
+
+ public function key()
+ {
+ echo __METHOD__ . "\n";
+ return $this->i;
+ }
+
+ public function current()
+ {
+ echo __METHOD__ . "\n";
+ return $this->a[$this->i];
+ }
+
+ public function next()
+ {
+ echo __METHOD__ . "\n";
+ $this->i++;
+ }
+}
+
+$it = new LimitIterator(new NumericArrayIterator(array(12, 25, 42, 56)));
+
+foreach($it as $k => $v)
+{
+ var_dump($k);
+ var_dump($v);
+}
+
+echo "===SEEK===\n";
+
+$it->seek(2);
+
+echo "===LOOP===\n";
+
+foreach(new NoRewindIterator($it) as $k => $v)
+{
+ var_dump($k);
+ var_dump($v);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+NumericArrayIterator::__construct
+NumericArrayIterator::rewind
+NumericArrayIterator::valid
+NumericArrayIterator::valid
+NumericArrayIterator::current
+NumericArrayIterator::key
+int(0)
+int(12)
+NumericArrayIterator::next
+NumericArrayIterator::valid
+NumericArrayIterator::current
+NumericArrayIterator::key
+int(1)
+int(25)
+NumericArrayIterator::next
+NumericArrayIterator::valid
+NumericArrayIterator::current
+NumericArrayIterator::key
+int(2)
+int(42)
+NumericArrayIterator::next
+NumericArrayIterator::valid
+NumericArrayIterator::current
+NumericArrayIterator::key
+int(3)
+int(56)
+NumericArrayIterator::next
+NumericArrayIterator::valid
+===SEEK===
+NumericArrayIterator::rewind
+NumericArrayIterator::valid
+NumericArrayIterator::next
+NumericArrayIterator::valid
+NumericArrayIterator::next
+NumericArrayIterator::valid
+NumericArrayIterator::valid
+NumericArrayIterator::current
+NumericArrayIterator::key
+===LOOP===
+int(2)
+int(42)
+NumericArrayIterator::next
+NumericArrayIterator::valid
+NumericArrayIterator::current
+NumericArrayIterator::key
+int(3)
+int(56)
+NumericArrayIterator::next
+NumericArrayIterator::valid
+===DONE===
diff --git a/ext/spl/tests/iterator_040.phpt b/ext/spl/tests/iterator_040.phpt
new file mode 100644
index 0000000..ae00c81
--- /dev/null
+++ b/ext/spl/tests/iterator_040.phpt
@@ -0,0 +1,47 @@
+--TEST--
+SPL: RecursiveFilterIterator
+--FILE--
+<?php
+
+class MyRecursiveFilterIterator extends RecursiveFilterIterator
+{
+ function accept()
+ {
+ return true;
+ }
+}
+
+$ar = array(1, array(21, 22), 3);
+$it = new RecursiveArrayIterator($ar);
+$it = new MyRecursiveFilterIterator($it);
+$it = new RecursiveIteratorIterator($it);
+
+foreach($it as $k => $v)
+{
+ echo "===\n";
+ var_dump($it->getDepth());
+ var_dump($k);
+ var_dump($v);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+===
+int(0)
+int(0)
+int(1)
+===
+int(1)
+int(0)
+int(21)
+===
+int(1)
+int(1)
+int(22)
+===
+int(0)
+int(2)
+int(3)
+===DONE===
diff --git a/ext/spl/tests/iterator_041.phpt b/ext/spl/tests/iterator_041.phpt
new file mode 100644
index 0000000..e00ac6b
--- /dev/null
+++ b/ext/spl/tests/iterator_041.phpt
@@ -0,0 +1,117 @@
+--TEST--
+SPL: iterator_to_array() and exceptions
+--FILE--
+<?php
+
+class MyArrayIterator extends ArrayIterator
+{
+ static protected $fail = 0;
+ public $state;
+
+ static function fail($state, $method)
+ {
+ if (self::$fail == $state)
+ {
+ throw new Exception("State $state: $method()");
+ }
+ }
+
+ function __construct()
+ {
+ $this->state = MyArrayIterator::$fail;
+ self::fail(0, __FUNCTION__);
+ parent::__construct(array(1, 2));
+ self::fail(1, __FUNCTION__);
+ }
+
+ function rewind()
+ {
+ self::fail(2, __FUNCTION__);
+ return parent::rewind();
+ }
+
+ function valid()
+ {
+ self::fail(3, __FUNCTION__);
+ return parent::valid();
+ }
+
+ function current()
+ {
+ self::fail(4, __FUNCTION__);
+ return parent::current();
+ }
+
+ function key()
+ {
+ self::fail(5, __FUNCTION__);
+ return parent::key();
+ }
+
+ function next()
+ {
+ self::fail(6, __FUNCTION__);
+ return parent::next();
+ }
+
+ function __destruct()
+ {
+// self::fail(7, __FUNCTION__);
+ }
+
+ static function test($func, $skip = null)
+ {
+ echo "===$func===\n";
+ self::$fail = 0;
+ while(self::$fail < 10)
+ {
+ try
+ {
+ var_dump($func(new MyArrayIterator()));
+ break;
+ }
+ catch (Exception $e)
+ {
+ echo $e->getMessage() . "\n";
+ }
+ if (isset($skip[self::$fail]))
+ {
+ self::$fail = $skip[self::$fail];
+ }
+ else
+ {
+ self::$fail++;
+ }
+ }
+ }
+}
+
+MyArrayIterator::test('iterator_to_array');
+MyArrayIterator::test('iterator_count', array(3 => 6));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+===iterator_to_array===
+State 0: __construct()
+State 1: __construct()
+State 2: rewind()
+State 3: valid()
+State 4: current()
+State 5: key()
+State 6: next()
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+}
+===iterator_count===
+State 0: __construct()
+State 1: __construct()
+State 2: rewind()
+State 3: valid()
+State 6: next()
+int(2)
+===DONE===
diff --git a/ext/spl/tests/iterator_041a.phpt b/ext/spl/tests/iterator_041a.phpt
new file mode 100644
index 0000000..ec999a5
--- /dev/null
+++ b/ext/spl/tests/iterator_041a.phpt
@@ -0,0 +1,107 @@
+--TEST--
+SPL: iterator_to_array() and exceptions from destruct
+--FILE--
+<?php
+
+class MyArrayIterator extends ArrayIterator
+{
+ static protected $fail = 0;
+ public $state;
+
+ static function fail($state, $method)
+ {
+ if (self::$fail == $state)
+ {
+ throw new Exception("State $state: $method()");
+ }
+ }
+
+ function __construct()
+ {
+ $this->state = MyArrayIterator::$fail;
+ self::fail(0, __FUNCTION__);
+ parent::__construct(array(1, 2));
+ self::fail(1, __FUNCTION__);
+ }
+
+ function rewind()
+ {
+ self::fail(2, __FUNCTION__);
+ return parent::rewind();
+ }
+
+ function valid()
+ {
+ self::fail(3, __FUNCTION__);
+ return parent::valid();
+ }
+
+ function current()
+ {
+ self::fail(4, __FUNCTION__);
+ return parent::current();
+ }
+
+ function key()
+ {
+ self::fail(5, __FUNCTION__);
+ return parent::key();
+ }
+
+ function next()
+ {
+ self::fail(6, __FUNCTION__);
+ return parent::next();
+ }
+
+ function __destruct()
+ {
+ self::fail(7, __FUNCTION__);
+ }
+
+ static function test($func, $skip = null)
+ {
+ echo "===$func===\n";
+ self::$fail = 7;
+ while(self::$fail < 10)
+ {
+ try
+ {
+ var_dump($func(new MyArrayIterator()));
+ break;
+ }
+ catch (Exception $e)
+ {
+ echo $e->getMessage() . "\n";
+ }
+ if (isset($skip[self::$fail]))
+ {
+ self::$fail = $skip[self::$fail];
+ }
+ else
+ {
+ self::$fail++;
+ }
+ }
+ }
+}
+
+MyArrayIterator::test('iterator_to_array');
+MyArrayIterator::test('iterator_count', array(3 => 6));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+===iterator_to_array===
+State 7: __destruct()
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+}
+===iterator_count===
+State 7: __destruct()
+int(2)
+===DONE===
diff --git a/ext/spl/tests/iterator_041b.phpt b/ext/spl/tests/iterator_041b.phpt
new file mode 100644
index 0000000..e7ea8b8
--- /dev/null
+++ b/ext/spl/tests/iterator_041b.phpt
@@ -0,0 +1,123 @@
+--TEST--
+SPL: iterator_to_array() and exceptions from delayed destruct
+--FILE--
+<?php
+
+class MyArrayIterator extends ArrayIterator
+{
+ static protected $fail = 0;
+ public $state;
+
+ static function fail($state, $method)
+ {
+ if (self::$fail == $state)
+ {
+ throw new Exception("State $state: $method()");
+ }
+ }
+
+ function __construct()
+ {
+ $this->state = MyArrayIterator::$fail;
+ self::fail(0, __FUNCTION__);
+ parent::__construct(array(1, 2));
+ self::fail(1, __FUNCTION__);
+ }
+
+ function rewind()
+ {
+ self::fail(2, __FUNCTION__);
+ return parent::rewind();
+ }
+
+ function valid()
+ {
+ self::fail(3, __FUNCTION__);
+ return parent::valid();
+ }
+
+ function current()
+ {
+ self::fail(4, __FUNCTION__);
+ return parent::current();
+ }
+
+ function key()
+ {
+ self::fail(5, __FUNCTION__);
+ return parent::key();
+ }
+
+ function next()
+ {
+ self::fail(6, __FUNCTION__);
+ return parent::next();
+ }
+
+ function __destruct()
+ {
+ self::fail(7, __FUNCTION__);
+ }
+
+ static function test($func, $skip = null)
+ {
+ echo "===$func===\n";
+ self::$fail = 0;
+ while(self::$fail < 10)
+ {
+ try
+ {
+ var_dump($func(new MyArrayIterator()));
+ break;
+ }
+ catch (Exception $e)
+ {
+ echo $e->getMessage() . "\n";
+ }
+ if (isset($skip[self::$fail]))
+ {
+ self::$fail = $skip[self::$fail];
+ }
+ else
+ {
+ self::$fail++;
+ }
+ try {
+ $e = null;
+ } catch (Exception $e) {
+ }
+ }
+ }
+}
+
+MyArrayIterator::test('iterator_to_array');
+MyArrayIterator::test('iterator_count', array(3 => 6));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===iterator_to_array===
+State 0: __construct()
+State 1: __construct()
+State 2: rewind()
+State 3: valid()
+State 4: current()
+State 5: key()
+State 6: next()
+State 7: __destruct()
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+}
+===iterator_count===
+State 0: __construct()
+State 1: __construct()
+State 2: rewind()
+State 3: valid()
+State 6: next()
+State 7: __destruct()
+int(2)
+===DONE===
diff --git a/ext/spl/tests/iterator_042.phpt b/ext/spl/tests/iterator_042.phpt
new file mode 100644
index 0000000..95fea2f
--- /dev/null
+++ b/ext/spl/tests/iterator_042.phpt
@@ -0,0 +1,123 @@
+--TEST--
+SPL: AppendIterator and its ArrayIterator
+--FILE--
+<?php
+
+function test_error_handler($errno, $msg, $filename, $linenum, $vars)
+{
+ echo "Error $msg in $filename on line $linenum\n";
+ return true;
+}
+
+set_error_handler('test_error_handler');
+
+$it = new AppendIterator;
+
+$it->append(array());
+$it->append(new ArrayIterator(array(1)));
+$it->append(new ArrayIterator(array(21, 22)));
+
+var_dump($it->getArrayIterator());
+
+$it->append(new ArrayIterator(array(31, 32, 33)));
+
+var_dump($it->getArrayIterator());
+
+$idx = 0;
+
+foreach($it as $k => $v)
+{
+ echo '===' . $idx++ . "===\n";
+ var_dump($it->getIteratorIndex());
+ var_dump($k);
+ var_dump($v);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Error Argument 1 passed to AppendIterator::append() must implement interface Iterator, array given in %siterator_042.php on line %d
+object(ArrayIterator)#%d (1) {
+ %s"storage"%s"ArrayIterator":private]=>
+ array(2) {
+ [0]=>
+ object(ArrayIterator)#%d (1) {
+ %s"storage"%s"ArrayIterator":private]=>
+ array(1) {
+ [0]=>
+ int(1)
+ }
+ }
+ [1]=>
+ object(ArrayIterator)#%d (1) {
+ %s"storage"%s"ArrayIterator":private]=>
+ array(2) {
+ [0]=>
+ int(21)
+ [1]=>
+ int(22)
+ }
+ }
+ }
+}
+object(ArrayIterator)#%d (1) {
+ %s"storage"%s"ArrayIterator":private]=>
+ array(3) {
+ [0]=>
+ object(ArrayIterator)#%d (1) {
+ %s"storage"%s"ArrayIterator":private]=>
+ array(1) {
+ [0]=>
+ int(1)
+ }
+ }
+ [1]=>
+ object(ArrayIterator)#%d (1) {
+ %s"storage"%s"ArrayIterator":private]=>
+ array(2) {
+ [0]=>
+ int(21)
+ [1]=>
+ int(22)
+ }
+ }
+ [2]=>
+ object(ArrayIterator)#5 (1) {
+ %s"storage"%s"ArrayIterator":private]=>
+ array(3) {
+ [0]=>
+ int(31)
+ [1]=>
+ int(32)
+ [2]=>
+ int(33)
+ }
+ }
+ }
+}
+===0===
+int(0)
+int(0)
+int(1)
+===1===
+int(1)
+int(0)
+int(21)
+===2===
+int(1)
+int(1)
+int(22)
+===3===
+int(2)
+int(0)
+int(31)
+===4===
+int(2)
+int(1)
+int(32)
+===5===
+int(2)
+int(2)
+int(33)
+===DONE===
diff --git a/ext/spl/tests/iterator_043.phpt b/ext/spl/tests/iterator_043.phpt
new file mode 100644
index 0000000..301a593
--- /dev/null
+++ b/ext/spl/tests/iterator_043.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SPL: RecursiveCachingIterator and uninitialized getChildren()
+--FILE--
+<?php
+
+$it = new RecursiveCachingIterator(new RecursiveArrayIterator(array(1,2)));
+
+var_dump($it->getChildren());
+$it->rewind();
+var_dump($it->getChildren());
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+NULL
+NULL
+===DONE===
diff --git a/ext/spl/tests/iterator_044.phpt b/ext/spl/tests/iterator_044.phpt
new file mode 100644
index 0000000..1271cca
--- /dev/null
+++ b/ext/spl/tests/iterator_044.phpt
@@ -0,0 +1,165 @@
+--TEST--
+SPL: CachingIterator and offsetGet/Exists using flag FULL_CACHE
+--FILE--
+<?php
+
+class MyFoo
+{
+ function __toString()
+ {
+ return 'foo';
+ }
+}
+
+class MyCachingIterator extends CachingIterator
+{
+ function __construct(Iterator $it, $flags = 0)
+ {
+ parent::__construct($it, $flags);
+ }
+
+ function test($ar)
+ {
+ foreach($ar as $k => $v)
+ {
+ echo "===$k===\n";
+ var_dump($v);
+ var_dump($this->offsetExists($v));
+ var_dump($this->offsetGet($v));
+ }
+ }
+}
+
+$it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 2, 'bar'=>3, 4)));
+
+try
+{
+ var_dump($it->offsetExists(0));
+}
+catch(Exception $e)
+{
+ echo "Exception: " . $e->getMessage() . "\n";
+}
+
+try
+{
+ var_dump($it->offsetGet(0));
+}
+catch(Exception $e)
+{
+ echo "Exception: " . $e->getMessage() . "\n";
+}
+
+$it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 2, 'bar'=>3, 4)), CachingIterator::FULL_CACHE);
+
+var_dump($it->offsetExists());
+var_dump($it->offsetGet());
+
+$checks = array(0, new stdClass, new MyFoo, NULL, 2, 'foo', 3);
+
+$it->test($checks);
+
+echo "===FILL===\n";
+
+foreach($it as $v); // read all into cache
+
+$it->test($checks);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Exception: MyCachingIterator does not use a full cache (see CachingIterator::__construct)
+Exception: MyCachingIterator does not use a full cache (see CachingIterator::__construct)
+
+Warning: CachingIterator::offsetExists() expects exactly 1 parameter, 0 given in %siterator_044.php on line %d
+NULL
+
+Warning: CachingIterator::offsetGet() expects exactly 1 parameter, 0 given in %siterator_044.php on line %d
+NULL
+===0===
+int(0)
+bool(false)
+
+Notice: Undefined index: 0 in %siterator_044.php on line %d
+NULL
+===1===
+object(stdClass)#%d (0) {
+}
+
+Warning: CachingIterator::offsetExists() expects parameter 1 to be string, object given in %siterator_044.php on line %d
+NULL
+
+Warning: CachingIterator::offsetGet() expects parameter 1 to be string, object given in %siterator_044.php on line %d
+NULL
+===2===
+object(MyFoo)#%d (0) {
+}
+bool(false)
+
+Notice: Undefined index: foo in %siterator_044.php on line %d
+NULL
+===3===
+NULL
+bool(false)
+
+Notice: Undefined index: in %siterator_044.php on line %d
+NULL
+===4===
+int(2)
+bool(false)
+
+Notice: Undefined index: 2 in %siterator_044.php on line %d
+NULL
+===5===
+string(3) "foo"
+bool(false)
+
+Notice: Undefined index: foo in %siterator_044.php on line %d
+NULL
+===6===
+int(3)
+bool(false)
+
+Notice: Undefined index: 3 in %siterator_044.php on line %d
+NULL
+===FILL===
+===0===
+int(0)
+bool(true)
+int(0)
+===1===
+object(stdClass)#1 (0) {
+}
+
+Warning: CachingIterator::offsetExists() expects parameter 1 to be string, object given in %siterator_044.php on line %d
+NULL
+
+Warning: CachingIterator::offsetGet() expects parameter 1 to be string, object given in %siterator_044.php on line %d
+NULL
+===2===
+object(MyFoo)#2 (0) {
+}
+bool(true)
+int(1)
+===3===
+NULL
+bool(false)
+
+Notice: Undefined index: in %siterator_044.php on line %d
+NULL
+===4===
+int(2)
+bool(true)
+int(4)
+===5===
+string(3) "foo"
+bool(true)
+int(1)
+===6===
+int(3)
+bool(false)
+
+Notice: Undefined index: 3 in %siterator_044.php on line %d
+NULL
+===DONE===
diff --git a/ext/spl/tests/iterator_045.phpt b/ext/spl/tests/iterator_045.phpt
new file mode 100644
index 0000000..d76b2d9
--- /dev/null
+++ b/ext/spl/tests/iterator_045.phpt
@@ -0,0 +1,169 @@
+--TEST--
+SPL: CachingIterator and offsetSet/Unset, getCache using flag FULL_CACHE
+--FILE--
+<?php
+
+class MyFoo
+{
+ function __toString()
+ {
+ return 'foo';
+ }
+}
+
+class MyCachingIterator extends CachingIterator
+{
+ function __construct(Iterator $it, $flags = 0)
+ {
+ parent::__construct($it, $flags);
+ }
+
+ function testSet($ar)
+ {
+ echo __METHOD__ . "()\n";
+ foreach($ar as $k => $v)
+ {
+ echo "set($k,$v)\n";
+ $this->offsetSet($k, $v);
+ }
+ }
+
+ function testUnset($ar)
+ {
+ echo __METHOD__ . "()\n";
+ foreach($ar as $k => $v)
+ {
+ echo "unset($v)\n";
+ $this->offsetUnset($v);
+ }
+ }
+
+ function fill()
+ {
+ echo __METHOD__ . "()\n";
+ foreach($this as $v) ;
+ }
+
+ function show()
+ {
+ echo __METHOD__ . "()\n";
+ var_dump($this->getCache());
+ }
+}
+
+$it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 2, 'bar'=>3, 4)));
+
+try
+{
+ var_dump($it->offsetSet(0, 0));
+}
+catch(Exception $e)
+{
+ echo "Exception: " . $e->getMessage() . "\n";
+}
+
+try
+{
+ var_dump($it->offsetUnset(0));
+}
+catch(Exception $e)
+{
+ echo "Exception: " . $e->getMessage() . "\n";
+}
+
+$it = new MyCachingIterator(new ArrayIterator(array(0, 1, 2, 3)), CachingIterator::FULL_CACHE);
+
+var_dump($it->offsetSet());
+var_dump($it->offsetSet(0));
+var_dump($it->offsetUnset());
+
+$checks = array(0 => 25, 1 => 42, 3 => 'FooBar');
+$unsets = array(0, 2);
+
+$it->testSet($checks);
+$it->show();
+$it->testUnset($unsets);
+$it->show();
+$it->fill();
+$it->show();
+$it->testSet($checks);
+$it->show();
+$it->testUnset($unsets);
+$it->show();
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Exception: MyCachingIterator does not use a full cache (see CachingIterator::__construct)
+Exception: MyCachingIterator does not use a full cache (see CachingIterator::__construct)
+
+Warning: CachingIterator::offsetSet() expects exactly 2 parameters, 0 given in %siterator_045.php on line %d
+NULL
+
+Warning: CachingIterator::offsetSet() expects exactly 2 parameters, 1 given in %siterator_045.php on line %d
+NULL
+
+Warning: CachingIterator::offsetUnset() expects exactly 1 parameter, 0 given in %siterator_045.php on line %d
+NULL
+MyCachingIterator::testSet()
+set(0,25)
+set(1,42)
+set(3,FooBar)
+MyCachingIterator::show()
+array(3) {
+ [0]=>
+ int(25)
+ [1]=>
+ int(42)
+ [3]=>
+ string(6) "FooBar"
+}
+MyCachingIterator::testUnset()
+unset(0)
+unset(2)
+MyCachingIterator::show()
+array(2) {
+ [1]=>
+ int(42)
+ [3]=>
+ string(6) "FooBar"
+}
+MyCachingIterator::fill()
+MyCachingIterator::show()
+array(4) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(1)
+ [2]=>
+ int(2)
+ [3]=>
+ int(3)
+}
+MyCachingIterator::testSet()
+set(0,25)
+set(1,42)
+set(3,FooBar)
+MyCachingIterator::show()
+array(4) {
+ [0]=>
+ int(25)
+ [1]=>
+ int(42)
+ [2]=>
+ int(2)
+ [3]=>
+ string(6) "FooBar"
+}
+MyCachingIterator::testUnset()
+unset(0)
+unset(2)
+MyCachingIterator::show()
+array(2) {
+ [1]=>
+ int(42)
+ [3]=>
+ string(6) "FooBar"
+}
+===DONE===
diff --git a/ext/spl/tests/iterator_046.phpt b/ext/spl/tests/iterator_046.phpt
new file mode 100644
index 0000000..f57415a
--- /dev/null
+++ b/ext/spl/tests/iterator_046.phpt
@@ -0,0 +1,51 @@
+--TEST--
+SPL: CachingIterator and __toString using bypassed string keys
+--FILE--
+<?php
+
+class MyFoo
+{
+ function __toString()
+ {
+ return 'foo';
+ }
+}
+
+class MyCachingIterator extends CachingIterator
+{
+ function __construct(Iterator $it, $flags = 0)
+ {
+ parent::__construct($it, $flags);
+ }
+
+ function fill()
+ {
+ echo __METHOD__ . "()\n";
+ foreach($this as $v) ;
+ }
+
+ function show()
+ {
+ echo __METHOD__ . "()\n";
+ foreach($this as $v)
+ {
+ var_dump((string)$this);
+ }
+ }
+}
+
+$it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 'bar'=>2)), CachingIterator::TOSTRING_USE_KEY);
+
+$it->fill();
+$it->show();
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+MyCachingIterator::fill()
+MyCachingIterator::show()
+string(1) "0"
+string(3) "foo"
+string(3) "bar"
+===DONE===
diff --git a/ext/spl/tests/iterator_047.phpt b/ext/spl/tests/iterator_047.phpt
new file mode 100644
index 0000000..548f486
--- /dev/null
+++ b/ext/spl/tests/iterator_047.phpt
@@ -0,0 +1,125 @@
+--TEST--
+SPL: RecursiveCachingIterator and exception in has/getChildren
+--FILE--
+<?php
+
+class MyRecursiveArrayIterator extends RecursiveArrayIterator
+{
+ static public $fail = 0;
+
+ static function fail($state, $method)
+ {
+ if (self::$fail == $state)
+ {
+ throw new Exception("State $state: $method()");
+ }
+ }
+
+ function hasChildren()
+ {
+ echo __METHOD__ . "()\n";
+ self::fail(1, __METHOD__);
+ return parent::hasChildren();
+ }
+
+ function getChildren()
+ {
+ echo __METHOD__ . "()\n";
+ self::fail(2, __METHOD__);
+ return parent::getChildren();
+ }
+}
+
+class MyRecursiveCachingIterator extends RecursiveCachingIterator
+{
+ function show()
+ {
+ MyRecursiveArrayIterator::$fail = 0;
+ while(MyRecursiveArrayIterator::$fail < 4)
+ {
+ echo "===" . MyRecursiveArrayIterator::$fail . "===\n";
+ try
+ {
+ foreach(new RecursiveIteratorIterator($this) as $k => $v)
+ {
+ var_dump($k);
+ var_dump($v);
+ }
+ }
+ catch (Exception $e)
+ {
+ echo "Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n";
+ }
+ MyRecursiveArrayIterator::$fail++;
+ }
+ }
+}
+
+$it = new MyRecursiveArrayIterator(array(0, array(10), 2, array(30), 4));
+$it = new MyRecursiveCachingIterator($it);
+
+$it->show();
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===0===
+MyRecursiveArrayIterator::hasChildren()
+int(0)
+int(0)
+MyRecursiveArrayIterator::hasChildren()
+MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %siterator_047.php on line %d
+MyRecursiveArrayIterator::hasChildren()
+int(0)
+int(10)
+MyRecursiveArrayIterator::hasChildren()
+int(2)
+int(2)
+MyRecursiveArrayIterator::hasChildren()
+MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %siterator_047.php on line %d
+MyRecursiveArrayIterator::hasChildren()
+int(0)
+int(30)
+MyRecursiveArrayIterator::hasChildren()
+int(4)
+int(4)
+===1===
+MyRecursiveArrayIterator::hasChildren()
+Exception: State 1: MyRecursiveArrayIterator::hasChildren() in %s on line %d
+===2===
+MyRecursiveArrayIterator::hasChildren()
+int(0)
+int(0)
+MyRecursiveArrayIterator::hasChildren()
+MyRecursiveArrayIterator::getChildren()
+Exception: State 2: MyRecursiveArrayIterator::getChildren() in %s on line %d
+===3===
+MyRecursiveArrayIterator::hasChildren()
+int(0)
+int(0)
+MyRecursiveArrayIterator::hasChildren()
+MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %siterator_047.php on line %d
+MyRecursiveArrayIterator::hasChildren()
+int(0)
+int(10)
+MyRecursiveArrayIterator::hasChildren()
+int(2)
+int(2)
+MyRecursiveArrayIterator::hasChildren()
+MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %siterator_047.php on line %d
+MyRecursiveArrayIterator::hasChildren()
+int(0)
+int(30)
+MyRecursiveArrayIterator::hasChildren()
+int(4)
+int(4)
+===DONE===
diff --git a/ext/spl/tests/iterator_048.phpt b/ext/spl/tests/iterator_048.phpt
new file mode 100644
index 0000000..bad4e78
--- /dev/null
+++ b/ext/spl/tests/iterator_048.phpt
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveRegexIterator and exception in has/getChildren
+--FILE--
+<?php
+
+class MyRecursiveRegexIterator extends RecursiveRegexIterator
+{
+ function show()
+ {
+ foreach(new RecursiveIteratorIterator($this) as $k => $v)
+ {
+ var_dump($k);
+ var_dump($v);
+ }
+ }
+
+ function accept()
+ {
+ return $this->hasChildren() || parent::accept();
+ }
+}
+
+$ar = new RecursiveArrayIterator(array('Foo', array('Bar'), 'FooBar', array('Baz'), 'Biz'));
+$it = new MyRecursiveRegexIterator($ar, '/Bar/');
+
+$it->show();
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(0)
+string(3) "Bar"
+int(2)
+string(6) "FooBar"
+===DONE===
diff --git a/ext/spl/tests/iterator_049.phpt b/ext/spl/tests/iterator_049.phpt
new file mode 100644
index 0000000..b9ab2c3
--- /dev/null
+++ b/ext/spl/tests/iterator_049.phpt
@@ -0,0 +1,25 @@
+--TEST--
+SPL: ArrayIterator with NULL key
+--FILE--
+<?php
+
+$ar = new ArrayIterator(array(NULL=>NULL));
+@var_dump($ar);
+var_dump($ar->getArrayCopy());
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+object(ArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(1) {
+ [""]=>
+ NULL
+ }
+}
+array(1) {
+ [""]=>
+ NULL
+}
+===DONE===
diff --git a/ext/spl/tests/iterator_049b.phpt b/ext/spl/tests/iterator_049b.phpt
new file mode 100644
index 0000000..03c7350
--- /dev/null
+++ b/ext/spl/tests/iterator_049b.phpt
Binary files differ
diff --git a/ext/spl/tests/iterator_050.phpt b/ext/spl/tests/iterator_050.phpt
new file mode 100644
index 0000000..fed4a3b
--- /dev/null
+++ b/ext/spl/tests/iterator_050.phpt
@@ -0,0 +1,98 @@
+--TEST--
+SPL: RegexIterator::GET_MATCH
+--FILE--
+<?php
+
+class MyRegexIterator extends RegexIterator
+{
+ function show()
+ {
+ foreach($this as $k => $v)
+ {
+ var_dump($k);
+ var_dump($v);
+ }
+ }
+}
+
+$ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::GET_MATCH);
+$it->show();
+
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::GET_MATCH);
+$it->show();
+
+var_dump($ar);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(1)
+array(3) {
+ [0]=>
+ %s(3) "1,2"
+ [1]=>
+ %s(1) "1"
+ [2]=>
+ %s(1) "2"
+}
+int(2)
+array(3) {
+ [0]=>
+ %s(3) "1,2"
+ [1]=>
+ %s(1) "1"
+ [2]=>
+ %s(1) "2"
+}
+
+Notice: Array to string conversion in %siterator_050.php on line %d
+int(0)
+array(2) {
+ [0]=>
+ %s(1) "1"
+ [1]=>
+ %s(1) "1"
+}
+int(1)
+array(2) {
+ [0]=>
+ %s(1) "1"
+ [1]=>
+ %s(1) "1"
+}
+int(2)
+array(2) {
+ [0]=>
+ %s(1) "1"
+ [1]=>
+ %s(1) "1"
+}
+
+Notice: Array to string conversion in %siterator_050.php on line %d
+object(ArrayIterator)#%d (1) {
+ %s"storage"%s"ArrayIterator":private]=>
+ array(9) {
+ [0]=>
+ %s(1) "1"
+ [1]=>
+ %s(3) "1,2"
+ [2]=>
+ %s(5) "1,2,3"
+ [3]=>
+ %s(0) ""
+ [4]=>
+ NULL
+ [5]=>
+ array(0) {
+ }
+ [6]=>
+ %s(6) "FooBar"
+ [7]=>
+ %s(1) ","
+ [8]=>
+ %s(2) ",,"
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/iterator_051.phpt b/ext/spl/tests/iterator_051.phpt
new file mode 100644
index 0000000..2d198db
--- /dev/null
+++ b/ext/spl/tests/iterator_051.phpt
@@ -0,0 +1,96 @@
+--TEST--
+SPL: RegexIterator::GET_MATCH, USE_KEY
+--FILE--
+<?php
+
+class MyRegexIterator extends RegexIterator
+{
+ function show()
+ {
+ foreach($this as $k => $v)
+ {
+ var_dump($k);
+ var_dump($v);
+ }
+ }
+}
+
+$ar = new ArrayIterator(array('1'=>0,'1,2'=>1,'1,2,3'=>2,0=>3,'FooBar'=>4,','=>5,',,'=>6));
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::GET_MATCH, RegexIterator::USE_KEY);
+$it->show();
+
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::GET_MATCH, RegexIterator::USE_KEY);
+$it->show();
+
+var_dump($ar);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+string(3) "1,2"
+array(3) {
+ [0]=>
+ string(3) "1,2"
+ [1]=>
+ string(1) "1"
+ [2]=>
+ string(1) "2"
+}
+string(5) "1,2,3"
+array(3) {
+ [0]=>
+ string(3) "1,2"
+ [1]=>
+ string(1) "1"
+ [2]=>
+ string(1) "2"
+}
+int(1)
+array(2) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "1"
+}
+string(3) "1,2"
+array(2) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "1"
+}
+string(5) "1,2,3"
+array(2) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "1"
+}
+int(0)
+array(2) {
+ [0]=>
+ string(1) "0"
+ [1]=>
+ string(1) "0"
+}
+object(ArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(7) {
+ [1]=>
+ int(0)
+ ["1,2"]=>
+ int(1)
+ ["1,2,3"]=>
+ int(2)
+ [0]=>
+ int(3)
+ ["FooBar"]=>
+ int(4)
+ [","]=>
+ int(5)
+ [",,"]=>
+ int(6)
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/iterator_052.phpt b/ext/spl/tests/iterator_052.phpt
new file mode 100644
index 0000000..c68bd52
--- /dev/null
+++ b/ext/spl/tests/iterator_052.phpt
@@ -0,0 +1,319 @@
+--TEST--
+SPL: RegexIterator::ALL_MATCHES
+--FILE--
+<?php
+
+class MyRegexIterator extends RegexIterator
+{
+ public $uk, $re;
+
+ function __construct($it, $re, $mode, $flags = 0)
+ {
+ $this->uk = $flags & self::USE_KEY;
+ $this->re = $re;
+ parent::__construct($it, $re, $mode, $flags);
+ }
+
+ function show()
+ {
+ foreach($this as $k => $v)
+ {
+ var_dump($k);
+ var_dump($v);
+ }
+ }
+
+ function accept()
+ {
+ @preg_match_all($this->re, (string)($this->uk ? $this->key() : $this->current()), $sub);
+ $ret = parent::accept();
+ var_dump($sub == $this->current());
+ return $ret;
+ }
+}
+
+$ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::ALL_MATCHES);
+$it->show();
+
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::ALL_MATCHES);
+$it->show();
+
+var_dump($ar);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+bool(true)
+int(0)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(1)
+array(3) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "1,2"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "1"
+ }
+ [2]=>
+ array(1) {
+ [0]=>
+ string(1) "2"
+ }
+}
+bool(true)
+int(2)
+array(3) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(3) "1,2"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "1"
+ }
+ [2]=>
+ array(1) {
+ [0]=>
+ string(1) "2"
+ }
+}
+bool(true)
+int(3)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(4)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+
+Notice: Array to string conversion in %siterator_052.php on line %d
+bool(true)
+int(5)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(6)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(7)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(8)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(0)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "1"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "1"
+ }
+}
+bool(true)
+int(1)
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ }
+}
+bool(true)
+int(2)
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ [2]=>
+ string(1) "3"
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ [2]=>
+ string(1) "3"
+ }
+}
+bool(true)
+int(3)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(4)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+
+Notice: Array to string conversion in %siterator_052.php on line %d
+bool(true)
+int(5)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(6)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(7)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(8)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+object(ArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(9) {
+ [0]=>
+ %s(1) "1"
+ [1]=>
+ %s(3) "1,2"
+ [2]=>
+ %s(5) "1,2,3"
+ [3]=>
+ %s(0) ""
+ [4]=>
+ NULL
+ [5]=>
+ array(0) {
+ }
+ [6]=>
+ %s(6) "FooBar"
+ [7]=>
+ %s(1) ","
+ [8]=>
+ %s(2) ",,"
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/iterator_053.phpt b/ext/spl/tests/iterator_053.phpt
new file mode 100644
index 0000000..5d9c740
--- /dev/null
+++ b/ext/spl/tests/iterator_053.phpt
@@ -0,0 +1,315 @@
+--TEST--
+SPL: RegexIterator::ALL_MATCHES
+--FILE--
+<?php
+
+class MyRegexIterator extends RegexIterator
+{
+ public $uk, $re;
+
+ function __construct($it, $re, $mode, $flags = 0)
+ {
+ $this->uk = $flags & self::USE_KEY;
+ $this->re = $re;
+ parent::__construct($it, $re, $mode, $flags);
+ }
+
+ function show()
+ {
+ foreach($this as $k => $v)
+ {
+ var_dump($k);
+ var_dump($v);
+ }
+ }
+
+ function accept()
+ {
+ @preg_match_all($this->re, (string)($this->uk ? $this->key() : $this->current()), $sub);
+ $ret = parent::accept();
+ var_dump($sub == $this->current());
+ return $ret;
+ }
+}
+
+$ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::ALL_MATCHES, RegexIterator::USE_KEY);
+$it->show();
+
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::ALL_MATCHES, RegexIterator::USE_KEY);
+$it->show();
+
+var_dump($ar);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+bool(true)
+int(0)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(1)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(2)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(3)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(4)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(5)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(6)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(7)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(8)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(0)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "0"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "0"
+ }
+}
+bool(true)
+int(1)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "1"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "1"
+ }
+}
+bool(true)
+int(2)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "2"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "2"
+ }
+}
+bool(true)
+int(3)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "3"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "3"
+ }
+}
+bool(true)
+int(4)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "4"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "4"
+ }
+}
+bool(true)
+int(5)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "5"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "5"
+ }
+}
+bool(true)
+int(6)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "6"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "6"
+ }
+}
+bool(true)
+int(7)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "7"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "7"
+ }
+}
+bool(true)
+int(8)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "8"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "8"
+ }
+}
+object(ArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(9) {
+ [0]=>
+ %s(1) "1"
+ [1]=>
+ %s(3) "1,2"
+ [2]=>
+ %s(5) "1,2,3"
+ [3]=>
+ %s(0) ""
+ [4]=>
+ NULL
+ [5]=>
+ array(0) {
+ }
+ [6]=>
+ %s(6) "FooBar"
+ [7]=>
+ %s(1) ","
+ [8]=>
+ %s(2) ",,"
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/iterator_054.phpt b/ext/spl/tests/iterator_054.phpt
new file mode 100644
index 0000000..1f1cd58
--- /dev/null
+++ b/ext/spl/tests/iterator_054.phpt
@@ -0,0 +1,87 @@
+--TEST--
+SPL: RegexIterator::SPLIT
+--FILE--
+<?php
+
+class MyRegexIterator extends RegexIterator
+{
+ function show()
+ {
+ foreach($this as $k => $v)
+ {
+ var_dump($k);
+ var_dump($v);
+ }
+ }
+}
+
+$ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
+$it = new MyRegexIterator($ar, '/,/', RegexIterator::SPLIT);
+
+$it->show();
+
+var_dump($ar);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(1)
+array(2) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+}
+int(2)
+array(3) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ [2]=>
+ string(1) "3"
+}
+
+Notice: Array to string conversion in %siterator_054.php on line %d
+int(7)
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+}
+int(8)
+array(3) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+}
+object(ArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(9) {
+ [0]=>
+ %s(1) "1"
+ [1]=>
+ %s(3) "1,2"
+ [2]=>
+ %s(5) "1,2,3"
+ [3]=>
+ %s(0) ""
+ [4]=>
+ NULL
+ [5]=>
+ array(0) {
+ }
+ [6]=>
+ %s(6) "FooBar"
+ [7]=>
+ %s(1) ","
+ [8]=>
+ %s(2) ",,"
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/iterator_055.phpt b/ext/spl/tests/iterator_055.phpt
new file mode 100644
index 0000000..dec68a4
--- /dev/null
+++ b/ext/spl/tests/iterator_055.phpt
@@ -0,0 +1,62 @@
+--TEST--
+SPL: RegexIterator::SPLIT, USE_KEY
+--FILE--
+<?php
+
+class MyRegexIterator extends RegexIterator
+{
+ function show()
+ {
+ foreach($this as $k => $v)
+ {
+ var_dump($k);
+ var_dump($v);
+ }
+ }
+}
+
+$ar = new ArrayIterator(array('1'=>0,'1,2'=>1,'1,2,3'=>2,0=>3,'FooBar'=>4,','=>5,',,'=>6));
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::SPLIT, RegexIterator::USE_KEY);
+
+$it->show();
+
+var_dump($ar);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+string(3) "1,2"
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+}
+string(5) "1,2,3"
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(2) ",3"
+}
+object(ArrayIterator)#%d (1) {
+ ["storage":"ArrayIterator":private]=>
+ array(7) {
+ [1]=>
+ int(0)
+ ["1,2"]=>
+ int(1)
+ ["1,2,3"]=>
+ int(2)
+ [0]=>
+ int(3)
+ ["FooBar"]=>
+ int(4)
+ [","]=>
+ int(5)
+ [",,"]=>
+ int(6)
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/iterator_056.phpt b/ext/spl/tests/iterator_056.phpt
new file mode 100644
index 0000000..4b0e75a
--- /dev/null
+++ b/ext/spl/tests/iterator_056.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: FilterIterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myFilterIterator extends FilterIterator {
+ function accept() {
+
+ }
+}
+try {
+ $it = new myFilterIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
diff --git a/ext/spl/tests/iterator_057.phpt b/ext/spl/tests/iterator_057.phpt
new file mode 100644
index 0000000..602c125
--- /dev/null
+++ b/ext/spl/tests/iterator_057.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: ArrayIterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+/**
+ * From Docs: Construct a new array iterator from anything that has a hash table.
+ * NULL, NOTHING is not a hash table ;)
+ */
+class myArrayIterator extends ArrayIterator {
+}
+try {
+ $it = new myArrayIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+echo 'no Exception thrown'
+?>
+--EXPECT--
+no Exception thrown
diff --git a/ext/spl/tests/iterator_058.phpt b/ext/spl/tests/iterator_058.phpt
new file mode 100644
index 0000000..3f65ecb
--- /dev/null
+++ b/ext/spl/tests/iterator_058.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: Iterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myIterator implements Iterator {
+
+ function current() {}
+ function next() {}
+ function key() {}
+ function valid() {}
+ function rewind() {}
+
+}
+try {
+ $it = new myIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+echo 'no Exception thrown';
+?>
+--EXPECT--
+no Exception thrown
diff --git a/ext/spl/tests/iterator_059.phpt b/ext/spl/tests/iterator_059.phpt
new file mode 100644
index 0000000..8c579ae
--- /dev/null
+++ b/ext/spl/tests/iterator_059.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: CachingIterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myCachingIterator extends CachingIterator {
+
+}
+try {
+ $it = new myCachingIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
diff --git a/ext/spl/tests/iterator_060.phpt b/ext/spl/tests/iterator_060.phpt
new file mode 100644
index 0000000..0c3b6c2
--- /dev/null
+++ b/ext/spl/tests/iterator_060.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: RecursiveCachingIterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myRecursiveCachingIterator extends RecursiveCachingIterator {
+
+}
+try {
+ $it = new myRecursiveCachingIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
diff --git a/ext/spl/tests/iterator_061.phpt b/ext/spl/tests/iterator_061.phpt
new file mode 100644
index 0000000..472f8da
--- /dev/null
+++ b/ext/spl/tests/iterator_061.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: ParentIterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myParentIterator extends ParentIterator {
+
+}
+try {
+ $it = new myParentIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
diff --git a/ext/spl/tests/iterator_062.phpt b/ext/spl/tests/iterator_062.phpt
new file mode 100644
index 0000000..59a1dfa
--- /dev/null
+++ b/ext/spl/tests/iterator_062.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SPL: RecursiveIteratorIterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+}
+
+try {
+ $it = new myRecursiveIteratorIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
diff --git a/ext/spl/tests/iterator_063.phpt b/ext/spl/tests/iterator_063.phpt
new file mode 100644
index 0000000..4d4112b
--- /dev/null
+++ b/ext/spl/tests/iterator_063.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: LimitIterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myLimitIterator extends LimitIterator {
+
+}
+try {
+ $it = new myLimitIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
diff --git a/ext/spl/tests/iterator_064.phpt b/ext/spl/tests/iterator_064.phpt
new file mode 100644
index 0000000..6a62e6c
--- /dev/null
+++ b/ext/spl/tests/iterator_064.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: CachingIterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myCachingIterator extends CachingIterator {}
+try {
+ $it = new myCachingIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
diff --git a/ext/spl/tests/iterator_065.phpt b/ext/spl/tests/iterator_065.phpt
new file mode 100644
index 0000000..9ea2974
--- /dev/null
+++ b/ext/spl/tests/iterator_065.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: RecursiveCachingIterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myRecursiveCachingIterator extends RecursiveCachingIterator {}
+try {
+ $it = new myRecursiveCachingIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
diff --git a/ext/spl/tests/iterator_066.phpt b/ext/spl/tests/iterator_066.phpt
new file mode 100644
index 0000000..008c47c
--- /dev/null
+++ b/ext/spl/tests/iterator_066.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: NoRewindIterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myNoRewindIterator extends NoRewindIterator {}
+try {
+ $it = new myNoRewindIterator();
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+InvalidArgumentException thrown
diff --git a/ext/spl/tests/iterator_067.phpt b/ext/spl/tests/iterator_067.phpt
new file mode 100644
index 0000000..e05a48d
--- /dev/null
+++ b/ext/spl/tests/iterator_067.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: AppendIterator::__construct(void)
+--CREDITS--
+Sebastian Schürmann
+--FILE--
+<?php
+class myAppendIterator extends AppendIterator {}
+try {
+ $it = new myAppendIterator();
+ echo "no exception";
+} catch (InvalidArgumentException $e) {
+ echo 'InvalidArgumentException thrown';
+}
+?>
+--EXPECT--
+no exception
diff --git a/ext/spl/tests/iterator_068.phpt b/ext/spl/tests/iterator_068.phpt
new file mode 100644
index 0000000..4845708
--- /dev/null
+++ b/ext/spl/tests/iterator_068.phpt
@@ -0,0 +1,34 @@
+--TEST--
+SPL: Iterator: Overloaded object and destruction
+--FILE--
+<?php
+
+class Test implements Iterator {
+ function foo() {
+ echo __METHOD__ . "()\n";
+ }
+ function rewind() {}
+ function valid() {}
+ function current() {}
+ function key() {}
+ function next() {}
+}
+
+class TestIteratorIterator extends IteratorIterator {
+ function __destruct() {
+ echo __METHOD__ . "()\n";
+ $this->foo();
+ }
+}
+
+$obj = new TestIteratorIterator(new Test);
+$obj->foo();
+unset($obj);
+
+?>
+===DONE===
+--EXPECT--
+Test::foo()
+TestIteratorIterator::__destruct()
+Test::foo()
+===DONE===
diff --git a/ext/spl/tests/iterator_069.phpt b/ext/spl/tests/iterator_069.phpt
new file mode 100644
index 0000000..e9b3177
--- /dev/null
+++ b/ext/spl/tests/iterator_069.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: RecursiveIteratorIterator cannot be used with foreach by reference
+--FILE--
+<?php
+
+$arr = array(array(1,2));
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+$recItIt = new RecursiveIteratorIterator($recArrIt);
+
+foreach ($recItIt as &$val) echo "$val\n";
+
+?>
+--EXPECTF--
+Fatal error: An iterator cannot be used with foreach by reference in %s on line %d
diff --git a/ext/spl/tests/iterator_070.phpt b/ext/spl/tests/iterator_070.phpt
new file mode 100644
index 0000000..c45f08e
--- /dev/null
+++ b/ext/spl/tests/iterator_070.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Ensure that non-overriden methods execute problem free.
+--FILE--
+<?php
+
+$array = array();
+$recArrIt = new RecursiveArrayIterator($array);
+
+$recItIt = new RecursiveIteratorIterator($recArrIt);
+
+var_dump($recItIt->beginIteration());
+var_dump($recItIt->endIteration());
+var_dump($recItIt->nextElement());
+
+?>
+
+--EXPECTF--
+NULL
+NULL
+NULL \ No newline at end of file
diff --git a/ext/spl/tests/iterator_071.phpt b/ext/spl/tests/iterator_071.phpt
new file mode 100644
index 0000000..21ec798
--- /dev/null
+++ b/ext/spl/tests/iterator_071.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Test where the case is RS_SELF and mode is CHILD_FIRST
+--FILE--
+<?php
+
+$arr = array(array(1,2),2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function nextelement() {
+ echo __METHOD__."\n";
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::CHILD_FIRST);
+
+foreach ($recItIt as $key => $val) echo "$key\n";
+
+?>
+--EXPECTF--
+MyRecursiveIteratorIterator::nextelement
+0
+MyRecursiveIteratorIterator::nextelement
+1
+MyRecursiveIteratorIterator::nextelement
+0
+MyRecursiveIteratorIterator::nextelement
+1 \ No newline at end of file
diff --git a/ext/spl/tests/iterator_count.phpt b/ext/spl/tests/iterator_count.phpt
new file mode 100644
index 0000000..9aa4e11
--- /dev/null
+++ b/ext/spl/tests/iterator_count.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SPL: iterator_count() exceptions test
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$array=array('a','b');
+
+$iterator = new ArrayIterator($array);
+
+iterator_count();
+
+
+iterator_count($iterator,'1');
+
+iterator_count('1');
+
+
+?>
+--EXPECTF--
+Warning: iterator_count() expects exactly 1 parameter, 0 given in %s
+
+Warning: iterator_count() expects exactly 1 parameter, 2 given in %s
+
+Catchable fatal error: Argument 1 passed to iterator_count() must implement interface Traversable, %unicode_string_optional% given %s
diff --git a/ext/spl/tests/iterator_to_array.phpt b/ext/spl/tests/iterator_to_array.phpt
new file mode 100644
index 0000000..958d370
--- /dev/null
+++ b/ext/spl/tests/iterator_to_array.phpt
@@ -0,0 +1,25 @@
+--TEST--
+SPL: iterator_to_array() exceptions test
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$array=array('a','b');
+
+$iterator = new ArrayIterator($array);
+
+iterator_to_array();
+
+
+iterator_to_array($iterator,'test','test');
+
+iterator_to_array('test','test');
+
+?>
+--EXPECTF--
+Warning: iterator_to_array() expects at least 1 parameter, 0 given in %s
+
+Warning: iterator_to_array() expects at most 2 parameters, 3 given in %s
+
+Catchable fatal error: Argument 1 passed to iterator_to_array() must implement interface Traversable, %unicode_string_optional% given %s
diff --git a/ext/spl/tests/limititerator_seek.phpt b/ext/spl/tests/limititerator_seek.phpt
new file mode 100644
index 0000000..a59a49b
--- /dev/null
+++ b/ext/spl/tests/limititerator_seek.phpt
@@ -0,0 +1,18 @@
+--TEST--
+SPL: LimitIterator seek() arguments
+--CREDITS--
+Roshan Abraham (roshanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+
+$a = array(1,2,3);
+$lt = new LimitIterator(new ArrayIterator($a));
+
+$lt->seek(1,1); // Should throw a warning as seek expects only 1 argument
+
+?>
+--EXPECTF--
+
+Warning: LimitIterator::seek() expects exactly 1 parameter, 2 given in %s on line %d
+
diff --git a/ext/spl/tests/multiple_iterator_001.phpt b/ext/spl/tests/multiple_iterator_001.phpt
new file mode 100644
index 0000000..edd03f5
--- /dev/null
+++ b/ext/spl/tests/multiple_iterator_001.phpt
@@ -0,0 +1,345 @@
+--TEST--
+SPL: MultipleIterator
+--FILE--
+<?php
+
+$iter1 = new ArrayIterator(array(1,2,3));
+$iter2 = new ArrayIterator(array(1,2));
+$iter3 = new ArrayIterator(array(new stdClass(),"string",3));
+
+$m = new MultipleIterator();
+
+echo "-- Default flags, no iterators --\n";
+foreach($m as $value) {
+ var_dump($value);
+}
+var_dump($m->current());
+
+$m->attachIterator($iter1);
+$m->attachIterator($iter2);
+$m->attachIterator($iter3);
+
+echo "-- Default flags, MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_KEYS_NUMERIC --\n";
+
+var_dump($m->getFlags() === (MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_KEYS_NUMERIC));
+
+foreach($m as $value) {
+ var_dump($m->key(), $value);
+}
+try {
+ $m->current();
+} catch(RuntimeException $e) {
+ echo "RuntimeException thrown: " . $e->getMessage() . "\n";
+}
+try {
+ $m->key();
+} catch(RuntimeException $e) {
+ echo "RuntimeException thrown: " . $e->getMessage() . "\n";
+}
+
+echo "-- Flags = MultipleIterator::MIT_NEED_ANY | MultipleIterator::MIT_KEYS_NUMERIC --\n";
+
+$m->setFlags(MultipleIterator::MIT_NEED_ANY | MultipleIterator::MIT_KEYS_NUMERIC);
+var_dump($m->getFlags() === (MultipleIterator::MIT_NEED_ANY | MultipleIterator::MIT_KEYS_NUMERIC));
+
+foreach($m as $value) {
+ var_dump($m->key(), $value);
+}
+
+echo "-- Default flags, added element --\n";
+
+$m->setFlags(MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_KEYS_NUMERIC);
+
+$iter2[] = 3;
+foreach($m as $value) {
+ var_dump($m->key(), $value);
+}
+
+echo "-- Flags |= MultipleIterator::MIT_KEYS_ASSOC, with iterator associated with NULL --\n";
+
+$m->setFlags(MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_KEYS_ASSOC);
+$m->rewind();
+try {
+ $m->current();
+} catch(InvalidArgumentException $e) {
+ echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n";
+}
+
+echo "-- Flags |= MultipleIterator::MIT_KEYS_ASSOC --\n";
+
+$m->attachIterator($iter1, "iter1");
+$m->attachIterator($iter2, b"iter2");
+$m->attachIterator($iter3, 3);
+
+foreach($m as $value) {
+ var_dump($m->key(), $value);
+}
+
+echo "-- Associate with invalid value --\n";
+
+try {
+ $m->attachIterator($iter3, new stdClass());
+} catch(InvalidArgumentException $e) {
+ echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n";
+}
+
+echo "-- Associate with duplicate value --\n";
+
+try {
+ $m->attachIterator($iter3, "iter1");
+} catch(InvalidArgumentException $e) {
+ echo "InvalidArgumentException thrown: " . $e->getMessage() . "\n";
+}
+
+echo "-- Count, contains, detach, count, contains, iterate --\n";
+
+var_dump($m->countIterators());
+var_dump($m->containsIterator($iter2));
+var_dump($m->detachIterator($iter2));
+var_dump($m->countIterators());
+var_dump($m->containsIterator($iter2));
+foreach($m as $value) {
+ var_dump($m->key(), $value);
+}
+
+?>
+--EXPECTF--
+-- Default flags, no iterators --
+bool(false)
+-- Default flags, MultipleIterator::MIT_NEED_ALL | MultipleIterator::MIT_KEYS_NUMERIC --
+bool(true)
+array(3) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(0)
+ [2]=>
+ int(0)
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ [2]=>
+ object(stdClass)#%d (0) {
+ }
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ [2]=>
+ int(1)
+}
+array(3) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(2)
+ [2]=>
+ string(6) "string"
+}
+RuntimeException thrown: Called current() with non valid sub iterator
+RuntimeException thrown: Called key() with non valid sub iterator
+-- Flags = MultipleIterator::MIT_NEED_ANY | MultipleIterator::MIT_KEYS_NUMERIC --
+bool(true)
+array(3) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(0)
+ [2]=>
+ int(0)
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ [2]=>
+ object(stdClass)#%d (0) {
+ }
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ [2]=>
+ int(1)
+}
+array(3) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(2)
+ [2]=>
+ string(6) "string"
+}
+array(3) {
+ [0]=>
+ int(2)
+ [1]=>
+ NULL
+ [2]=>
+ int(2)
+}
+array(3) {
+ [0]=>
+ int(3)
+ [1]=>
+ NULL
+ [2]=>
+ int(3)
+}
+-- Default flags, added element --
+array(3) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(0)
+ [2]=>
+ int(0)
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ [2]=>
+ object(stdClass)#%d (0) {
+ }
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ [2]=>
+ int(1)
+}
+array(3) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(2)
+ [2]=>
+ string(6) "string"
+}
+array(3) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(2)
+ [2]=>
+ int(2)
+}
+array(3) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(3)
+ [2]=>
+ int(3)
+}
+-- Flags |= MultipleIterator::MIT_KEYS_ASSOC, with iterator associated with NULL --
+InvalidArgumentException thrown: Sub-Iterator is associated with NULL
+-- Flags |= MultipleIterator::MIT_KEYS_ASSOC --
+array(3) {
+ ["iter1"]=>
+ int(0)
+ ["iter2"]=>
+ int(0)
+ [3]=>
+ int(0)
+}
+array(3) {
+ ["iter1"]=>
+ int(1)
+ ["iter2"]=>
+ int(1)
+ [3]=>
+ object(stdClass)#%d (0) {
+ }
+}
+array(3) {
+ ["iter1"]=>
+ int(1)
+ ["iter2"]=>
+ int(1)
+ [3]=>
+ int(1)
+}
+array(3) {
+ ["iter1"]=>
+ int(2)
+ ["iter2"]=>
+ int(2)
+ [3]=>
+ string(6) "string"
+}
+array(3) {
+ ["iter1"]=>
+ int(2)
+ ["iter2"]=>
+ int(2)
+ [3]=>
+ int(2)
+}
+array(3) {
+ ["iter1"]=>
+ int(3)
+ ["iter2"]=>
+ int(3)
+ [3]=>
+ int(3)
+}
+-- Associate with invalid value --
+InvalidArgumentException thrown: Info must be NULL, integer or string
+-- Associate with duplicate value --
+InvalidArgumentException thrown: Key duplication error
+-- Count, contains, detach, count, contains, iterate --
+int(3)
+bool(true)
+NULL
+int(2)
+bool(false)
+array(2) {
+ ["iter1"]=>
+ int(0)
+ [3]=>
+ int(0)
+}
+array(2) {
+ ["iter1"]=>
+ int(1)
+ [3]=>
+ object(stdClass)#%d (0) {
+ }
+}
+array(2) {
+ ["iter1"]=>
+ int(1)
+ [3]=>
+ int(1)
+}
+array(2) {
+ ["iter1"]=>
+ int(2)
+ [3]=>
+ string(6) "string"
+}
+array(2) {
+ ["iter1"]=>
+ int(2)
+ [3]=>
+ int(2)
+}
+array(2) {
+ ["iter1"]=>
+ int(3)
+ [3]=>
+ int(3)
+}
diff --git a/ext/spl/tests/observer_001.phpt b/ext/spl/tests/observer_001.phpt
new file mode 100644
index 0000000..e7d72b9
--- /dev/null
+++ b/ext/spl/tests/observer_001.phpt
@@ -0,0 +1,116 @@
+--TEST--
+SPL: SplObserver and SplSubject (empty notify)
+--FILE--
+<?php
+
+class ObserverImpl implements SplObserver
+{
+ protected $name = '';
+
+ function __construct($name = 'obj')
+ {
+ $this->name = '$' . $name;
+ }
+
+ function update(SplSubject $subject)
+ {
+ echo $this->name . '->' . __METHOD__ . '(' . $subject->getName() . ");\n";
+ }
+
+ function getName()
+ {
+ return $this->name;
+ }
+}
+
+class SubjectImpl implements SplSubject
+{
+ protected $name = '';
+ protected $observers = array();
+
+ function __construct($name = 'sub')
+ {
+ $this->name = '$' . $name;
+ }
+
+ function attach(SplObserver $observer)
+ {
+ echo '$sub->' . __METHOD__ . '(' . $observer->getName() . ");\n";
+ if (!in_array($observer, $this->observers))
+ {
+ $this->observers[] = $observer;
+ }
+ }
+
+ function detach(SplObserver $observer)
+ {
+ echo '$sub->' . __METHOD__ . '(' . $observer->getName() . ");\n";
+ $idx = array_search($observer, $this->observers);
+ if ($idx !== false)
+ {
+ unset($this->observers[$idx]);
+ }
+ }
+
+ function notify()
+ {
+ echo '$sub->' . __METHOD__ . "();\n";
+ foreach($this->observers as $observer)
+ {
+ $observer->update($this);
+ }
+ }
+
+ function getName()
+ {
+ return $this->name;
+ }
+}
+
+$sub = new SubjectImpl;
+
+$ob1 = new ObserverImpl("ob1");
+$ob2 = new ObserverImpl("ob2");
+$ob3 = new ObserverImpl("ob3");
+
+$sub->attach($ob1);
+$sub->attach($ob1);
+$sub->attach($ob2);
+$sub->attach($ob3);
+
+$sub->notify();
+
+$sub->detach($ob3);
+
+$sub->notify();
+
+$sub->detach($ob2);
+$sub->detach($ob1);
+
+$sub->notify();
+
+$sub->attach($ob3);
+
+$sub->notify();
+?>
+===DONE===
+--EXPECT--
+$sub->SubjectImpl::attach($ob1);
+$sub->SubjectImpl::attach($ob1);
+$sub->SubjectImpl::attach($ob2);
+$sub->SubjectImpl::attach($ob3);
+$sub->SubjectImpl::notify();
+$ob1->ObserverImpl::update($sub);
+$ob2->ObserverImpl::update($sub);
+$ob3->ObserverImpl::update($sub);
+$sub->SubjectImpl::detach($ob3);
+$sub->SubjectImpl::notify();
+$ob1->ObserverImpl::update($sub);
+$ob2->ObserverImpl::update($sub);
+$sub->SubjectImpl::detach($ob2);
+$sub->SubjectImpl::detach($ob1);
+$sub->SubjectImpl::notify();
+$sub->SubjectImpl::attach($ob3);
+$sub->SubjectImpl::notify();
+$ob3->ObserverImpl::update($sub);
+===DONE===
diff --git a/ext/spl/tests/observer_002.phpt b/ext/spl/tests/observer_002.phpt
new file mode 100644
index 0000000..5d00617
--- /dev/null
+++ b/ext/spl/tests/observer_002.phpt
@@ -0,0 +1,199 @@
+--TEST--
+SPL: SplObjectStorage
+--FILE--
+<?php
+
+class MyObjectStorage extends SplObjectStorage
+{
+ function rewind()
+ {
+ echo __METHOD__ . "()\n";
+ parent::rewind();
+ }
+
+ function valid()
+ {
+ echo __METHOD__ . "(" . (parent::valid() ? 1 : 0) . ")\n";
+ return parent::valid();
+ }
+
+ function key()
+ {
+ echo __METHOD__ . "(" . parent::key() . ")\n";
+ return parent::key();
+ }
+
+ function current()
+ {
+ echo __METHOD__ . "(" . parent::current()->getName() . ")\n";
+ return parent::current();
+ }
+
+ function next()
+ {
+ echo __METHOD__ . "()\n";
+ parent::next();
+ }
+}
+
+class ObserverImpl implements SplObserver
+{
+ protected $name = '';
+
+ function __construct($name = 'obj')
+ {
+ $this->name = '$' . $name;
+ }
+
+ function update(SplSubject $subject)
+ {
+ echo $this->name . '->' . __METHOD__ . '(' . $subject->getName() . ");\n";
+ }
+
+ function getName()
+ {
+ return $this->name;
+ }
+}
+
+class SubjectImpl implements SplSubject
+{
+ protected $name = '';
+ protected $observers;
+
+ function __construct($name = 'sub')
+ {
+ $this->observers = new MyObjectStorage;
+ $this->name = '$' . $name;
+ }
+
+ function attach(SplObserver $observer)
+ {
+ echo $this->name . '->' . __METHOD__ . '(' . $observer->getName() . ");\n";
+ $this->observers->attach($observer);
+ }
+
+ function detach(SplObserver $observer)
+ {
+ echo $this->name . '->' . __METHOD__ . '(' . $observer->getName() . ");\n";
+ $this->observers->detach($observer);
+ }
+
+ function count()
+ {
+ return $this->observers->count();
+ }
+
+ function notify()
+ {
+ echo $this->name . '->' . __METHOD__ . "();\n";
+ foreach($this->observers as $key => $observer)
+ {
+ $observer->update($this);
+ }
+ }
+
+ function getName()
+ {
+ return $this->name;
+ }
+
+ function contains($obj)
+ {
+ return $this->observers->contains($obj);
+ }
+}
+
+$sub = new SubjectImpl;
+
+$ob1 = new ObserverImpl("ob1");
+$ob2 = new ObserverImpl("ob2");
+$ob3 = new ObserverImpl("ob3");
+
+var_dump($sub->contains($ob1));
+$sub->attach($ob1);
+var_dump($sub->contains($ob1));
+$sub->attach($ob1);
+$sub->attach($ob2);
+$sub->attach($ob3);
+var_dump($sub->count());
+
+$sub->notify();
+
+$sub->detach($ob3);
+var_dump($sub->count());
+
+$sub->notify();
+
+$sub->detach($ob2);
+$sub->detach($ob1);
+var_dump($sub->count());
+
+$sub->notify();
+
+$sub->attach($ob3);
+var_dump($sub->count());
+
+$sub->notify();
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+bool(false)
+$sub->SubjectImpl::attach($ob1);
+bool(true)
+$sub->SubjectImpl::attach($ob1);
+$sub->SubjectImpl::attach($ob2);
+$sub->SubjectImpl::attach($ob3);
+int(3)
+$sub->SubjectImpl::notify();
+MyObjectStorage::rewind()
+MyObjectStorage::valid(1)
+MyObjectStorage::current($ob1)
+MyObjectStorage::key(0)
+$ob1->ObserverImpl::update($sub);
+MyObjectStorage::next()
+MyObjectStorage::valid(1)
+MyObjectStorage::current($ob2)
+MyObjectStorage::key(1)
+$ob2->ObserverImpl::update($sub);
+MyObjectStorage::next()
+MyObjectStorage::valid(1)
+MyObjectStorage::current($ob3)
+MyObjectStorage::key(2)
+$ob3->ObserverImpl::update($sub);
+MyObjectStorage::next()
+MyObjectStorage::valid(0)
+$sub->SubjectImpl::detach($ob3);
+int(2)
+$sub->SubjectImpl::notify();
+MyObjectStorage::rewind()
+MyObjectStorage::valid(1)
+MyObjectStorage::current($ob1)
+MyObjectStorage::key(0)
+$ob1->ObserverImpl::update($sub);
+MyObjectStorage::next()
+MyObjectStorage::valid(1)
+MyObjectStorage::current($ob2)
+MyObjectStorage::key(1)
+$ob2->ObserverImpl::update($sub);
+MyObjectStorage::next()
+MyObjectStorage::valid(0)
+$sub->SubjectImpl::detach($ob2);
+$sub->SubjectImpl::detach($ob1);
+int(0)
+$sub->SubjectImpl::notify();
+MyObjectStorage::rewind()
+MyObjectStorage::valid(0)
+$sub->SubjectImpl::attach($ob3);
+int(1)
+$sub->SubjectImpl::notify();
+MyObjectStorage::rewind()
+MyObjectStorage::valid(1)
+MyObjectStorage::current($ob3)
+MyObjectStorage::key(0)
+$ob3->ObserverImpl::update($sub);
+MyObjectStorage::next()
+MyObjectStorage::valid(0)
+===DONE===
diff --git a/ext/spl/tests/observer_003.phpt b/ext/spl/tests/observer_003.phpt
new file mode 100644
index 0000000..5e5da22
--- /dev/null
+++ b/ext/spl/tests/observer_003.phpt
@@ -0,0 +1,58 @@
+--TEST--
+SPL: SplObjectStorage serialization
+--FILE--
+<?php
+
+class TestClass
+{
+ public $test = 25;
+
+ public function __construct($test = 42)
+ {
+ $this->test = $test;
+ }
+}
+
+$storage = new SplObjectStorage();
+
+foreach(array(1,"2","foo",true) as $value)
+{
+ $storage->attach(new TestClass($value));
+}
+
+var_dump(count($storage));
+
+foreach($storage as $object)
+{
+ var_dump($object->test);
+}
+
+var_dump(serialize($storage));
+echo "===UNSERIALIZE===\n";
+
+$storage2 = unserialize(serialize($storage));
+
+var_dump(count($storage2));
+
+foreach($storage2 as $object)
+{
+ var_dump($object->test);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(4)
+int(1)
+string(1) "2"
+string(3) "foo"
+bool(true)
+string(%d) "%s"
+===UNSERIALIZE===
+int(4)
+int(1)
+string(1) "2"
+string(3) "foo"
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/observer_004.phpt b/ext/spl/tests/observer_004.phpt
new file mode 100644
index 0000000..0bc2512
--- /dev/null
+++ b/ext/spl/tests/observer_004.phpt
@@ -0,0 +1,122 @@
+--TEST--
+SPL: SplObjectStorage serialization & overloading
+--FILE--
+<?php
+
+class TestClass
+{
+ public $test = 25;
+
+ public function __construct($test = 42)
+ {
+ $this->test = $test;
+ }
+}
+
+class MyStorage extends SplObjectStorage
+{
+ public $bla = 25;
+
+ public function __construct($bla = 26)
+ {
+ $this->bla = $bla;
+ }
+}
+
+$storage = new MyStorage();
+
+foreach(array(1,2) as $value)
+{
+ $storage->attach(new TestClass($value));
+}
+
+var_dump(count($storage));
+
+foreach($storage as $object)
+{
+ var_dump($object->test);
+}
+
+var_dump($storage);
+
+var_dump(serialize($storage));
+echo "===UNSERIALIZE===\n";
+
+$storage2 = unserialize(serialize($storage));
+
+var_dump(count($storage2));
+
+foreach($storage2 as $object)
+{
+ var_dump($object->test);
+}
+
+var_dump($storage2);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(2)
+int(1)
+int(2)
+object(MyStorage)#%d (2) {
+ ["bla"]=>
+ int(26)
+ ["storage":"SplObjectStorage":private]=>
+ array(2) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(1)
+ }
+ ["inf"]=>
+ NULL
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(2)
+ }
+ ["inf"]=>
+ NULL
+ }
+ }
+}
+string(%d) "%s"
+===UNSERIALIZE===
+int(2)
+int(1)
+int(2)
+object(MyStorage)#%d (2) {
+ ["bla"]=>
+ int(26)
+ ["storage":"SplObjectStorage":private]=>
+ array(2) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(1)
+ }
+ ["inf"]=>
+ NULL
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(2)
+ }
+ ["inf"]=>
+ NULL
+ }
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/observer_005.phpt b/ext/spl/tests/observer_005.phpt
new file mode 100644
index 0000000..883602f
--- /dev/null
+++ b/ext/spl/tests/observer_005.phpt
@@ -0,0 +1,212 @@
+--TEST--
+SPL: SplObjectStorage serialization & visibility
+--FILE--
+<?php
+
+class TestClass
+{
+ public $def = 24;
+ public $pub = 25;
+ protected $pro = 26;
+ private $pri = 27;
+
+ public function __construct($pub = 42, $pro = 43, $pri = 44)
+ {
+ $this->pub = $pub;
+ $this->pro = $pro;
+ $this->pri = $pri;
+ }
+}
+
+class ExtTestClass
+{
+}
+
+class MyStorage extends SplObjectStorage
+{
+ public $def = 24;
+ public $pub = 25;
+ protected $pro = 26;
+ private $pri = 27;
+
+ public function __construct($pub = 52, $pro = 53, $pri = 54)
+ {
+ $this->pub = $pub;
+ $this->pro = $pro;
+ $this->pri = $pri;
+ }
+}
+
+class ExtStorage extends MyStorage
+{
+}
+
+$storage = new MyStorage(1,2,3);
+
+foreach(array(array(4,5,6),array(7,8,9)) as $value)
+{
+ $storage->attach(new TestClass($value[0], $value[1], $value[2]));
+}
+
+var_dump(count($storage));
+
+foreach($storage as $object)
+{
+ var_dump($object);
+}
+
+var_dump($storage);
+
+var_dump(serialize($storage));
+echo "===UNSERIALIZE===\n";
+
+$storage2 = unserialize(serialize($storage));
+
+var_dump(count($storage2));
+
+foreach($storage2 as $object)
+{
+ var_dump($object);
+}
+
+var_dump($storage2);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(2)
+object(TestClass)#%d (4) {
+ ["def"]=>
+ int(24)
+ ["pub"]=>
+ int(4)
+ ["pro":protected]=>
+ int(5)
+ ["pri":"TestClass":private]=>
+ int(6)
+}
+object(TestClass)#%d (4) {
+ ["def"]=>
+ int(24)
+ ["pub"]=>
+ int(7)
+ ["pro":protected]=>
+ int(8)
+ ["pri":"TestClass":private]=>
+ int(9)
+}
+object(MyStorage)#%d (5) {
+ ["def"]=>
+ int(24)
+ ["pub"]=>
+ int(1)
+ ["pro":protected]=>
+ int(2)
+ ["pri":"MyStorage":private]=>
+ int(3)
+ ["storage":"SplObjectStorage":private]=>
+ array(2) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (4) {
+ ["def"]=>
+ int(24)
+ ["pub"]=>
+ int(4)
+ ["pro":protected]=>
+ int(5)
+ ["pri":"TestClass":private]=>
+ int(6)
+ }
+ ["inf"]=>
+ NULL
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (4) {
+ ["def"]=>
+ int(24)
+ ["pub"]=>
+ int(7)
+ ["pro":protected]=>
+ int(8)
+ ["pri":"TestClass":private]=>
+ int(9)
+ }
+ ["inf"]=>
+ NULL
+ }
+ }
+}
+string(%d) "%s"
+===UNSERIALIZE===
+int(2)
+object(TestClass)#%d (4) {
+ ["def"]=>
+ int(24)
+ ["pub"]=>
+ int(4)
+ ["pro":protected]=>
+ int(5)
+ ["pri":"TestClass":private]=>
+ int(6)
+}
+object(TestClass)#%d (4) {
+ ["def"]=>
+ int(24)
+ ["pub"]=>
+ int(7)
+ ["pro":protected]=>
+ int(8)
+ ["pri":"TestClass":private]=>
+ int(9)
+}
+object(MyStorage)#%d (5) {
+ ["def"]=>
+ int(24)
+ ["pub"]=>
+ int(1)
+ ["pro":protected]=>
+ int(2)
+ ["pri":"MyStorage":private]=>
+ int(3)
+ ["storage":"SplObjectStorage":private]=>
+ array(2) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (4) {
+ ["def"]=>
+ int(24)
+ ["pub"]=>
+ int(4)
+ ["pro":protected]=>
+ int(5)
+ ["pri":"TestClass":private]=>
+ int(6)
+ }
+ ["inf"]=>
+ NULL
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (4) {
+ ["def"]=>
+ int(24)
+ ["pub"]=>
+ int(7)
+ ["pro":protected]=>
+ int(8)
+ ["pri":"TestClass":private]=>
+ int(9)
+ }
+ ["inf"]=>
+ NULL
+ }
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/observer_006.phpt b/ext/spl/tests/observer_006.phpt
new file mode 100644
index 0000000..3cd84a7
--- /dev/null
+++ b/ext/spl/tests/observer_006.phpt
@@ -0,0 +1,310 @@
+--TEST--
+SPL: SplObjectStorage with accociatied information
+--FILE--
+<?php
+
+class TestClass
+{
+ public $test = 25;
+
+ public function __construct($test = 42)
+ {
+ $this->test = $test;
+ }
+}
+
+class MyStorage extends SplObjectStorage
+{
+ public $bla = 25;
+
+ public function __construct($bla = 26)
+ {
+ $this->bla = $bla;
+ }
+}
+
+$storage = new MyStorage();
+
+foreach(array(1=>"foo",2=>42) as $key => $value)
+{
+ $storage->attach(new TestClass($key), $value);
+}
+
+var_dump(count($storage));
+
+foreach($storage as $object)
+{
+ var_dump($object->test);
+}
+
+var_dump($storage);
+
+var_dump(serialize($storage));
+echo "===UNSERIALIZE===\n";
+
+$storage2 = unserialize(serialize($storage));
+
+var_dump(count($storage2));
+
+foreach($storage2 as $object)
+{
+ var_dump($object->test);
+}
+
+var_dump($storage2);
+$storage->attach(new TestClass(3), new stdClass);
+$storage->attach(new TestClass(4), new TestClass(5));
+echo "===UNSERIALIZE2===\n";
+var_dump(unserialize(serialize($storage)));
+$storage->rewind();
+$storage->next();
+var_dump($storage->key());
+var_dump($storage->current());
+var_dump($storage->getInfo());
+$storage->setInfo("bar");
+var_dump($storage->getInfo());
+echo "===UNSERIALIZE3===\n";
+var_dump(unserialize(serialize($storage)));
+$storage->rewind();
+$storage->next();
+$storage->next();
+var_dump($storage->key());
+var_dump($storage->current());
+$storage->attach($storage->current(), "replaced");
+echo "===UNSERIALIZE4===\n";
+var_dump(unserialize(serialize($storage)));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(2)
+int(1)
+int(2)
+object(MyStorage)#%d (2) {
+ ["bla"]=>
+ int(26)
+ ["storage":"SplObjectStorage":private]=>
+ array(2) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(1)
+ }
+ ["inf"]=>
+ string(3) "foo"
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(2)
+ }
+ ["inf"]=>
+ int(42)
+ }
+ }
+}
+string(%d) "%s"
+===UNSERIALIZE===
+int(2)
+int(1)
+int(2)
+object(MyStorage)#%d (2) {
+ ["bla"]=>
+ int(26)
+ ["storage":"SplObjectStorage":private]=>
+ array(2) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(1)
+ }
+ ["inf"]=>
+ string(3) "foo"
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(2)
+ }
+ ["inf"]=>
+ int(42)
+ }
+ }
+}
+===UNSERIALIZE2===
+object(MyStorage)#%d (2) {
+ ["bla"]=>
+ int(26)
+ ["storage":"SplObjectStorage":private]=>
+ array(4) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(1)
+ }
+ ["inf"]=>
+ string(3) "foo"
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(2)
+ }
+ ["inf"]=>
+ int(42)
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(3)
+ }
+ ["inf"]=>
+ object(stdClass)#%d (0) {
+ }
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(4)
+ }
+ ["inf"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(5)
+ }
+ }
+ }
+}
+int(1)
+object(TestClass)#%d (1) {
+ ["test"]=>
+ int(2)
+}
+int(42)
+string(3) "bar"
+===UNSERIALIZE3===
+object(MyStorage)#%d (2) {
+ ["bla"]=>
+ int(26)
+ ["storage":"SplObjectStorage":private]=>
+ array(4) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(1)
+ }
+ ["inf"]=>
+ string(3) "foo"
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(2)
+ }
+ ["inf"]=>
+ string(3) "bar"
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(3)
+ }
+ ["inf"]=>
+ object(stdClass)#%d (0) {
+ }
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(4)
+ }
+ ["inf"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(5)
+ }
+ }
+ }
+}
+int(2)
+object(TestClass)#7 (1) {
+ ["test"]=>
+ int(3)
+}
+===UNSERIALIZE4===
+object(MyStorage)#%d (2) {
+ ["bla"]=>
+ int(26)
+ ["storage":"SplObjectStorage":private]=>
+ array(4) {
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(1)
+ }
+ ["inf"]=>
+ string(3) "foo"
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(2)
+ }
+ ["inf"]=>
+ string(3) "bar"
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(3)
+ }
+ ["inf"]=>
+ string(8) "replaced"
+ }
+ ["%s"]=>
+ array(2) {
+ ["obj"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(4)
+ }
+ ["inf"]=>
+ object(TestClass)#%d (1) {
+ ["test"]=>
+ int(5)
+ }
+ }
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/observer_007.phpt b/ext/spl/tests/observer_007.phpt
new file mode 100644
index 0000000..e494f19
--- /dev/null
+++ b/ext/spl/tests/observer_007.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplObjectStorage comapred with ==
+--FILE--
+<?php
+$a = new SplObjectStorage;
+$b = new SplObjectStorage;
+var_dump($a == $b);
+$b[$b] = 2;
+var_dump($a == $b);
+$a[$b] = 2;
+var_dump($a == $b);
+$a[$b] = 3;
+var_dump($a == $b);
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/observer_008.phpt b/ext/spl/tests/observer_008.phpt
new file mode 100644
index 0000000..56a3c89
--- /dev/null
+++ b/ext/spl/tests/observer_008.phpt
@@ -0,0 +1,35 @@
+--TEST--
+SPL: SplObjectStorage addAll/removeAll
+--FILE--
+<?php
+class A extends SplObjectStorage { }
+
+$o1 = new StdClass;
+$o2 = new StdClass;
+$o3 = new StdClass;
+
+$a = new A;
+$a->attach($o1);
+$a->attach($o2);
+
+$b = new SplObjectSTorage();
+$b->attach($o2);
+$b->attach($o3);
+
+$a->addAll($b);
+
+var_dump($a->count());
+
+$a->detach($o3);
+var_dump($a->count());
+
+$a->removeAll($b);
+var_dump($a->count());
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(3)
+int(2)
+int(1)
+===DONE===
diff --git a/ext/spl/tests/observer_009.phpt b/ext/spl/tests/observer_009.phpt
new file mode 100644
index 0000000..6ac676c
--- /dev/null
+++ b/ext/spl/tests/observer_009.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: SplObjectStorage addAll/removeAll
+--FILE--
+<?php
+class Foo {}
+
+$storageA = new \SplObjectStorage();
+$storageA->attach(new \Foo);
+$storageA->attach(new \Foo);
+
+echo ("Count storage A: " . count($storageA));
+foreach ($storageA as $object) {
+ echo ' x ';
+}
+
+echo "\n";
+$storageB = clone $storageA;
+
+echo ("Count storage B: " . count($storageB));
+foreach ($storageB as $object) {
+ echo ' x ';
+}
+echo "\n";
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Count storage A: 2 x x
+Count storage B: 2 x x
+===DONE===
diff --git a/ext/spl/tests/pqueue_001.phpt b/ext/spl/tests/pqueue_001.phpt
new file mode 100644
index 0000000..de164e5
--- /dev/null
+++ b/ext/spl/tests/pqueue_001.phpt
@@ -0,0 +1,96 @@
+--TEST--
+SPL: SplPriorityQueue: std operations and extract flags
+--FILE--
+<?php
+$pq = new SplPriorityQueue();
+
+// errors
+try {
+ $pq->extract();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+$pq->insert("a", 1);
+$pq->insert("b", 2);
+$pq->insert("c", 0);
+
+foreach ($pq as $k=>$v) {
+ echo "$k=>".print_r($v, 1)."\n";
+}
+
+echo "EXTR_BOTH\n";
+
+$pq1 = new SplPriorityQueue();
+$pq1->setExtractFlags(SplPriorityQueue::EXTR_BOTH);
+
+$pq1->insert("a", 1);
+$pq1->insert("b", 2);
+$pq1->insert("c", 0);
+
+foreach ($pq1 as $k=>$v) {
+ echo "$k=>".print_r($v, 1)."\n";
+}
+
+echo "EXTR_DATA\n";
+
+$pq2 = new SplPriorityQueue();
+$pq2->setExtractFlags(SplPriorityQueue::EXTR_DATA);
+
+$pq2->insert("a", 1);
+$pq2->insert("b", 2);
+$pq2->insert("c", 0);
+
+foreach ($pq2 as $k=>$v) {
+ echo "$k=>".print_r($v, 1)."\n";
+}
+
+echo "EXTR_PRIORITY\n";
+
+$pq3 = new SplPriorityQueue();
+$pq3->setExtractFlags(SplPriorityQueue::EXTR_PRIORITY);
+
+$pq3->insert("a", 1);
+$pq3->insert("b", 2);
+$pq3->insert("c", 0);
+
+foreach ($pq3 as $k=>$v) {
+ echo "$k=>".print_r($v, 1)."\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Exception: Can't extract from an empty heap
+2=>b
+1=>a
+0=>c
+EXTR_BOTH
+2=>Array
+(
+ [data] => b
+ [priority] => 2
+)
+
+1=>Array
+(
+ [data] => a
+ [priority] => 1
+)
+
+0=>Array
+(
+ [data] => c
+ [priority] => 0
+)
+
+EXTR_DATA
+2=>b
+1=>a
+0=>c
+EXTR_PRIORITY
+2=>2
+1=>1
+0=>0
+===DONE===
diff --git a/ext/spl/tests/pqueue_002.phpt b/ext/spl/tests/pqueue_002.phpt
new file mode 100644
index 0000000..eaab2cf
--- /dev/null
+++ b/ext/spl/tests/pqueue_002.phpt
@@ -0,0 +1,67 @@
+--TEST--
+SPL: SplPriorityQueue: exceptions
+--FILE--
+<?php
+class myPQueue extends SplPriorityQueue {
+ public function compare($a, $b) {
+ throw new exception("foo");
+ }
+}
+
+$h = new myPQueue;
+
+try {
+ $h->insert(1, 1);
+ echo "inserted 1\n";
+ $h->insert(2, 1);
+ echo "inserted 2\n";
+ $h->insert(3, 1);
+ echo "inserted 3\n";
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+try {
+ $h->insert(4, 1);
+ echo "inserted 4\n";
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+try {
+ var_dump($h->extract());
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ var_dump($h->extract());
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+
+echo "Recovering..\n";
+$h->recoverFromCorruption();
+
+try {
+ var_dump($h->extract());
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+try {
+ var_dump($h->extract());
+} catch(Exception $e) {
+ echo "Exception: ".$e->getMessage()."\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+inserted 1
+Exception: foo
+Exception: Heap is corrupted, heap properties are no longer ensured.
+Exception: Heap is corrupted, heap properties are no longer ensured.
+Exception: Heap is corrupted, heap properties are no longer ensured.
+Recovering..
+int(1)
+int(2)
+===DONE===
diff --git a/ext/spl/tests/pqueue_003.phpt b/ext/spl/tests/pqueue_003.phpt
new file mode 100644
index 0000000..9c0b5a5
--- /dev/null
+++ b/ext/spl/tests/pqueue_003.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: SplPriorityQueue: iteration through methods
+--FILE--
+<?php
+$h = new SplPriorityQueue();
+
+$h->insert(1, 1);
+$h->insert(5, 5);
+$h->insert(0, 0);
+$h->insert(4, 4);
+
+$h->rewind();
+echo "count(\$h) = ".count($h)."\n";
+echo "\$h->count() = ".$h->count()."\n";
+while ($h->valid()) {
+ $k = $h->key();
+ $v = $h->current();
+ echo "$k=>$v\n";
+ $h->next();
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+count($h) = 4
+$h->count() = 4
+3=>5
+2=>4
+1=>1
+0=>0
+===DONE===
diff --git a/ext/spl/tests/pqueue_004.phpt b/ext/spl/tests/pqueue_004.phpt
new file mode 100644
index 0000000..3a86f9e
--- /dev/null
+++ b/ext/spl/tests/pqueue_004.phpt
@@ -0,0 +1,54 @@
+--TEST--
+SPL: SplPriorityQueue: var_dump
+--FILE--
+<?php
+$pq = new SplPriorityQueue();
+
+$pq->insert("a", 0);
+$pq->insert("b", 1);
+$pq->insert("c", 5);
+$pq->insert("d", -2);
+
+var_dump($pq);
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+object(SplPriorityQueue)#1 (3) {
+ ["flags":"SplPriorityQueue":private]=>
+ int(1)
+ ["isCorrupted":"SplPriorityQueue":private]=>
+ bool(false)
+ ["heap":"SplPriorityQueue":private]=>
+ array(4) {
+ [0]=>
+ array(2) {
+ ["data"]=>
+ string(1) "c"
+ ["priority"]=>
+ int(5)
+ }
+ [1]=>
+ array(2) {
+ ["data"]=>
+ string(1) "a"
+ ["priority"]=>
+ int(0)
+ }
+ [2]=>
+ array(2) {
+ ["data"]=>
+ string(1) "b"
+ ["priority"]=>
+ int(1)
+ }
+ [3]=>
+ array(2) {
+ ["data"]=>
+ string(1) "d"
+ ["priority"]=>
+ int(-2)
+ }
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/pqueue_compare_basic.phpt b/ext/spl/tests/pqueue_compare_basic.phpt
new file mode 100644
index 0000000..1544add
--- /dev/null
+++ b/ext/spl/tests/pqueue_compare_basic.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: SplPriorityQueue: test compare
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplPriorityQueue();
+var_dump($h->compare(4, 5) < 0);
+var_dump($h->compare(5, 5) == 0);
+var_dump($h->compare(5, 4) > 0);
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/pqueue_compare_error.phpt b/ext/spl/tests/pqueue_compare_error.phpt
new file mode 100644
index 0000000..610be2a
--- /dev/null
+++ b/ext/spl/tests/pqueue_compare_error.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: Priority queue compare, illegal number of args
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplPriorityQueue();
+$h->compare();
+$h->compare(1);
+$h->compare(1, 2, 3);
+?>
+--EXPECTF--
+Warning: SplPriorityQueue::compare() expects exactly 2 parameters, 0 given in %s
+
+Warning: SplPriorityQueue::compare() expects exactly 2 parameters, 1 given in %s
+
+Warning: SplPriorityQueue::compare() expects exactly 2 parameters, 3 given in %s
+
diff --git a/ext/spl/tests/pqueue_current_error.phpt b/ext/spl/tests/pqueue_current_error.phpt
new file mode 100644
index 0000000..7fdf0af
--- /dev/null
+++ b/ext/spl/tests/pqueue_current_error.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplPriorityQueue current on empty queue should give null
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplPriorityQueue();
+var_dump($h->current());
+?>
+--EXPECT--
+NULL
diff --git a/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt b/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt
new file mode 100644
index 0000000..f543072
--- /dev/null
+++ b/ext/spl/tests/recursiveIteratorIterator_beginchildren_error.phpt
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in beginchildren which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(array(1,2),2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function beginchildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt2->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->beginchildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt b/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt
new file mode 100644
index 0000000..88f03fb
--- /dev/null
+++ b/ext/spl/tests/recursiveIteratorIterator_callHasChildren_error.phpt
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in callHasChildren which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(1,2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function callHasChildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt2->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->callHasChildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt b/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt
new file mode 100644
index 0000000..e25d3ed
--- /dev/null
+++ b/ext/spl/tests/recursiveIteratorIterator_endchildren_error.phpt
@@ -0,0 +1,42 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in endchildren which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(array(1,2));
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function endchildren() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+foreach ($recItIt as $val) echo "$val\n";
+
+$recItIt2 = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+echo "===NEXT LOOP===\n";
+
+foreach ($recItIt2 as $val) echo "$val\n";
+
+?>
+--EXPECTF--
+1
+2
+===NEXT LOOP===
+1
+2
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->endchildren()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt b/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt
new file mode 100644
index 0000000..3a91ed5
--- /dev/null
+++ b/ext/spl/tests/recursiveIteratorIterator_nextelement_error.phpt
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RecursiveIteratorIterator - Exception thrown in nextelement which should be handled in next()
+--FILE--
+<?php
+
+$arr = array(1,2);
+$arrOb = new ArrayObject($arr);
+
+$recArrIt = new RecursiveArrayIterator($arrOb->getIterator());
+
+class MyRecursiveIteratorIterator extends RecursiveIteratorIterator {
+
+ function nextelement() {
+ throw new Exception;
+ }
+}
+
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD);
+
+var_dump($recItIt->next());
+
+$recItIt = new MyRecursiveIteratorIterator($recArrIt, RecursiveIteratorIterator::LEAVES_ONLY);
+
+var_dump($recItIt->next());
+
+?>
+--EXPECTF--
+NULL
+
+Fatal error: Uncaught exception 'Exception' in %s
+Stack trace:
+#0 [internal function]: MyRecursiveIteratorIterator->nextelement()
+#1 %s: RecursiveIteratorIterator->next()
+#2 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/recursive_tree_iterator_001.phpt b/ext/spl/tests/recursive_tree_iterator_001.phpt
new file mode 100644
index 0000000..f70186c
--- /dev/null
+++ b/ext/spl/tests/recursive_tree_iterator_001.phpt
@@ -0,0 +1,102 @@
+--TEST--
+SPL: RecursiveTreeIterator
+--INI--
+error_reporting=E_ALL&~E_NOTICE
+--FILE--
+<?php
+
+$ary = array(
+ 0 => array(
+ "a",
+ 1,
+ ),
+ "a" => array(
+ 2,
+ "b",
+ 3 => array(
+ 4,
+ "c",
+ ),
+ "3" => array(
+ 4,
+ "c",
+ ),
+ ),
+);
+
+$it = new RecursiveArrayIterator($ary);
+echo "-- flags = BYPASS_KEY --\n";
+foreach(new RecursiveTreeIterator($it) as $k => $v) {
+ echo "[$k] => $v\n";
+}
+echo "-- flags = BYPASS_CURRENT --\n";
+foreach(new RecursiveTreeIterator($it, RecursiveTreeIterator::BYPASS_CURRENT) as $k => $v) {
+ echo "[$k] => $v\n";
+}
+echo "-- flags = BYPASS_KEY|BYPASS_KEY --\n";
+foreach(new RecursiveTreeIterator($it, RecursiveTreeIterator::BYPASS_CURRENT|RecursiveTreeIterator::BYPASS_KEY) as $k => $v) {
+ echo "[$k] => $v\n";
+}
+echo "-- flags = 0 --\n";
+foreach(new RecursiveTreeIterator($it, 0) as $k => $v) {
+ echo "[$k] => $v\n";
+}
+echo "-- flags = 0, caching_it_flags = CachingIterator::CATCH_GET_CHILD --\n";
+foreach(new RecursiveTreeIterator($it, 0, CachingIterator::CATCH_GET_CHILD) as $k => $v) {
+ echo "[$k] => $v\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+-- flags = BYPASS_KEY --
+[0] => |-Array
+[0] => | |-a
+[1] => | \-1
+[a] => \-Array
+[0] => |-2
+[1] => |-b
+[3] => \-Array
+[0] => |-4
+[1] => \-c
+-- flags = BYPASS_CURRENT --
+[|-0] => Array
+[| |-0] => a
+[| \-1] => 1
+[\-a] => Array
+[ |-0] => 2
+[ |-1] => b
+[ \-3] => Array
+[ |-0] => 4
+[ \-1] => c
+-- flags = BYPASS_KEY|BYPASS_KEY --
+[0] => Array
+[0] => a
+[1] => 1
+[a] => Array
+[0] => 2
+[1] => b
+[3] => Array
+[0] => 4
+[1] => c
+-- flags = 0 --
+[|-0] => |-Array
+[| |-0] => | |-a
+[| \-1] => | \-1
+[\-a] => \-Array
+[ |-0] => |-2
+[ |-1] => |-b
+[ \-3] => \-Array
+[ |-0] => |-4
+[ \-1] => \-c
+-- flags = 0, caching_it_flags = CachingIterator::CATCH_GET_CHILD --
+[|-0] => |-Array
+[| |-0] => | |-a
+[| \-1] => | \-1
+[\-a] => \-Array
+[ |-0] => |-2
+[ |-1] => |-b
+[ \-3] => \-Array
+[ |-0] => |-4
+[ \-1] => \-c
+===DONE===
diff --git a/ext/spl/tests/recursive_tree_iterator_002.phpt b/ext/spl/tests/recursive_tree_iterator_002.phpt
new file mode 100644
index 0000000..1aae288
--- /dev/null
+++ b/ext/spl/tests/recursive_tree_iterator_002.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: RecursiveTreeIterator(void)
+--INI--
+error_reporting=E_ALL&~E_NOTICE
+--FILE--
+<?php
+try {
+ new RecursiveTreeIterator();
+} catch (InvalidArgumentException $e) {
+ echo "InvalidArgumentException thrown\n";
+}
+?>
+===DONE===
+--EXPECTF--
+InvalidArgumentException thrown
+===DONE===
diff --git a/ext/spl/tests/recursive_tree_iterator_003.phpt b/ext/spl/tests/recursive_tree_iterator_003.phpt
new file mode 100644
index 0000000..83c8553
--- /dev/null
+++ b/ext/spl/tests/recursive_tree_iterator_003.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: RecursiveTreeIterator(non-traversable)
+--INI--
+error_reporting=E_ALL&~E_NOTICE
+--FILE--
+<?php
+try {
+ new RecursiveTreeIterator(new ArrayIterator(array()));
+} catch (InvalidArgumentException $e) {
+ echo "InvalidArgumentException thrown\n";
+}
+?>
+===DONE===
+--EXPECTF--
+InvalidArgumentException thrown
+===DONE===
diff --git a/ext/spl/tests/recursive_tree_iterator_004.phpt b/ext/spl/tests/recursive_tree_iterator_004.phpt
new file mode 100644
index 0000000..ad3ba6c
--- /dev/null
+++ b/ext/spl/tests/recursive_tree_iterator_004.phpt
@@ -0,0 +1,43 @@
+--TEST--
+SPL: RecursiveTreeIterator methods
+--INI--
+error_reporting=E_ALL&~E_NOTICE
+--FILE--
+<?php
+
+$ary = array(
+ 0 => array(
+ "a",
+ 1,
+ ),
+ "a" => array(
+ 2,
+ "b",
+ 3 => array(
+ 4,
+ "c",
+ ),
+ "3" => array(
+ 4,
+ "c",
+ ),
+ ),
+);
+
+$it = new RecursiveTreeIterator(new RecursiveArrayIterator($ary));
+foreach($it as $k => $v) {
+ echo '[' . $it->key() . '] => ' . $it->getPrefix() . $it->getEntry() . $it->getPostfix() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+[0] => |-Array
+[0] => | |-a
+[1] => | \-1
+[a] => \-Array
+[0] => |-2
+[1] => |-b
+[3] => \-Array
+[0] => |-4
+[1] => \-c
+===DONE===
diff --git a/ext/spl/tests/recursive_tree_iterator_005.phpt b/ext/spl/tests/recursive_tree_iterator_005.phpt
new file mode 100644
index 0000000..b14811f
--- /dev/null
+++ b/ext/spl/tests/recursive_tree_iterator_005.phpt
@@ -0,0 +1,116 @@
+--TEST--
+SPL: RecursiveTreeIterator and binary vs unicode (PHP 6.0+)
+--INI--
+error_reporting=E_ALL&~E_NOTICE
+--FILE--
+<?php
+
+$ary = array(
+ 0 => array(
+ (binary) "binary",
+ "abc2",
+ 1,
+ ),
+ (binary) "binary" => array(
+ 2,
+ "b",
+ 3 => array(
+ 4,
+ "c",
+ ),
+ "4abc" => array(
+ 4,
+ "c",
+ ),
+ ),
+);
+
+$it = new RecursiveTreeIterator(new RecursiveArrayIterator($ary), 0);
+foreach($it as $k => $v) {
+ var_dump($v);
+}
+echo "\n----------------\n\n";
+foreach($it as $k => $v) {
+ var_dump($k);
+}
+echo "\n----------------\n\n";
+echo "key, getEntry, current:\n";
+foreach($it as $k => $v) {
+ var_dump($it->key(), $it->getEntry(), $it->current());
+}
+?>
+===DONE===
+--EXPECT--
+string(7) "|-Array"
+string(10) "| |-binary"
+string(8) "| |-abc2"
+string(5) "| \-1"
+string(7) "\-Array"
+string(5) " |-2"
+string(5) " |-b"
+string(9) " |-Array"
+string(7) " | |-4"
+string(7) " | \-c"
+string(9) " \-Array"
+string(7) " |-4"
+string(7) " \-c"
+
+----------------
+
+string(3) "|-0"
+string(5) "| |-0"
+string(5) "| |-1"
+string(5) "| \-2"
+string(8) "\-binary"
+string(5) " |-0"
+string(5) " |-1"
+string(5) " |-3"
+string(7) " | |-0"
+string(7) " | \-1"
+string(8) " \-4abc"
+string(7) " |-0"
+string(7) " \-1"
+
+----------------
+
+key, getEntry, current:
+string(3) "|-0"
+string(5) "Array"
+string(7) "|-Array"
+string(5) "| |-0"
+string(6) "binary"
+string(10) "| |-binary"
+string(5) "| |-1"
+string(4) "abc2"
+string(8) "| |-abc2"
+string(5) "| \-2"
+string(1) "1"
+string(5) "| \-1"
+string(8) "\-binary"
+string(5) "Array"
+string(7) "\-Array"
+string(5) " |-0"
+string(1) "2"
+string(5) " |-2"
+string(5) " |-1"
+string(1) "b"
+string(5) " |-b"
+string(5) " |-3"
+string(5) "Array"
+string(9) " |-Array"
+string(7) " | |-0"
+string(1) "4"
+string(7) " | |-4"
+string(7) " | \-1"
+string(1) "c"
+string(7) " | \-c"
+string(8) " \-4abc"
+string(5) "Array"
+string(9) " \-Array"
+string(7) " |-0"
+string(1) "4"
+string(7) " |-4"
+string(7) " \-1"
+string(1) "c"
+string(7) " \-c"
+===DONE===
diff --git a/ext/spl/tests/recursive_tree_iterator_006.phpt b/ext/spl/tests/recursive_tree_iterator_006.phpt
new file mode 100644
index 0000000..17f51b6
--- /dev/null
+++ b/ext/spl/tests/recursive_tree_iterator_006.phpt
@@ -0,0 +1,112 @@
+--TEST--
+SPL: RecursiveTreeIterator and IteratorAggregate
+--INI--
+error_reporting=E_ALL&~E_NOTICE
+--FILE--
+<?php
+
+$ary = array(
+ 0 => array(
+ "a",
+ 1,
+ ),
+ "a" => array(
+ 2,
+ "b",
+ 3 => array(
+ 4,
+ "c",
+ ),
+ "3" => array(
+ 4,
+ "c",
+ ),
+ ),
+);
+
+class RecursiveArrayIteratorAggregated implements IteratorAggregate {
+ public $it;
+ function __construct($it) {
+ $this->it = new RecursiveArrayIterator($it);
+ }
+ function getIterator() {
+ return $this->it;
+ }
+}
+
+$it = new RecursiveArrayIteratorAggregated($ary);
+echo "-- flags = BYPASS_KEY --\n";
+foreach(new RecursiveTreeIterator($it) as $k => $v) {
+ echo "[$k] => $v\n";
+}
+echo "-- flags = BYPASS_CURRENT --\n";
+foreach(new RecursiveTreeIterator($it, RecursiveTreeIterator::BYPASS_CURRENT) as $k => $v) {
+ echo "[$k] => $v\n";
+}
+echo "-- flags = BYPASS_KEY|BYPASS_KEY --\n";
+foreach(new RecursiveTreeIterator($it, RecursiveTreeIterator::BYPASS_CURRENT|RecursiveTreeIterator::BYPASS_KEY) as $k => $v) {
+ echo "[$k] => $v\n";
+}
+echo "-- flags = 0 --\n";
+foreach(new RecursiveTreeIterator($it, 0) as $k => $v) {
+ echo "[$k] => $v\n";
+}
+echo "-- flags = 0, caching_it_flags = CachingIterator::CATCH_GET_CHILD --\n";
+foreach(new RecursiveTreeIterator($it, 0, CachingIterator::CATCH_GET_CHILD) as $k => $v) {
+ echo "[$k] => $v\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+-- flags = BYPASS_KEY --
+[0] => |-Array
+[0] => | |-a
+[1] => | \-1
+[a] => \-Array
+[0] => |-2
+[1] => |-b
+[3] => \-Array
+[0] => |-4
+[1] => \-c
+-- flags = BYPASS_CURRENT --
+[|-0] => Array
+[| |-0] => a
+[| \-1] => 1
+[\-a] => Array
+[ |-0] => 2
+[ |-1] => b
+[ \-3] => Array
+[ |-0] => 4
+[ \-1] => c
+-- flags = BYPASS_KEY|BYPASS_KEY --
+[0] => Array
+[0] => a
+[1] => 1
+[a] => Array
+[0] => 2
+[1] => b
+[3] => Array
+[0] => 4
+[1] => c
+-- flags = 0 --
+[|-0] => |-Array
+[| |-0] => | |-a
+[| \-1] => | \-1
+[\-a] => \-Array
+[ |-0] => |-2
+[ |-1] => |-b
+[ \-3] => \-Array
+[ |-0] => |-4
+[ \-1] => \-c
+-- flags = 0, caching_it_flags = CachingIterator::CATCH_GET_CHILD --
+[|-0] => |-Array
+[| |-0] => | |-a
+[| \-1] => | \-1
+[\-a] => \-Array
+[ |-0] => |-2
+[ |-1] => |-b
+[ \-3] => \-Array
+[ |-0] => |-4
+[ \-1] => \-c
+===DONE===
diff --git a/ext/spl/tests/recursive_tree_iterator_007.phpt b/ext/spl/tests/recursive_tree_iterator_007.phpt
new file mode 100644
index 0000000..6a8ff84
--- /dev/null
+++ b/ext/spl/tests/recursive_tree_iterator_007.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: RecursiveTreeIterator and Exception from getEntry()
+--INI--
+error_reporting=E_ALL&~E_NOTICE
+--FILE--
+<?php
+
+$ary = array(new stdClass);
+
+class RecursiveArrayIteratorAggregated implements IteratorAggregate {
+ public $it;
+ function __construct($it) {
+ $this->it = new RecursiveArrayIterator($it);
+ }
+ function getIterator() {
+ return $this->it;
+ }
+}
+
+$it = new RecursiveArrayIteratorAggregated($ary);
+try {
+ foreach(new RecursiveTreeIterator($it) as $k => $v) {
+ echo "[$k] => $v\n";
+ }
+} catch (UnexpectedValueException $e) {
+ echo "UnexpectedValueException thrown\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+UnexpectedValueException thrown
+===DONE===
diff --git a/ext/spl/tests/recursive_tree_iterator_008.phpt b/ext/spl/tests/recursive_tree_iterator_008.phpt
new file mode 100644
index 0000000..a034980
--- /dev/null
+++ b/ext/spl/tests/recursive_tree_iterator_008.phpt
@@ -0,0 +1,41 @@
+--TEST--
+SPL: RecursiveTreeIterator::setPrefixPart()
+--INI--
+error_reporting=E_ALL&~E_NOTICE
+--FILE--
+<?php
+
+$ary = array(
+ "a" => array("b"),
+ "c" => array("d"),
+);
+
+$it = new RecursiveArrayIterator($ary);
+$it = new RecursiveTreeIterator($it);
+for($i = 0; $i < 6; ++$i) {
+ $it->setPrefixPart($i, $i);
+}
+foreach($it as $k => $v) {
+ echo "[$k] => $v\n";
+}
+try {
+ $it->setPrefixPart(-1, "");
+ $it->setPrefixPart(6, "");
+} catch (OutOfRangeException $e) {
+ echo "OutOfRangeException thrown\n";
+}
+try {
+ $it->setPrefixPart(6, "");
+} catch (OutOfRangeException $e) {
+ echo "OutOfRangeException thrown\n";
+}
+?>
+===DONE===
+--EXPECTF--
+[a] => 035Array
+[0] => 0145b
+[c] => 045Array
+[0] => 0245d
+OutOfRangeException thrown
+OutOfRangeException thrown
+===DONE===
diff --git a/ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt b/ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt
new file mode 100644
index 0000000..81c853f
--- /dev/null
+++ b/ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RecursiveTreeIterator::setPrefixPart() Test arguments
+--CREDITS--
+Roshan Abraham (roshanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+
+$arr = array(
+ "a" => array("b")
+);
+
+$it = new RecursiveArrayIterator($arr);
+$it = new RecursiveTreeIterator($it);
+
+$it->setPrefixPart(1); // Should throw a warning as setPrefixPart expects 2 arguments
+
+$a = new stdClass();
+$it->setPrefixPart($a, 1); // Should throw a warning as setPrefixPart expects argument 1 to be long integer
+
+$it->setPrefixPart(1, $a); // Should throw a warning as setPrefixPart expects argument 2 to be a string
+
+
+?>
+===DONE===
+--EXPECTF--
+Warning: RecursiveTreeIterator::setPrefixPart() expects exactly 2 parameters, 1 given in %s on line %d
+
+Warning: RecursiveTreeIterator::setPrefixPart() expects parameter 1 to be long, object given in %s on line %d
+
+Warning: RecursiveTreeIterator::setPrefixPart() expects parameter 2 to be %binary_string_optional%, object given in %s on line %d
+===DONE===
diff --git a/ext/spl/tests/recursiveiteratoriterator_beginiteration_basic.phpt b/ext/spl/tests/recursiveiteratoriterator_beginiteration_basic.phpt
new file mode 100644
index 0000000..c9476e0
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_beginiteration_basic.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RecursiveIteratorIterator::beginIteration() is called by RecursiveIteratorIterator::rewind()
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2);
+$sub_iterator = new RecursiveArrayIterator($sample_array);
+
+$iterator = new RecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+
+class SkipsFirstElementRecursiveIteratorIterator extends RecursiveIteratorIterator {
+ public function beginIteration() {
+ echo "::beginIteration() was invoked\n";
+ $this->next();
+ }
+}
+$iterator = new SkipsFirstElementRecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+?>
+--EXPECT--
+int(1)
+int(2)
+::beginIteration() was invoked
+int(2)
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_enditeration_basic.phpt b/ext/spl/tests/recursiveiteratoriterator_enditeration_basic.phpt
new file mode 100644
index 0000000..0355401
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_enditeration_basic.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RecursiveIteratorIterator::endIteration() is called when ::valid() first returns false
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2);
+$sub_iterator = new RecursiveArrayIterator($sample_array);
+
+$iterator = new RecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+
+class EndIterationRecursiveIteratorIterator extends RecursiveIteratorIterator {
+ public function endIteration() {
+ echo "::endIteration() was invoked\n";
+ }
+}
+$iterator = new EndIterationRecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+?>
+--EXPECT--
+int(1)
+int(2)
+int(1)
+int(2)
+::endIteration() was invoked
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_basic.phpt b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_basic.phpt
new file mode 100644
index 0000000..5d1c958
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_basic.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SPL: RecursiveIteratorIterator::getSubIterator() returns iterator passed in constructor
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2, array(3, 4));
+
+$sub_iterator = new RecursiveArrayIterator($sample_array);
+$not_sub_iterator = new RecursiveArrayIterator($sample_array);
+$iterator = new RecursiveIteratorIterator($sub_iterator);
+
+var_dump($iterator->getSubIterator() === $sub_iterator);
+var_dump($iterator->getSubIterator() === $not_sub_iterator);
+?>
+--EXPECT--
+bool(true)
+bool(false)
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt
new file mode 100644
index 0000000..760082f
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: RecursiveIteratorIterator::getSubIterator() expects at most 1 parameter
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator(array()));
+$iterator->getSubIterator();
+$iterator->getSubIterator(0);
+$iterator->getSubIterator(0, 0);
+?>
+--EXPECTF--
+Warning: RecursiveIteratorIterator::getSubIterator() expects at most 1 parameter, 2 given in %s on line 5
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation.phpt b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation.phpt
new file mode 100644
index 0000000..a7b84c4
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation.phpt
@@ -0,0 +1,42 @@
+--TEST--
+SPL: RecursiveIteratorIterator::getSubIterator() returns different iterators depending on the current element
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2, array(3, 4));
+
+$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($sample_array));
+
+$iterator->next();
+$iterator->next();
+var_dump(get_class($iterator->getSubIterator()));
+var_dump($iterator->getSubIterator()->getArrayCopy());
+$iterator->next();
+var_dump(get_class($iterator->getSubIterator()));
+var_dump($iterator->getSubIterator()->getArrayCopy());
+?>
+--EXPECTF--
+%unicode|string%(22) "RecursiveArrayIterator"
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+ }
+}
+%unicode|string%(22) "RecursiveArrayIterator"
+array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+}
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_002.phpt b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_002.phpt
new file mode 100644
index 0000000..aac4e65
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_002.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SPL: RecursiveIteratorIterator::getSubIterator() returns NULL if there's no current element
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1);
+
+$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($sample_array));
+
+$iterator->next();
+var_dump(is_null($iterator->getSubIterator()));
+$iterator->next();
+var_dump(is_null($iterator->getSubIterator()));
+?>
+--EXPECT--
+bool(false)
+bool(false)
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_003.phpt b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_003.phpt
new file mode 100644
index 0000000..ff18840
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_variation_003.phpt
@@ -0,0 +1,42 @@
+--TEST--
+SPL: RecursiveIteratorIterator::getSubIterator() with explicit level parameter
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2, array(3, 4));
+
+$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($sample_array));
+
+$iterator->next();
+$iterator->next();
+$iterator->next();
+var_dump($iterator->getSubIterator(-1));
+var_dump($iterator->getSubIterator(0)->getArrayCopy());
+var_dump($iterator->getSubIterator(1)->getArrayCopy());
+var_dump($iterator->getSubIterator(2));
+?>
+--EXPECT--
+NULL
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+ }
+}
+array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+}
+NULL
+
diff --git a/ext/spl/tests/recursiveiteratoriterator_nextelement_basic.phpt b/ext/spl/tests/recursiveiteratoriterator_nextelement_basic.phpt
new file mode 100644
index 0000000..0bf4f19
--- /dev/null
+++ b/ext/spl/tests/recursiveiteratoriterator_nextelement_basic.phpt
@@ -0,0 +1,39 @@
+--TEST--
+SPL: RecursiveIteratorIterator::nextElement() is called when the next element is ready
+--CREDITS--
+Matt Raines matt@raines.me.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$sample_array = array(1, 2, array(3, 4));
+$sub_iterator = new RecursiveArrayIterator($sample_array);
+
+$iterator = new RecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+
+class NextElementRecursiveIteratorIterator extends RecursiveIteratorIterator {
+ public function nextElement() {
+ echo "::nextElement() was invoked\n";
+ }
+}
+$iterator = new NextElementRecursiveIteratorIterator($sub_iterator);
+foreach ($iterator as $element) {
+ var_dump($element);
+}
+?>
+--EXPECT--
+int(1)
+int(2)
+int(3)
+int(4)
+::nextElement() was invoked
+int(1)
+::nextElement() was invoked
+int(2)
+::nextElement() was invoked
+int(3)
+::nextElement() was invoked
+int(4)
+
diff --git a/ext/spl/tests/regexIterator_flags_basic.phpt b/ext/spl/tests/regexIterator_flags_basic.phpt
new file mode 100644
index 0000000..535be00
--- /dev/null
+++ b/ext/spl/tests/regexIterator_flags_basic.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: RegexIterator::getFlags() and setFlags() basic tests
+--CREDITS--
+Felix De Vliegher <felix.devliegher@gmail.com>
+--FILE--
+<?php
+
+$array = array('foo', 'bar', 'baz');
+$iterator = new ArrayIterator($array);
+$regexIterator = new RegexIterator($iterator, "/f/", null, RegexIterator::USE_KEY);
+
+var_dump($regexIterator->getFlags() === RegexIterator::USE_KEY);
+
+// Test a change in flags, there's only one class constant so it has to be another int value
+$regexIterator->setFlags(3);
+var_dump($regexIterator->getFlags() === RegexIterator::USE_KEY);
+$regexIterator->setFlags(RegexIterator::USE_KEY);
+var_dump($regexIterator->getFlags() === RegexIterator::USE_KEY);
+
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
diff --git a/ext/spl/tests/regexIterator_mode_basic.phpt b/ext/spl/tests/regexIterator_mode_basic.phpt
new file mode 100644
index 0000000..a39b969
--- /dev/null
+++ b/ext/spl/tests/regexIterator_mode_basic.phpt
@@ -0,0 +1,32 @@
+--TEST--
+SPL: RegexIterator::getMode() and setMode() basic tests
+--CREDITS--
+Felix De Vliegher <felix.devliegher@gmail.com>
+--FILE--
+<?php
+
+$array = array('foo', 'bar', 'baz');
+$iterator = new ArrayIterator($array);
+$regexIterator = new RegexIterator($iterator, "/f/");
+
+var_dump($regexIterator->getMode() === RegexIterator::MATCH);
+
+$regexIterator->setMode(RegexIterator::MATCH);
+var_dump($regexIterator->getMode() === RegexIterator::MATCH);
+
+$regexIterator->setMode(RegexIterator::GET_MATCH);
+var_dump($regexIterator->getMode() === RegexIterator::GET_MATCH);
+
+$regexIterator->setMode(RegexIterator::ALL_MATCHES);
+var_dump($regexIterator->getMode() === RegexIterator::ALL_MATCHES);
+
+$regexIterator->setMode(RegexIterator::SPLIT);
+var_dump($regexIterator->getMode() === RegexIterator::SPLIT);
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/spl/tests/regexIterator_setMode_error.phpt b/ext/spl/tests/regexIterator_setMode_error.phpt
new file mode 100644
index 0000000..52af499
--- /dev/null
+++ b/ext/spl/tests/regexIterator_setMode_error.phpt
@@ -0,0 +1,28 @@
+--TEST--
+SPL: RegexIterator::setMode() error tests
+--CREDITS--
+Felix De Vliegher <felix.devliegher@gmail.com>
+--FILE--
+<?php
+
+$array = array('foo', 'bar', 'baz');
+$regexIterator = new RegexIterator(new ArrayIterator($array), "/f/");
+
+var_dump($regexIterator->getMode());
+
+try {
+ $regexIterator->setMode(7);
+} catch (InvalidArgumentException $e) {
+ var_dump($e->getMessage());
+ var_dump($e->getCode());
+}
+
+$regexIterator->setMode('foo');
+
+?>
+--EXPECTF--
+int(0)
+string(14) "Illegal mode 7"
+int(0)
+
+Warning: RegexIterator::setMode() expects parameter 1 to be long, string given in %s on line %d
diff --git a/ext/spl/tests/regexiterator_getpregflags.phpt b/ext/spl/tests/regexiterator_getpregflags.phpt
new file mode 100644
index 0000000..58a4dc4
--- /dev/null
+++ b/ext/spl/tests/regexiterator_getpregflags.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: RegexIterator::getPregFlags()
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class myIterator implements Iterator {
+
+function current (){}
+function key ( ){}
+function next ( ){}
+function rewind ( ){}
+function valid ( ){}
+
+
+}
+
+class TestRegexIterator extends RegexIterator{}
+
+$rege = '/^a/';
+
+
+$r = new TestRegexIterator(new myIterator, $rege);
+
+$r->setPregFlags(PREG_OFFSET_CAPTURE);
+
+echo is_long($r->getPregFlags());
+
+?>
+--EXPECTF--
+1 \ No newline at end of file
diff --git a/ext/spl/tests/regexiterator_getregex.phpt b/ext/spl/tests/regexiterator_getregex.phpt
new file mode 100644
index 0000000..d3113a5
--- /dev/null
+++ b/ext/spl/tests/regexiterator_getregex.phpt
@@ -0,0 +1,29 @@
+--TEST--
+SPL: RegexIterator::getRegex() basic tests
+--CREDITS--
+Joshua Thijssen <jthijssen@noxlogic.nl>
+--FILE--
+<?php
+
+$array = array('cat', 'hat', 'sat');
+$iterator = new ArrayIterator($array);
+
+# Simple regex
+$regexIterator = new RegexIterator($iterator, '/.at/');
+var_dump($regexIterator->getRegex());
+
+# Empty regular expression
+$regexIterator = new RegexIterator($iterator, '//');
+var_dump($regexIterator->getRegex());
+
+# "Complex" email regular expression
+$regexIterator = new RegexIterator($iterator, '|\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b|');
+var_dump($regexIterator->getRegex());
+
+
+
+?>
+--EXPECT--
+string(5) "/.at/"
+string(2) "//"
+string(43) "|\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b|"
diff --git a/ext/spl/tests/regexiterator_setflags_exception.phpt b/ext/spl/tests/regexiterator_setflags_exception.phpt
new file mode 100644
index 0000000..fdc8bca
--- /dev/null
+++ b/ext/spl/tests/regexiterator_setflags_exception.phpt
@@ -0,0 +1,35 @@
+--TEST--
+SPL: RegexIterator::setFlags() exceptions test
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class myIterator implements Iterator {
+
+function current (){}
+function key ( ){}
+function next ( ){}
+function rewind ( ){}
+function valid ( ){}
+
+
+}
+
+class TestRegexIterator extends RegexIterator{}
+
+$rege = '/^a/';
+
+
+$r = new TestRegexIterator(new myIterator, $rege);
+
+try{
+ $r->setFlags();
+}catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECTF--
+Warning: RegexIterator::setFlags() expects exactly 1 parameter, 0 given in %s \ No newline at end of file
diff --git a/ext/spl/tests/regexiterator_setpregflags.phpt b/ext/spl/tests/regexiterator_setpregflags.phpt
new file mode 100644
index 0000000..ea1b455
--- /dev/null
+++ b/ext/spl/tests/regexiterator_setpregflags.phpt
@@ -0,0 +1,34 @@
+--TEST--
+SPL: RegexIterator::setPregFlags()
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class myIterator implements Iterator {
+
+function current (){}
+function key ( ){}
+function next ( ){}
+function rewind ( ){}
+function valid ( ){}
+
+
+}
+
+class TestRegexIterator extends RegexIterator{}
+
+$rege = '/^a/';
+
+
+$r = new TestRegexIterator(new myIterator, $rege);
+
+$r->setPregFlags(PREG_OFFSET_CAPTURE);
+
+echo $r->getPregFlags();
+
+
+?>
+--EXPECTF--
+256 \ No newline at end of file
diff --git a/ext/spl/tests/regexiterator_setpregflags_exception.phpt b/ext/spl/tests/regexiterator_setpregflags_exception.phpt
new file mode 100644
index 0000000..cc7c17c
--- /dev/null
+++ b/ext/spl/tests/regexiterator_setpregflags_exception.phpt
@@ -0,0 +1,36 @@
+--TEST--
+SPL: RegexIterator::getPregFlags() exception test
+--CREDITS--
+Lance Kesson jac_kesson@hotmail.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class myIterator implements Iterator {
+
+function current (){}
+function key ( ){}
+function next ( ){}
+function rewind ( ){}
+function valid ( ){}
+
+
+}
+
+class TestRegexIterator extends RegexIterator{}
+
+$rege = '/^a/';
+
+
+$r = new TestRegexIterator(new myIterator, $rege);
+
+
+try{
+ $r->setPregFlags();
+}catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECTF--
+Warning: RegexIterator::setPregFlags() expects exactly 1 parameter, 0 given in %s \ No newline at end of file
diff --git a/ext/spl/tests/splDoublyLinkedList_shift_noParams.phpt b/ext/spl/tests/splDoublyLinkedList_shift_noParams.phpt
new file mode 100644
index 0000000..cd4ea5b
--- /dev/null
+++ b/ext/spl/tests/splDoublyLinkedList_shift_noParams.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Checks that the shift() method of DoublyLinkedList does not accept args.
+--CREDITS--
+PHPNW Test Fest 2009 - Rick Ogden
+--FILE--
+<?php
+$ll = new SplDoublyLinkedList();
+$ll->push(1);
+$ll->push(2);
+
+var_dump($ll->shift(1));
+?>
+--EXPECTF--
+Warning: SplDoublyLinkedList::shift() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
diff --git a/ext/spl/tests/spl_001.phpt b/ext/spl/tests/spl_001.phpt
new file mode 100644
index 0000000..e101272
--- /dev/null
+++ b/ext/spl/tests/spl_001.phpt
@@ -0,0 +1,34 @@
+--TEST--
+SPL: iterator_to_array() and iterator_count()
+--FILE--
+<?php
+
+$it = new ArrayObject(array("x"=>1, 1=>2, 3=>3, 4, "1"=>5));
+
+$ar = iterator_to_array($it);
+
+var_dump(iterator_count($it));
+
+print_r($ar);
+
+foreach($ar as $v)
+{
+ var_dump($v);
+}
+
+?>
+===DONE===
+--EXPECT--
+int(4)
+Array
+(
+ [x] => 1
+ [1] => 5
+ [3] => 3
+ [4] => 4
+)
+int(1)
+int(5)
+int(3)
+int(4)
+===DONE===
diff --git a/ext/spl/tests/spl_002.phpt b/ext/spl/tests/spl_002.phpt
new file mode 100644
index 0000000..d8b71b2
--- /dev/null
+++ b/ext/spl/tests/spl_002.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: Countable
+--FILE--
+<?php
+
+class Test implements Countable
+{
+ function count()
+ {
+ return 4;
+ }
+};
+
+$a = new Test;
+
+var_dump(count($a));
+
+?>
+===DONE===
+--EXPECT--
+int(4)
+===DONE===
diff --git a/ext/spl/tests/spl_003.phpt b/ext/spl/tests/spl_003.phpt
new file mode 100644
index 0000000..e92a41a
--- /dev/null
+++ b/ext/spl/tests/spl_003.phpt
@@ -0,0 +1,74 @@
+--TEST--
+SPL: class_parents() and class_implements()
+--FILE--
+<?php
+class a{}
+class b extends a{}
+class c extends b{}
+class d{}
+var_dump(class_parents(new c),
+ class_parents("c"),
+ class_parents(new b),
+ class_parents("b"),
+ class_parents("d"),
+ class_parents("foo", 0),
+ class_parents("foo", 1)
+);
+
+interface iface1{}
+interface iface2{}
+class f implements iface1, iface2{}
+var_dump(class_implements(new a),
+ class_implements("a"),
+ class_implements("aaa"),
+ class_implements("bbb", 0)
+);
+
+function __autoload($cname) {
+ var_dump($cname);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Warning: class_parents(): Class foo does not exist in %sspl_003.php on line %d
+string(3) "foo"
+
+Warning: class_parents(): Class foo does not exist and could not be loaded in %sspl_003.php on line %d
+array(2) {
+ ["b"]=>
+ string(1) "b"
+ ["a"]=>
+ string(1) "a"
+}
+array(2) {
+ ["b"]=>
+ string(1) "b"
+ ["a"]=>
+ string(1) "a"
+}
+array(1) {
+ ["a"]=>
+ string(1) "a"
+}
+array(1) {
+ ["a"]=>
+ string(1) "a"
+}
+array(0) {
+}
+bool(false)
+bool(false)
+string(3) "aaa"
+
+Warning: class_implements(): Class aaa does not exist and could not be loaded in %sspl_003.php on line %d
+
+Warning: class_implements(): Class bbb does not exist in %sspl_003.php on line %d
+array(0) {
+}
+array(0) {
+}
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/spl_004.phpt b/ext/spl/tests/spl_004.phpt
new file mode 100644
index 0000000..97896f8
--- /dev/null
+++ b/ext/spl/tests/spl_004.phpt
@@ -0,0 +1,84 @@
+--TEST--
+SPL: iterator_apply()
+--FILE--
+<?php
+
+function my_error_handler($errno, $errstr, $errfile, $errline) {
+ echo "Error: $errstr\n";
+}
+
+set_error_handler('my_error_handler');
+
+function test_arg($arg)
+{
+ if ($arg instanceof Iterator)
+ {
+ var_dump($arg->key());
+ var_dump($arg->current());
+ }
+ else
+ {
+ var_dump($arg);
+ }
+ return true;
+}
+
+function test()
+{
+ static $arg = 0;
+ var_dump($arg++);
+ return true;
+}
+
+$it = new RecursiveArrayIterator(array(1, array(21, 22), 3));
+
+var_dump(iterator_apply($it, 'test', NULL));
+
+echo "===ARGS===\n";
+var_dump(iterator_apply($it, 'test_arg', array($it)));
+
+echo "===RECURSIVE===\n";
+$it = new RecursiveIteratorIterator($it);
+var_dump(iterator_apply($it, 'test'));
+
+echo "===ERRORS===\n";
+var_dump(iterator_apply($it, 'test', 1));
+var_dump(iterator_apply($it, 'non_existing_functon'));
+var_dump(iterator_apply($it, 'non_existing_functon', NULL, 2));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+int(0)
+int(1)
+int(2)
+int(3)
+===ARGS===
+int(0)
+int(1)
+int(1)
+array(2) {
+ [0]=>
+ int(21)
+ [1]=>
+ int(22)
+}
+int(2)
+int(3)
+int(3)
+===RECURSIVE===
+int(3)
+int(4)
+int(5)
+int(6)
+int(4)
+===ERRORS===
+Error: Argument 3 passed to iterator_apply() must be of the type array, integer given
+Error: iterator_apply() expects parameter 3 to be array, integer given
+NULL
+Error: iterator_apply() expects parameter 2 to be a valid callback, function 'non_existing_functon' not found or invalid function name
+NULL
+Error: iterator_apply() expects at most 3 parameters, 4 given
+NULL
+===DONE===
diff --git a/ext/spl/tests/spl_005.phpt b/ext/spl/tests/spl_005.phpt
new file mode 100644
index 0000000..219c791
--- /dev/null
+++ b/ext/spl/tests/spl_005.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: spl_object_hash()
+--FILE--
+<?php
+
+var_dump(spl_object_hash(new stdClass));
+var_dump(spl_object_hash(42));
+var_dump(spl_object_hash());
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+string(32) "%s"
+
+Warning: spl_object_hash() expects parameter 1 to be object, integer given in %sspl_005.php on line %d
+NULL
+
+Warning: spl_object_hash() expects exactly 1 parameter, 0 given in %sspl_005.php on line %d
+NULL
+===DONE===
diff --git a/ext/spl/tests/spl_006.phpt b/ext/spl/tests/spl_006.phpt
new file mode 100644
index 0000000..1f5f85f
--- /dev/null
+++ b/ext/spl/tests/spl_006.phpt
@@ -0,0 +1,39 @@
+--TEST--
+SPL: iterator_to_array() without keys
+--FILE--
+<?php
+
+$it = new AppendIterator();
+$it->append(new ArrayIterator(array(1,2)));
+$it->append(new ArrayIterator(array(2,3)));
+
+var_dump(iterator_to_array($it));
+var_dump(iterator_to_array($it, false));
+var_dump(iterator_to_array($it, true));
+
+?>
+===DONE===
+--EXPECT--
+array(2) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(3)
+}
+array(4) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(2)
+ [3]=>
+ int(3)
+}
+array(2) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(3)
+}
+===DONE===
diff --git a/ext/spl/tests/spl_007.phpt b/ext/spl/tests/spl_007.phpt
new file mode 100644
index 0000000..6d4059d
--- /dev/null
+++ b/ext/spl/tests/spl_007.phpt
@@ -0,0 +1,24 @@
+--TEST--
+SPL: iterator_apply() with callback using __call()
+--FILE--
+<?php
+
+class Foo {
+ public function __call($name, $params) {
+ echo "Called $name.\n";
+ return true;
+ }
+}
+
+$it = new ArrayIterator(array(1, 2, 3));
+
+iterator_apply($it, array(new Foo, "foobar"));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+Called foobar.
+Called foobar.
+Called foobar.
+===DONE===
diff --git a/ext/spl/tests/spl_autoload_001.phpt b/ext/spl/tests/spl_autoload_001.phpt
new file mode 100644
index 0000000..ff9d1e9
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_001.phpt
@@ -0,0 +1,136 @@
+--TEST--
+SPL: spl_autoload() and friends
+--INI--
+include_path=.
+--FILE--
+<?php
+
+echo "===EMPTY===\n";
+
+var_dump(spl_autoload_extensions());
+
+try
+{
+ spl_autoload("TestClass");
+}
+catch(Exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+
+$test_exts = array(NULL, "1", ".inc,,.php.inc", "");
+
+foreach($test_exts as $exts)
+{
+ echo "===($exts)===\n";
+ try
+ {
+ spl_autoload("TestClass", $exts);
+ }
+ catch(Exception $e)
+ {
+ echo 'Exception: ' . $e->getMessage() . "\n";
+ }
+}
+
+try
+{
+ spl_autoload_extensions(".inc,.php.inc");
+ spl_autoload("TestClass");
+}
+catch(Exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+
+function TestFunc1($classname)
+{
+ echo __METHOD__ . "($classname)\n";
+}
+
+function TestFunc2($classname)
+{
+ echo __METHOD__ . "($classname)\n";
+}
+
+echo "===SPL_AUTOLOAD()===\n";
+
+spl_autoload_register();
+
+try
+{
+ var_dump(spl_autoload_extensions(".inc"));
+ var_dump(class_exists("TestClass", true));
+}
+catch(Exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+
+echo "===REGISTER===\n";
+
+spl_autoload_unregister("spl_autoload");
+spl_autoload_register("TestFunc1");
+spl_autoload_register("TestFunc2");
+spl_autoload_register("TestFunc2"); /* 2nd call ignored */
+spl_autoload_extensions(".inc,.class.inc"); /* we do not have spl_autoload_registered yet */
+
+try
+{
+ var_dump(class_exists("TestClass", true));
+}
+catch(Exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+
+echo "===LOAD===\n";
+
+spl_autoload_register("spl_autoload");
+var_dump(class_exists("TestClass", true));
+
+echo "===NOFUNCTION===\n";
+
+try
+{
+ spl_autoload_register("unavailable_autoload_function");
+}
+catch(Exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===EMPTY===
+string(9) ".inc,.php"
+%stestclass.inc
+Exception: Class TestClass could not be loaded
+===()===
+Exception: Class TestClass could not be loaded
+===(1)===
+Exception: Class TestClass could not be loaded
+===(.inc,,.php.inc)===
+%stestclass
+%stestclass.php.inc
+Exception: Class TestClass could not be loaded
+===()===
+Exception: Class TestClass could not be loaded
+Exception: Class TestClass could not be loaded
+===SPL_AUTOLOAD()===
+string(4) ".inc"
+Exception: Class TestClass could not be loaded
+===REGISTER===
+TestFunc1(TestClass)
+TestFunc2(TestClass)
+bool(false)
+===LOAD===
+TestFunc1(TestClass)
+TestFunc2(TestClass)
+%stestclass.class.inc
+bool(true)
+===NOFUNCTION===
+Exception: Function 'unavailable_autoload_function' not found (function 'unavailable_autoload_function' not found or invalid function name)
+===DONE===
diff --git a/ext/spl/tests/spl_autoload_002.phpt b/ext/spl/tests/spl_autoload_002.phpt
new file mode 100644
index 0000000..2373d6d
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_002.phpt
@@ -0,0 +1,70 @@
+--TEST--
+SPL: spl_autoload_functions()
+--SKIPIF--
+<?php
+if (spl_autoload_functions() !== false) die('skip __autoload() registered by php.ini');
+?>
+--FILE--
+<?php
+
+function SplAutoloadTest1($name) {}
+function SplAutoloadTest2($name) {}
+
+var_dump(spl_autoload_functions());
+
+spl_autoload_register();
+
+var_dump(spl_autoload_functions());
+
+spl_autoload_register('SplAutoloadTest1');
+spl_autoload_register('SplAutoloadTest2');
+spl_autoload_register('SplAutoloadTest1');
+
+var_dump(spl_autoload_functions());
+
+spl_autoload_unregister('SplAutoloadTest1');
+
+var_dump(spl_autoload_functions());
+
+spl_autoload_unregister('spl_autoload_call');
+
+var_dump(spl_autoload_functions());
+
+spl_autoload_register();
+
+var_dump(spl_autoload_functions());
+
+spl_autoload_unregister('spl_autoload');
+
+var_dump(spl_autoload_functions());
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+bool(false)
+array(1) {
+ [0]=>
+ string(12) "spl_autoload"
+}
+array(3) {
+ [0]=>
+ string(12) "spl_autoload"
+ [1]=>
+ string(16) "SplAutoloadTest1"
+ [2]=>
+ string(16) "SplAutoloadTest2"
+}
+array(2) {
+ [0]=>
+ string(12) "spl_autoload"
+ [1]=>
+ string(16) "SplAutoloadTest2"
+}
+bool(false)
+array(1) {
+ [0]=>
+ string(12) "spl_autoload"
+}
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/spl_autoload_003.phpt b/ext/spl/tests/spl_autoload_003.phpt
new file mode 100644
index 0000000..7c0bd1a
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_003.phpt
@@ -0,0 +1,45 @@
+--TEST--
+SPL: spl_autoload() and friends
+--INI--
+include_path=.
+--FILE--
+<?php
+
+function TestFunc1($classname)
+{
+ echo __METHOD__ . "($classname)\n";
+}
+
+function TestFunc2($classname)
+{
+ echo __METHOD__ . "($classname)\n";
+ throw new Exception("Class $classname missing");
+}
+
+function TestFunc3($classname)
+{
+ echo __METHOD__ . "($classname)\n";
+}
+
+spl_autoload_register("TestFunc1");
+spl_autoload_register("TestFunc2");
+spl_autoload_register("TestFunc3");
+
+try
+{
+ var_dump(class_exists("TestClass", true));
+}
+catch(Exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+TestFunc1(TestClass)
+TestFunc2(TestClass)
+TestFunc3(TestClass)
+Exception: Class TestClass missing
+===DONE===
diff --git a/ext/spl/tests/spl_autoload_004.phpt b/ext/spl/tests/spl_autoload_004.phpt
new file mode 100644
index 0000000..1f26521
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_004.phpt
@@ -0,0 +1,43 @@
+--TEST--
+SPL: spl_autoload() with static methods
+--INI--
+include_path=.
+--FILE--
+<?php
+
+class MyAutoLoader {
+
+ static function autoLoad($className) {
+ echo __METHOD__ . "($className)\n";
+ }
+}
+
+spl_autoload_register(array('MyAutoLoader', 'autoLoad'));
+
+// and
+
+$myAutoLoader = new MyAutoLoader();
+
+spl_autoload_register(array($myAutoLoader, 'autoLoad'));
+
+var_dump(spl_autoload_functions());
+
+// check
+var_dump(class_exists("TestClass", true));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "autoLoad"
+ }
+}
+MyAutoLoader::autoLoad(TestClass)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/spl_autoload_005.phpt b/ext/spl/tests/spl_autoload_005.phpt
new file mode 100644
index 0000000..f4db521
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_005.phpt
@@ -0,0 +1,55 @@
+--TEST--
+SPL: spl_autoload() with methods
+--INI--
+include_path=.
+--FILE--
+<?php
+
+class MyAutoLoader {
+
+ function autoLoad($className)
+ {
+ echo __METHOD__ . "($className)\n";
+ }
+
+ function autoThrow($className)
+ {
+ echo __METHOD__ . "($className)\n";
+ throw new Exception("Unavailable");
+ }
+}
+
+try
+{
+ spl_autoload_register(array('MyAutoLoader', 'autoLoad'), true);
+}
+catch(Exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+
+// and
+
+$myAutoLoader = new MyAutoLoader();
+
+spl_autoload_register(array($myAutoLoader, 'autoLoad'));
+spl_autoload_register(array($myAutoLoader, 'autoThrow'));
+
+try
+{
+ var_dump(class_exists("TestClass", true));
+}
+catch(Exception $e)
+{
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Exception: Passed array specifies a non static method but no object (non-static method MyAutoLoader::autoLoad() should not be called statically)
+MyAutoLoader::autoLoad(TestClass)
+MyAutoLoader::autoThrow(TestClass)
+Exception: Unavailable
+===DONE===
diff --git a/ext/spl/tests/spl_autoload_006.phpt b/ext/spl/tests/spl_autoload_006.phpt
new file mode 100644
index 0000000..21a6084
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_006.phpt
@@ -0,0 +1,37 @@
+--TEST--
+SPL: spl_autoload() with static methods
+--INI--
+include_path=.
+--FILE--
+<?php
+
+class MyAutoLoader {
+
+ static function autoLoad($className) {
+ echo __METHOD__ . "($className)\n";
+ }
+}
+
+spl_autoload_register('MyAutoLoader::autoLoad');
+
+var_dump(spl_autoload_functions());
+
+// check
+var_dump(class_exists("TestClass", true));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "autoLoad"
+ }
+}
+MyAutoLoader::autoLoad(TestClass)
+bool(false)
+===DONE===
diff --git a/ext/spl/tests/spl_autoload_007.phpt b/ext/spl/tests/spl_autoload_007.phpt
new file mode 100644
index 0000000..1a81f19
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_007.phpt
@@ -0,0 +1,138 @@
+--TEST--
+SPL: spl_autoload() with inaccessible methods
+--INI--
+include_path=.
+--FILE--
+<?php
+
+class MyAutoLoader {
+
+ static protected function noAccess($className) {
+ echo __METHOD__ . "($className)\n";
+ }
+
+ static function autoLoad($className) {
+ echo __METHOD__ . "($className)\n";
+ }
+
+ function dynaLoad($className) {
+ echo __METHOD__ . "($className)\n";
+ }
+}
+
+$obj = new MyAutoLoader;
+
+$funcs = array(
+ 'MyAutoLoader::notExist',
+ 'MyAutoLoader::noAccess',
+ 'MyAutoLoader::autoLoad',
+ 'MyAutoLoader::dynaLoad',
+ array('MyAutoLoader', 'notExist'),
+ array('MyAutoLoader', 'noAccess'),
+ array('MyAutoLoader', 'autoLoad'),
+ array('MyAutoLoader', 'dynaLoad'),
+ array($obj, 'notExist'),
+ array($obj, 'noAccess'),
+ array($obj, 'autoLoad'),
+ array($obj, 'dynaLoad'),
+);
+
+foreach($funcs as $idx => $func)
+{
+ if ($idx) echo "\n";
+ try
+ {
+ var_dump($func);
+ spl_autoload_register($func);
+ echo "ok\n";
+ }
+ catch (Exception $e)
+ {
+ echo $e->getMessage() . "\n";
+ }
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+string(22) "MyAutoLoader::notExist"
+Function 'MyAutoLoader::notExist' not found (class 'MyAutoLoader' does not have a method 'notExist')
+
+string(22) "MyAutoLoader::noAccess"
+Function 'MyAutoLoader::noAccess' not callable (cannot access protected method MyAutoLoader::noAccess())
+
+string(22) "MyAutoLoader::autoLoad"
+ok
+
+string(22) "MyAutoLoader::dynaLoad"
+Function 'MyAutoLoader::dynaLoad' not callable (non-static method MyAutoLoader::dynaLoad() should not be called statically)
+
+array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "notExist"
+}
+Passed array does not specify an existing static method (class 'MyAutoLoader' does not have a method 'notExist')
+
+array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "noAccess"
+}
+Passed array does not specify a callable static method (cannot access protected method MyAutoLoader::noAccess())
+
+array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "autoLoad"
+}
+ok
+
+array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "dynaLoad"
+}
+Passed array specifies a non static method but no object (non-static method MyAutoLoader::dynaLoad() should not be called statically)
+
+array(2) {
+ [0]=>
+ object(MyAutoLoader)#%d (0) {
+ }
+ [1]=>
+ string(8) "notExist"
+}
+Passed array does not specify an existing method (class 'MyAutoLoader' does not have a method 'notExist')
+
+array(2) {
+ [0]=>
+ object(MyAutoLoader)#%d (0) {
+ }
+ [1]=>
+ string(8) "noAccess"
+}
+Passed array does not specify a callable method (cannot access protected method MyAutoLoader::noAccess())
+
+array(2) {
+ [0]=>
+ object(MyAutoLoader)#%d (0) {
+ }
+ [1]=>
+ string(8) "autoLoad"
+}
+ok
+
+array(2) {
+ [0]=>
+ object(MyAutoLoader)#%d (0) {
+ }
+ [1]=>
+ string(8) "dynaLoad"
+}
+ok
+===DONE===
diff --git a/ext/spl/tests/spl_autoload_008.phpt b/ext/spl/tests/spl_autoload_008.phpt
new file mode 100644
index 0000000..4b10351
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_008.phpt
@@ -0,0 +1,129 @@
+--TEST--
+SPL: spl_autoload() with exceptions
+--INI--
+include_path=.
+--FILE--
+<?php
+
+function MyAutoLoad($className)
+{
+ echo __METHOD__ . "($className)\n";
+ throw new Exception('Bla');
+}
+
+class MyAutoLoader
+{
+ static function autoLoad($className)
+ {
+ echo __METHOD__ . "($className)\n";
+ throw new Exception('Bla');
+ }
+
+ function dynaLoad($className)
+ {
+ echo __METHOD__ . "($className)\n";
+ throw new Exception('Bla');
+ }
+}
+
+$obj = new MyAutoLoader;
+
+$funcs = array(
+ 'MyAutoLoad',
+ 'MyAutoLoader::autoLoad',
+ 'MyAutoLoader::dynaLoad',
+ array('MyAutoLoader', 'autoLoad'),
+ array('MyAutoLoader', 'dynaLoad'),
+ array($obj, 'autoLoad'),
+ array($obj, 'dynaLoad'),
+);
+
+foreach($funcs as $idx => $func)
+{
+ echo "====$idx====\n";
+
+ try
+ {
+ var_dump($func);
+ spl_autoload_register($func);
+ if (count(spl_autoload_functions()))
+ {
+ echo "registered\n";
+
+ var_dump(class_exists("NoExistingTestClass", true));
+ }
+ }
+ catch (Exception $e)
+ {
+ echo get_class($e) . ": " . $e->getMessage() . "\n";
+ }
+
+ spl_autoload_unregister($func);
+ var_dump(count(spl_autoload_functions()));
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+====0====
+string(10) "MyAutoLoad"
+registered
+MyAutoLoad(NoExistingTestClass)
+Exception: Bla
+int(0)
+====1====
+string(22) "MyAutoLoader::autoLoad"
+registered
+MyAutoLoader::autoLoad(NoExistingTestClass)
+Exception: Bla
+int(0)
+====2====
+string(22) "MyAutoLoader::dynaLoad"
+LogicException: Function 'MyAutoLoader::dynaLoad' not callable (non-static method MyAutoLoader::dynaLoad() should not be called statically)
+int(0)
+====3====
+array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "autoLoad"
+}
+registered
+MyAutoLoader::autoLoad(NoExistingTestClass)
+Exception: Bla
+int(0)
+====4====
+array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "dynaLoad"
+}
+LogicException: Passed array specifies a non static method but no object (non-static method MyAutoLoader::dynaLoad() should not be called statically)
+int(0)
+====5====
+array(2) {
+ [0]=>
+ object(MyAutoLoader)#%d (0) {
+ }
+ [1]=>
+ string(8) "autoLoad"
+}
+registered
+MyAutoLoader::autoLoad(NoExistingTestClass)
+Exception: Bla
+int(0)
+====6====
+array(2) {
+ [0]=>
+ object(MyAutoLoader)#%d (0) {
+ }
+ [1]=>
+ string(8) "dynaLoad"
+}
+registered
+MyAutoLoader::dynaLoad(NoExistingTestClass)
+Exception: Bla
+int(0)
+===DONE===
diff --git a/ext/spl/tests/spl_autoload_009.phpt b/ext/spl/tests/spl_autoload_009.phpt
new file mode 100644
index 0000000..d5e5413
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_009.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SPL: spl_autoload() and friends
+--INI--
+include_path=.
+--FILE--
+<?php
+
+function my_autoload($name)
+{
+ require $name . '.class.inc';
+ var_dump(class_exists($name));
+}
+
+spl_autoload_register("spl_autoload");
+spl_autoload_register("my_autoload");
+
+$obj = new testclass;
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+%stestclass.inc
+%stestclass.class.inc
+bool(true)
+===DONE===
diff --git a/ext/spl/tests/spl_autoload_010.phpt b/ext/spl/tests/spl_autoload_010.phpt
new file mode 100644
index 0000000..cd70bdc
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_010.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: spl_autoload() and prepend
+--INI--
+include_path=.
+--FILE--
+<?php
+function autoloadA($name) {
+ echo "A -> $name\n";
+}
+function autoloadB($name) {
+ echo "B -> $name\n";
+}
+function autoloadC($name) {
+ echo "C -> $name\n";
+ class C{}
+}
+
+spl_autoload_register('autoloadA');
+spl_autoload_register('autoloadB', true, true);
+spl_autoload_register('autoloadC');
+
+new C;
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+B -> C
+A -> C
+C -> C
+===DONE===
diff --git a/ext/spl/tests/spl_autoload_011.phpt b/ext/spl/tests/spl_autoload_011.phpt
new file mode 100644
index 0000000..5a99255
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_011.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: spl_autoload() and object freed
+--INI--
+include_path=.
+--FILE--
+<?php
+class A {
+ public $var = 1;
+ public function autoload() {
+ echo "var:".$this->var."\n";
+ }
+ public function __destruct() {
+ echo "__destruct__\n";
+ }
+}
+
+$a = new A;
+$a->var = 2;
+
+spl_autoload_register(array($a, 'autoload'));
+unset($a);
+
+var_dump(class_exists("C", true));
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+var:2
+bool(false)
+===DONE===
+__destruct__
diff --git a/ext/spl/tests/spl_autoload_012.phpt b/ext/spl/tests/spl_autoload_012.phpt
new file mode 100644
index 0000000..e07f0e4
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_012.phpt
@@ -0,0 +1,65 @@
+--TEST--
+SPL: spl_autoload() capturing multiple Exceptions in __autoload
+--FILE--
+<?php
+
+function autoload_first($name)
+{
+ echo __METHOD__ . "\n";
+ throw new Exception('first');
+}
+
+function autoload_second($name)
+{
+ echo __METHOD__ . "\n";
+ throw new Exception('second');
+}
+
+spl_autoload_register('autoload_first');
+spl_autoload_register('autoload_second');
+
+try {
+ class_exists('ThisClassDoesNotExist');
+} catch(Exception $e) {
+ do {
+ echo $e->getMessage()."\n";
+ } while($e = $e->getPrevious());
+}
+
+try {
+ new ThisClassDoesNotExist;
+} catch(Exception $e) {
+ do {
+ echo $e->getMessage()."\n";
+ } while($e = $e->getPrevious());
+}
+
+class_exists('ThisClassDoesNotExist');
+?>
+===DONE===
+--EXPECTF--
+autoload_first
+autoload_second
+second
+first
+autoload_first
+autoload_second
+second
+first
+autoload_first
+autoload_second
+
+Fatal error: Uncaught exception 'Exception' with message 'first' in %sspl_autoload_012.php:%d
+Stack trace:
+#0 [internal function]: autoload_first('ThisClassDoesNo...')
+#1 [internal function]: spl_autoload_call('ThisClassDoesNo...')
+#2 %sspl_autoload_012.php(%d): class_exists('ThisClassDoesNo...')
+#3 {main}
+
+Next exception 'Exception' with message 'second' in %sspl_autoload_012.php:%d
+Stack trace:
+#0 [internal function]: autoload_second('ThisClassDoesNo...')
+#1 [internal function]: spl_autoload_call('ThisClassDoesNo...')
+#2 %sspl_autoload_012.php(%d): class_exists('ThisClassDoesNo...')
+#3 {main}
+ thrown in %sspl_autoload_012.php on line %d
diff --git a/ext/spl/tests/spl_autoload_013.phpt b/ext/spl/tests/spl_autoload_013.phpt
new file mode 100644
index 0000000..44d4d85
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_013.phpt
@@ -0,0 +1,51 @@
+--TEST--
+SPL: spl_autoload_functions() with closures and invokables
+--FILE--
+<?php
+$closure = function($class) {
+ echo "a called\n";
+};
+
+class Autoloader {
+ private $dir;
+ public function __construct($dir) {
+ $this->dir = $dir;
+ }
+ public function __invoke($class) {
+ var_dump("{$this->dir}/$class.php");
+ }
+}
+
+$al1 = new Autoloader('d1');
+$al2 = new Autoloader('d2');
+
+spl_autoload_register($closure);
+spl_autoload_register($al1);
+spl_autoload_register($al2);
+
+var_dump(spl_autoload_functions());
+
+?>
+===DONE===
+--EXPECTF--
+array(3) {
+ [0]=>
+ object(Closure)#%d (1) {
+ ["parameter"]=>
+ array(1) {
+ ["$class"]=>
+ string(10) "<required>"
+ }
+ }
+ [1]=>
+ object(Autoloader)#%d (1) {
+ ["dir":"Autoloader":private]=>
+ string(2) "d1"
+ }
+ [2]=>
+ object(Autoloader)#%d (1) {
+ ["dir":"Autoloader":private]=>
+ string(2) "d2"
+ }
+}
+===DONE=== \ No newline at end of file
diff --git a/ext/spl/tests/spl_autoload_014.phpt b/ext/spl/tests/spl_autoload_014.phpt
new file mode 100644
index 0000000..a68fcb7
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_014.phpt
@@ -0,0 +1,47 @@
+--TEST--
+SPL: spl_autoload_unregister() with closures and invokables
+--FILE--
+<?php
+$closure = function($class) {
+ echo "closure called with class $class\n";
+};
+
+class Autoloader {
+ private $dir;
+ public function __construct($dir) {
+ $this->dir = $dir;
+ }
+ public function __invoke($class) {
+ echo ("Autoloader('{$this->dir}') called with $class\n");
+ }
+}
+
+class WorkingAutoloader {
+ public function __invoke($class) {
+ echo ("WorkingAutoloader() called with $class\n");
+ eval("class $class { }");
+ }
+}
+
+$al1 = new Autoloader('d1');
+$al2 = new WorkingAutoloader('d2');
+
+spl_autoload_register($closure);
+spl_autoload_register($al1);
+spl_autoload_register($al2);
+
+$x = new TestX;
+
+spl_autoload_unregister($closure);
+spl_autoload_unregister($al1);
+
+$y = new TestY;
+
+?>
+===DONE===
+--EXPECT--
+closure called with class TestX
+Autoloader('d1') called with TestX
+WorkingAutoloader() called with TestX
+WorkingAutoloader() called with TestY
+===DONE=== \ No newline at end of file
diff --git a/ext/spl/tests/spl_autoload_bug48541.phpt b/ext/spl/tests/spl_autoload_bug48541.phpt
new file mode 100644
index 0000000..9937a7f
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_bug48541.phpt
@@ -0,0 +1,39 @@
+--TEST--
+SPL: spl_autoload_register() Bug #48541: registering multiple closures fails with memleaks
+--FILE--
+<?php
+
+class X {
+ public function getClosure() {
+ return function($class) {
+ echo "a2 called\n";
+ };
+ }
+}
+
+$a = function ($class) {
+ echo "a called\n";
+};
+$x = new X;
+$a2 = $x->getClosure();
+$b = function ($class) {
+ eval('class ' . $class . '{function __construct(){echo "foo\n";}}');
+ echo "b called\n";
+};
+spl_autoload_register($a);
+spl_autoload_register($a2);
+spl_autoload_register($b);
+
+$c = $a;
+$c2 = $a2;
+spl_autoload_register($c);
+spl_autoload_register($c2);
+$c = new foo;
+?>
+===DONE===
+--EXPECT--
+a called
+a2 called
+b called
+foo
+===DONE=== \ No newline at end of file
diff --git a/ext/spl/tests/spl_autoload_call_basic.phpt b/ext/spl/tests/spl_autoload_call_basic.phpt
new file mode 100644
index 0000000..2bd65c2
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_call_basic.phpt
@@ -0,0 +1,18 @@
+--TEST--
+spl_autoload_call() function - basic test for spl_autoload_call()
+--CREDITS--
+Jean-Marc Fontaine <jean-marc.fontaine@alterway.fr>
+# Alter Way Contribution Day 2011
+--FILE--
+<?php
+function customAutolader($class) {
+ require_once __DIR__ . '/testclass.class.inc';
+}
+spl_autoload_register('customAutolader');
+
+spl_autoload_call('TestClass');
+var_dump(class_exists('TestClass', false));
+?>
+--EXPECTF--
+%stestclass.class.inc
+bool(true)
diff --git a/ext/spl/tests/spl_caching_iterator_constructor_flags.phpt b/ext/spl/tests/spl_caching_iterator_constructor_flags.phpt
new file mode 100644
index 0000000..499cd67
--- /dev/null
+++ b/ext/spl/tests/spl_caching_iterator_constructor_flags.phpt
@@ -0,0 +1,25 @@
+--TEST--
+SPL: CachingInterator constructor flag checks
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+ //line 681 ...
+ $array = array(array(7,8,9),1,2,3,array(4,5,6));
+$arrayIterator = new ArrayIterator($array);
+try {
+$test = new CachingIterator($arrayIterator, 0);
+$test = new CachingIterator($arrayIterator, 1);
+$test = new CachingIterator($arrayIterator, 2);
+$test = new CachingIterator($arrayIterator, 3); // this throws an exception
+} catch (InvalidArgumentException $e){
+ print $e->getMessage() . "\n";
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_CURRENT
+===DONE===
diff --git a/ext/spl/tests/spl_cachingiterator___toString_basic.phpt b/ext/spl/tests/spl_cachingiterator___toString_basic.phpt
new file mode 100644
index 0000000..0395b37
--- /dev/null
+++ b/ext/spl/tests/spl_cachingiterator___toString_basic.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: SplCachingIterator, Test method to convert current element to string
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+$ai = new ArrayIterator(array(new stdClass(), new stdClass()));
+$ci = new CachingIterator($ai);
+var_dump(
+$ci->__toString() // if conversion to string is done by echo, for example, an exeption is thrown. Invoking __toString explicitly covers different code.
+);
+?>
+--EXPECTF--
+NULL
diff --git a/ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt b/ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt
new file mode 100644
index 0000000..126586b
--- /dev/null
+++ b/ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: SplCachingIterator, Test method to set flags for caching iterator
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+$ai = new ArrayIterator(array('foo', 'bar'));
+
+$ci = new CachingIterator($ai);
+$ci->setFlags(); //expects arg
+
+?>
+--EXPECTF--
+Warning: CachingIterator::setFlags() expects exactly 1 parameter, %s
diff --git a/ext/spl/tests/spl_classes.phpt b/ext/spl/tests/spl_classes.phpt
new file mode 100644
index 0000000..172c4ab
--- /dev/null
+++ b/ext/spl/tests/spl_classes.phpt
@@ -0,0 +1,13 @@
+--TEST--
+SPL: spl_classes() function
+--CREDITS--
+Sebastian Schürmann
+sebs@php.net
+Testfest 2009 Munich
+--FILE--
+<?php
+var_dump(is_array(spl_classes()));
+?>
+--EXPECT--
+bool(true)
+
diff --git a/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt b/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt
new file mode 100644
index 0000000..cee557e
--- /dev/null
+++ b/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: Spl File Info test getLinkTarget
+--CREDITS--
+Nataniel McHugh nat@fishtrap.co.uk
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+?>
+--FILE--
+<?php
+$link = __DIR__ . '/test_link';
+symlink(__FILE__, $link );
+$fileInfo = new SplFileInfo($link);
+
+if ($fileInfo->isLink()) {
+ echo $fileInfo->getLinkTarget() == __FILE__ ? 'same' : 'different',PHP_EOL;
+}
+var_dump(unlink($link));
+?>
+--EXPECT--
+same
+bool(true)
diff --git a/ext/spl/tests/spl_heap_count_basic.phpt b/ext/spl/tests/spl_heap_count_basic.phpt
new file mode 100644
index 0000000..6e6baf6
--- /dev/null
+++ b/ext/spl/tests/spl_heap_count_basic.phpt
@@ -0,0 +1,35 @@
+--TEST--
+SPL: SplHeap, Test spl_heap_object_count_elements (spl_heap.c:490) for returning count() failure for Heaps
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class MyHeap extends SplHeap
+{
+ public function compare($a,$b)
+ {
+ return ($a < $b);
+ }
+
+ public function count() // override count to force failure
+ {
+ throw new Exception('Cause count to fail');
+ return parent::count();
+ }
+}
+
+
+$heap = new MyHeap();
+$heap->insert(1);
+count($heap);// refers to MyHeap->count() method
+
+?>
+--EXPECTF--
+Fatal error: Uncaught exception 'Exception' with message 'Cause count to fail' in %s
+Stack trace:
+#0 [internal function]: MyHeap->count()
+#1 %s count(Object(MyHeap))
+#2 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/spl_heap_count_error.phpt b/ext/spl/tests/spl_heap_count_error.phpt
new file mode 100644
index 0000000..6bed4cf
--- /dev/null
+++ b/ext/spl/tests/spl_heap_count_error.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: Priority queue count, illegal number of args
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+$h = new SplPriorityQueue();
+$h->count(1);
+?>
+--EXPECTF--
+Warning: SplPriorityQueue::count() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/spl_heap_extract_parameter_error.phpt b/ext/spl/tests/spl_heap_extract_parameter_error.phpt
new file mode 100644
index 0000000..aecd03d
--- /dev/null
+++ b/ext/spl/tests/spl_heap_extract_parameter_error.phpt
@@ -0,0 +1,27 @@
+--TEST--
+SPL: Heap and extract with parameter
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+
+class TestHeap extends SplHeap {
+
+ function compare() {
+ print "This shouldn't be printed";
+ }
+}
+
+$testHeap = new TestHeap();
+
+
+
+var_dump($testHeap->extract('test'));
+
+?>
+===DONE===
+--EXPECTF--
+Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line 14
+NULL
+===DONE===
diff --git a/ext/spl/tests/spl_heap_insert_basic.phpt b/ext/spl/tests/spl_heap_insert_basic.phpt
new file mode 100644
index 0000000..76a34b2
--- /dev/null
+++ b/ext/spl/tests/spl_heap_insert_basic.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SPL: SplHeap, Test method to insert into heap
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+class MyHeap extends SplHeap
+{
+ public function compare($a, $b)
+ {
+ return $a < $b;
+ }
+}
+
+$heap = new MyHeap();
+$heap->insert(1,2);
+?>
+--EXPECTF--
+Warning: SplHeap::insert() expects exactly 1 parameter, %s
diff --git a/ext/spl/tests/spl_heap_is_empty_basic.phpt b/ext/spl/tests/spl_heap_is_empty_basic.phpt
new file mode 100644
index 0000000..47d7ccc
--- /dev/null
+++ b/ext/spl/tests/spl_heap_is_empty_basic.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: SplHeap, test trivial method to find if a heap is empty
+--CREDITS--
+Nathaniel McHugh nat@fishtrap.co.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class MyHeap extends SplHeap{
+
+public function compare($a, $b){
+return $a < $b;
+}
+
+}
+
+
+$heap = new MyHeap();
+var_dump($heap->isEmpty());
+$heap->insert(1);
+var_dump($heap->isEmpty());
+$heap->extract();
+var_dump($heap->isEmpty());
+$heap->isEmpty('var');
+?>
+--EXPECTF--
+bool(true)
+bool(false)
+bool(true)
+
+Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/spl_heap_isempty.phpt b/ext/spl/tests/spl_heap_isempty.phpt
new file mode 100644
index 0000000..2729c7f
--- /dev/null
+++ b/ext/spl/tests/spl_heap_isempty.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: Test of isEmpty for SPL Max Heap
+--CREDITS--
+Rohan Abraham (rohanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+ $h = new SplMaxHeap();
+ echo "Checking a new heap is empty: ";
+ var_dump($h->isEmpty())."\n";
+ $h->insert(2);
+ echo "Checking after insert: ";
+ var_dump($h->isEmpty())."\n";
+ $h->extract();
+ echo "Checking after extract: ";
+ var_dump($h->isEmpty())."\n";
+?>
+--EXPECT--
+Checking a new heap is empty: bool(true)
+Checking after insert: bool(false)
+Checking after extract: bool(true) \ No newline at end of file
diff --git a/ext/spl/tests/spl_heap_iteration_error.phpt b/ext/spl/tests/spl_heap_iteration_error.phpt
new file mode 100644
index 0000000..62e462f
--- /dev/null
+++ b/ext/spl/tests/spl_heap_iteration_error.phpt
@@ -0,0 +1,53 @@
+--TEST--
+SPL: Attempt to corrupt the heap while iterating
+--CREDITS--
+Lukasz Andrzejak meltir@meltir.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+class ext_heap extends SplMaxHeap {
+ public $fail = false;
+ public function compare($val1,$val2) {
+ if ($this->fail)
+ throw new Exception('Corrupting heap',99);
+ return 0;
+ }
+}
+
+$h = new ext_heap();
+$h->insert(array('foobar'));
+$h->insert(array('foobar1'));
+$h->insert(array('foobar2'));
+
+try {
+ $h->fail=true;
+ foreach ($h as $value) {};
+ echo "I should have raised an exception here";
+} catch (Exception $e) {
+ if ($e->getCode()!=99) echo "Unexpected exception";
+}
+
+var_dump($h);
+?>
+--EXPECTF--
+object(ext_heap)#%d (4) {
+ [%u|b%"fail"]=>
+ bool(true)
+ [%u|b%"flags":%u|b%"SplHeap":private]=>
+ int(0)
+ [%u|b%"isCorrupted":%u|b%"SplHeap":private]=>
+ bool(true)
+ [%u|b%"heap":%u|b%"SplHeap":private]=>
+ array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ %unicode|string%(7) "foobar2"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ %unicode|string%(7) "foobar1"
+ }
+ }
+}
diff --git a/ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt b/ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt
new file mode 100644
index 0000000..8726f4b
--- /dev/null
+++ b/ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt
@@ -0,0 +1,15 @@
+--TEST--
+SPL: SplHeap check no arguments to be accepted on recoverFromCorruption
+--CREDITS--
+Rohan Abraham (rohanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+ $h = new SplMaxHeap();
+ //Line below should throw a warning as no args are expected
+ $h->recoverFromCorruption("no args");
+?>
+--EXPECTF--
+
+Warning: SplHeap::recoverFromCorruption() expects exactly 0 parameters, 1 given in %s on line %d
+
diff --git a/ext/spl/tests/spl_iterator_apply_error.phpt b/ext/spl/tests/spl_iterator_apply_error.phpt
new file mode 100644
index 0000000..8e7cba4
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_apply_error.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SPL: Error: iterator_apply when an iterator method (eg rewind) throws exception
+--FILE--
+<?php
+
+class MyArrayIterator extends ArrayIterator {
+ public function rewind() {
+ throw new Exception('Make the iterator break');
+ }
+}
+
+function test() {}
+
+$it = new MyArrayIterator(array(1, 21, 22));
+
+try {
+ $res = iterator_apply($it, 'test');
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+
+<?php exit(0); ?>
+--EXPECT--
+Make the iterator break
diff --git a/ext/spl/tests/spl_iterator_apply_error_001.phpt b/ext/spl/tests/spl_iterator_apply_error_001.phpt
new file mode 100644
index 0000000..54663c0
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_apply_error_001.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SPL: Error: iterator_apply when the callback throws an exception
+--FILE--
+<?php
+
+function test() {
+ throw new Exception('Broken callback');
+}
+
+$it = new RecursiveArrayIterator(array(1, 21, 22));
+
+try {
+ iterator_apply($it, 'test');
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+?>
+--EXPECT--
+Broken callback
diff --git a/ext/spl/tests/spl_iterator_caching_count_basic.phpt b/ext/spl/tests/spl_iterator_caching_count_basic.phpt
new file mode 100644
index 0000000..b11eb7b
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_caching_count_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: Caching iterator count() cache contents
+--CREDITS--
+Lukasz Andrzejak meltir@meltir.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$i = new ArrayIterator(array(1,1,1,1,1));
+$i = new CachingIterator($i,CachingIterator::FULL_CACHE);
+foreach ($i as $value) {
+ echo $i->count()."\n";
+}
+?>
+===DONE===
+--EXPECT--
+1
+2
+3
+4
+5
+===DONE=== \ No newline at end of file
diff --git a/ext/spl/tests/spl_iterator_caching_count_error.phpt b/ext/spl/tests/spl_iterator_caching_count_error.phpt
new file mode 100644
index 0000000..70aa2be
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_caching_count_error.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: Caching iterator count() cache failure
+--CREDITS--
+Lukasz Andrzejak meltir@meltir.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$i = new ArrayIterator(array(1,1,1,1,1));
+$i = new CachingIterator($i);
+try {
+ $i->count();
+ echo "Should have caused an exception";
+} catch (BadMethodCallException $e) {
+ echo "Exception raised\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+Exception raised
+===DONE=== \ No newline at end of file
diff --git a/ext/spl/tests/spl_iterator_caching_getcache_error.phpt b/ext/spl/tests/spl_iterator_caching_getcache_error.phpt
new file mode 100644
index 0000000..2ea4bd8
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_caching_getcache_error.phpt
@@ -0,0 +1,21 @@
+--TEST--
+SPL: Caching iterator getCache failure
+--CREDITS--
+Lukasz Andrzejak meltir@meltir.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$i = new ArrayIterator(array(1,1,1,1,1));
+$i = new CachingIterator($i);
+try {
+ $i->getCache();
+ echo "Should have caused an exception";
+} catch (BadMethodCallException $e) {
+ echo "Exception raised\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+Exception raised
+===DONE=== \ No newline at end of file
diff --git a/ext/spl/tests/spl_iterator_getcallchildren.phpt b/ext/spl/tests/spl_iterator_getcallchildren.phpt
new file mode 100644
index 0000000..77b03b6
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_getcallchildren.phpt
@@ -0,0 +1,39 @@
+--TEST--
+SPL: RecursiveIteratorIterator, getCallChildren
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+ //line 681 ...
+ $array = array(array(7,8,9),1,2,3,array(4,5,6));
+$recursiveArrayIterator = new RecursiveArrayIterator($array);
+$test = new RecursiveIteratorIterator($recursiveArrayIterator);
+
+var_dump($test->current());
+$test->next();
+var_dump($test->current());
+try {
+ $output = $test->callGetChildren();
+} catch (InvalidArgumentException $ilae){
+ $output = null;
+ print "invalid argument exception\n";
+}
+var_dump($output);
+
+
+?>
+===DONE===
+--EXPECTF--
+ array(3) {
+ [0]=>
+ int(7)
+ [1]=>
+ int(8)
+ [2]=>
+ int(9)
+}
+int(7)
+invalid argument exception
+NULL
+===DONE===
diff --git a/ext/spl/tests/spl_iterator_iterator_constructor.phpt b/ext/spl/tests/spl_iterator_iterator_constructor.phpt
new file mode 100644
index 0000000..d4fdb14
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_iterator_constructor.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SPL: IteratorInterator constructor checks
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+
+ //I think this is testing line 1297 of spl_iterators.c
+
+ $array = array(array(7,8,9),1,2,3,array(4,5,6));
+$arrayIterator = new ArrayIterator($array);
+try {
+$test = new IteratorIterator($arrayIterator);
+
+$test = new IteratorIterator($arrayIterator, 1);
+$test = new IteratorIterator($arrayIterator, 1, 1);
+$test = new IteratorIterator($arrayIterator, 1, 1, 1);
+$test = new IteratorIterator($arrayIterator, 1, 1, 1, 1);
+
+} catch (InvalidArgumentException $e){
+ print $e->getMessage() . "\n";
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+IteratorIterator::__construct() expects at most 2 parameters, 3 given
+===DONE===
diff --git a/ext/spl/tests/spl_iterator_recursive_getiterator_error.phpt b/ext/spl/tests/spl_iterator_recursive_getiterator_error.phpt
new file mode 100644
index 0000000..0d45c31
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_recursive_getiterator_error.phpt
@@ -0,0 +1,16 @@
+--TEST--
+SPL: IteratorIterator foreach by reference failure
+--CREDITS--
+Lukasz Andrzejak meltir@meltir.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+$i = new ArrayIterator(array(1,1,1,1,1));
+$iii = new IteratorIterator($i);
+p($iii);
+function p ($i) {
+ foreach ($i as &$value) {}
+}
+?>
+--EXPECTF--
+Fatal error: An iterator cannot be used with foreach by reference in %s \ No newline at end of file
diff --git a/ext/spl/tests/spl_iterator_to_array_basic.phpt b/ext/spl/tests/spl_iterator_to_array_basic.phpt
new file mode 100644
index 0000000..68cb879
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_to_array_basic.phpt
@@ -0,0 +1,13 @@
+--TEST--
+SPL: iterator_to_array, Test function to convert iterator to array
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+iterator_to_array();//requires iterator as arg
+
+?>
+--EXPECTF--
+Warning: iterator_to_array() expects at least 1 parameter, %s
diff --git a/ext/spl/tests/spl_iterator_to_array_error.phpt b/ext/spl/tests/spl_iterator_to_array_error.phpt
new file mode 100644
index 0000000..755ef7b
--- /dev/null
+++ b/ext/spl/tests/spl_iterator_to_array_error.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: Error: iterator_to_array when the current operation throws an exception
+--FILE--
+<?php
+
+class MyArrayIterator extends ArrayIterator {
+ public function current() {
+ throw new Exception('Make the iterator break');
+ }
+}
+
+$it = new MyArrayIterator(array(4, 6, 2));
+
+try {
+ // get keys
+ $ar = iterator_to_array($it);
+} catch (Exception $e) {
+ echo $e->getMessage() . PHP_EOL;
+}
+
+try {
+ // get values
+ $ar = iterator_to_array($it, false);
+} catch (Exception $e) {
+ echo $e->getMessage() . PHP_EOL;
+}
+
+?>
+
+<?php exit(0); ?>
+--EXPECT--
+Make the iterator break
+Make the iterator break
diff --git a/ext/spl/tests/spl_limit_iterator_check_limits.phpt b/ext/spl/tests/spl_limit_iterator_check_limits.phpt
new file mode 100644
index 0000000..ae1bc85
--- /dev/null
+++ b/ext/spl/tests/spl_limit_iterator_check_limits.phpt
@@ -0,0 +1,37 @@
+--TEST--
+SPL: LimitIterator check limits are valid
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+ $array = array(array(7,8,9),1,2,3,array(4,5,6));
+$arrayIterator = new ArrayIterator($array);
+
+try {
+ $limitIterator = new LimitIterator($arrayIterator, -1);
+} catch (OutOfRangeException $e){
+ print $e->getMessage(). "\n";
+}
+
+
+try {
+ $limitIterator = new LimitIterator($arrayIterator, 0, -2);
+} catch (OutOfRangeException $e){
+ print $e->getMessage() . "\n";
+}
+
+try {
+ $limitIterator = new LimitIterator($arrayIterator, 0, -1);
+} catch (OutOfRangeException $e){
+ print $e->getMessage() . "\n";
+}
+
+
+
+?>
+===DONE===
+--EXPECTF--
+Parameter offset must be >= 0
+Parameter count must either be -1 or a value greater than or equal 0
+===DONE===
diff --git a/ext/spl/tests/spl_maxheap_compare_basic.phpt b/ext/spl/tests/spl_maxheap_compare_basic.phpt
new file mode 100644
index 0000000..3705b3f
--- /dev/null
+++ b/ext/spl/tests/spl_maxheap_compare_basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SPL: SplMaxHeap, Test method to comare elements
+--CREDITS--
+Chris Scott chris.scott@nstein.com
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+class MyHeap extends SplMaxHeap
+{
+ public function testCompare()
+ {
+ return parent::compare(1);
+ }
+}
+
+$heap = new MyHeap();
+$heap->testCompare();
+
+?>
+--EXPECTF--
+Warning: SplMaxHeap::compare() expects exactly 2 parameters, %s
diff --git a/ext/spl/tests/spl_minheap_compare_error.phpt b/ext/spl/tests/spl_minheap_compare_error.phpt
new file mode 100644
index 0000000..7120a6c
--- /dev/null
+++ b/ext/spl/tests/spl_minheap_compare_error.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: SplMinHeap compare, illegal number of args
+--CREDITS--
+Mark Schaschke (mark@fractalturtle.com)
+TestFest London May 2009
+--FILE--
+<?php
+class SplMinHeap2 extends SplMinHeap {
+ public function testCompare1() {
+ return parent::compare();
+ }
+ public function testCompare2() {
+ return parent::compare(1);
+ }
+ public function testCompare3() {
+ return parent::compare(1, 2, 3);
+ }
+}
+
+$h = new SplMinHeap2();
+$h->testCompare1();
+$h->testCompare2();
+$h->testCompare3();
+?>
+--EXPECTF--
+Warning: SplMinHeap::compare() expects exactly 2 parameters, 0 given in %s
+
+Warning: SplMinHeap::compare() expects exactly 2 parameters, 1 given in %s
+
+Warning: SplMinHeap::compare() expects exactly 2 parameters, 3 given in %s
+
diff --git a/ext/spl/tests/spl_pq_top_basic.phpt b/ext/spl/tests/spl_pq_top_basic.phpt
new file mode 100644
index 0000000..dcc1cbe
--- /dev/null
+++ b/ext/spl/tests/spl_pq_top_basic.phpt
@@ -0,0 +1,42 @@
+--TEST--
+SPL: SplPriorityQueue: top and extract flags
+--CREDITS--
+Nathaniel McHugh nat@fishtrap.co.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+
+$priorityQueue = new SplPriorityQueue();
+
+$priorityQueue->insert("a", 1);
+$priorityQueue->insert("b", 2);
+$priorityQueue->insert("c", 0);
+
+echo "EXTR DEFAULT",PHP_EOL;
+echo "value: ",$priorityQueue->top(),PHP_EOL;
+
+$priorityQueue->setExtractFlags(SplPriorityQueue::EXTR_PRIORITY);
+echo "EXTR_PRIORITY",PHP_EOL;
+echo "priority: ",$priorityQueue->top(),PHP_EOL;
+
+$priorityQueue->setExtractFlags(SplPriorityQueue::EXTR_BOTH);
+echo "EXTR_BOTH",PHP_EOL;
+print_r($priorityQueue->top());
+
+echo "EXTR_DATA",PHP_EOL;
+$priorityQueue->setExtractFlags(SplPriorityQueue::EXTR_DATA);
+echo "value: ",$priorityQueue->top(),PHP_EOL;
+?>
+--EXPECT--
+EXTR DEFAULT
+value: b
+EXTR_PRIORITY
+priority: 2
+EXTR_BOTH
+Array
+(
+ [data] => b
+ [priority] => 2
+)
+EXTR_DATA
+value: b \ No newline at end of file
diff --git a/ext/spl/tests/spl_pq_top_error_args.phpt b/ext/spl/tests/spl_pq_top_error_args.phpt
new file mode 100644
index 0000000..a0e5969
--- /dev/null
+++ b/ext/spl/tests/spl_pq_top_error_args.phpt
@@ -0,0 +1,12 @@
+--TEST--
+SPL: SplPriorityQueue: top too many arguments exception
+--CREDITS--
+Nathaniel McHugh nat@fishtrap.co.uk
+#testfest London 2009-05-09
+--FILE--
+<?php
+$priorityQueue = new SplPriorityQueue();
+$priorityQueue->top('var');
+?>
+--EXPECTF--
+Warning: SplPriorityQueue::top() expects exactly 0 parameters, 1 given in %s \ No newline at end of file
diff --git a/ext/spl/tests/spl_pq_top_error_corrupt.phpt b/ext/spl/tests/spl_pq_top_error_corrupt.phpt
new file mode 100644
index 0000000..30b6fde
--- /dev/null
+++ b/ext/spl/tests/spl_pq_top_error_corrupt.phpt
@@ -0,0 +1,38 @@
+--TEST--
+SPL: SplPriorityQueue: top and extract flags
+--CREDITS--
+Nathaniel McHugh nat@fishtrap.co.uk
+#testfest 2009-05-09
+--FILE--
+<?php
+
+class myPriorityQueue extends SplPriorityQueue{
+
+ public function compare($a, $b){
+ if ($b == 2) {
+ throw new Exception('ignore me');
+ } else {
+ return parent::compare($a, $b);
+ }
+ }
+}
+
+$priorityQueue = new myPriorityQueue();
+$priorityQueue->insert("a", 1);
+
+try {
+ //corrupt heap
+ $priorityQueue->insert("b", 2);
+ // ignore exception tested elsewhere
+} catch (Exception $e) {
+}
+
+try {
+ $priorityQueue->top();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage().PHP_EOL;
+}
+
+?>
+--EXPECT--
+Exception: Heap is corrupted, heap properties are no longer ensured.
diff --git a/ext/spl/tests/spl_pq_top_error_empty.phpt b/ext/spl/tests/spl_pq_top_error_empty.phpt
new file mode 100644
index 0000000..9e2a31b
--- /dev/null
+++ b/ext/spl/tests/spl_pq_top_error_empty.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: SplPriorityQueue: top exception on empty heap
+--CREDITS--
+Nathaniel McHugh nat@fishtrap.co.uk
+#testfest 2009-05-09
+--FILE--
+<?php
+
+$priorityQueue = new SplPriorityQueue();
+
+try {
+ $priorityQueue->top();
+} catch (RuntimeException $e) {
+ echo "Exception: ".$e->getMessage().PHP_EOL;
+}
+
+?>
+--EXPECT--
+Exception: Can't peek at an empty heap
diff --git a/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt b/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt
new file mode 100644
index 0000000..659ffb4
--- /dev/null
+++ b/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SPL: priorityQueue paramter test on insert method
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+
+
+$testHeap = new SplPriorityQueue();
+
+
+var_dump($testHeap->insert());
+var_dump($testHeap->insert('test'));
+var_dump($testHeap->insert('test', 'test'));
+var_dump($testHeap->insert('test', 'test', 'test'));
+
+
+?>
+===DONE===
+--EXPECTF--
+Warning: SplPriorityQueue::insert() expects exactly 2 parameters, 0 given in %s on line 7
+NULL
+
+Warning: SplPriorityQueue::insert() expects exactly 2 parameters, 1 given in %s on line 8
+NULL
+bool(true)
+
+Warning: SplPriorityQueue::insert() expects exactly 2 parameters, 3 given in %s on line 10
+NULL
+===DONE===
diff --git a/ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt b/ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt
new file mode 100644
index 0000000..d52a320
--- /dev/null
+++ b/ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt
@@ -0,0 +1,28 @@
+--TEST--
+SPL: RecursiveIteratorIterator, setMaxDepth check parameter count
+--CREDITS--
+Sean Burlington www.practicalweb.co.uk
+TestFest London May 2009
+--FILE--
+<?php
+ //line 681 ...
+ $array = array(array(7,8,9),1,2,3,array(4,5,6));
+$recursiveArrayIterator = new RecursiveArrayIterator($array);
+$test = new RecursiveIteratorIterator($recursiveArrayIterator);
+
+//var_dump($test->current());
+$test->setMaxDepth();
+$test->setMaxDepth(1);
+$test->setMaxDepth(1,2);
+$test->setMaxDepth(1,2,3);
+
+//var_dump($test->current());
+
+
+?>
+===DONE===
+--EXPECTF--
+Warning: RecursiveIteratorIterator::setMaxDepth() expects at most 1 parameter, 2 given in %s on line 10
+
+Warning: RecursiveIteratorIterator::setMaxDepth() expects at most 1 parameter, 3 given in %s on line 11
+===DONE===
diff --git a/ext/spl/tests/spl_recursive_iterator_iterator_key_case.phpt b/ext/spl/tests/spl_recursive_iterator_iterator_key_case.phpt
new file mode 100644
index 0000000..1262ec0
--- /dev/null
+++ b/ext/spl/tests/spl_recursive_iterator_iterator_key_case.phpt
@@ -0,0 +1,33 @@
+--TEST--
+SPL: Test on RecursiveIteratorIterator key function checking switch statements
+--CREDITS--
+Rohan Abraham (rohanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+ $ar = array("one"=>1, "two"=>2, "three"=>array("four"=>4, "five"=>5, "six"=>array("seven"=>7)), "eight"=>8, -100 => 10, NULL => "null");
+ $it = new RecursiveArrayIterator($ar);
+ $it = new RecursiveIteratorIterator($it);
+ foreach($it as $k=>$v)
+ {
+ echo "$k=>$v\n";
+ var_dump($k);
+ }
+?>
+--EXPECTF--
+one=>1
+%unicode|string%(3) "one"
+two=>2
+%unicode|string%(3) "two"
+four=>4
+%unicode|string%(4) "four"
+five=>5
+%unicode|string%(4) "five"
+seven=>7
+%unicode|string%(5) "seven"
+eight=>8
+%unicode|string%(5) "eight"
+-100=>10
+int(-100)
+=>null
+%unicode|string%(0) ""
diff --git a/ext/spl/tests/splfixedarray_offsetExists_larger.phpt b/ext/spl/tests/splfixedarray_offsetExists_larger.phpt
new file mode 100644
index 0000000..9449d64
--- /dev/null
+++ b/ext/spl/tests/splfixedarray_offsetExists_larger.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Checks that offsetExists() does not accept a value larger than the array.
+--CREDITS--
+ PHPNW Test Fest 2009 - Rick Ogden
+--FILE--
+<?php
+$ar = new SplFixedArray(3);
+$ar[0] = 1;
+$ar[1] = 2;
+$ar[2] = 3;
+
+var_dump($ar->offsetExists(4));
+?>
+--EXPECT--
+bool(false)
diff --git a/ext/spl/tests/splpriorityqueue_extract.phpt b/ext/spl/tests/splpriorityqueue_extract.phpt
new file mode 100644
index 0000000..eee7bb2
--- /dev/null
+++ b/ext/spl/tests/splpriorityqueue_extract.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SPL: splpriorityqueue extract() Test arguments
+--CREDITS--
+Roshan Abraham (roshanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+
+$sp = new SplPriorityQueue();
+
+$sp->insert("1",1);
+
+$sp->extract(1); // Should throw a warning as extract expects NO arguments
+
+?>
+--EXPECTF--
+
+Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
+
diff --git a/ext/spl/tests/splpriorityqueue_setextractflags.phpt b/ext/spl/tests/splpriorityqueue_setextractflags.phpt
new file mode 100644
index 0000000..97d86f3
--- /dev/null
+++ b/ext/spl/tests/splpriorityqueue_setextractflags.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SPL: splpriorityqueue setExtractFlags() Test arguments
+--CREDITS--
+Roshan Abraham (roshanabrahams@gmail.com)
+TestFest London May 2009
+--FILE--
+<?php
+
+$sp = new SplPriorityQueue();
+
+$sp->setExtractFlags(1,1); // Should throw a warning as setExtractFlags expects only 1 argument
+
+?>
+--EXPECTF--
+
+Warning: SplPriorityQueue::setExtractFlags() expects exactly 1 parameter, 2 given in %s on line %d
+
diff --git a/ext/spl/tests/testclass b/ext/spl/tests/testclass
new file mode 100755
index 0000000..ceb24c8
--- /dev/null
+++ b/ext/spl/tests/testclass
@@ -0,0 +1,5 @@
+<?php
+
+echo __FILE__ . "\n";
+
+?> \ No newline at end of file
diff --git a/ext/spl/tests/testclass.class.inc b/ext/spl/tests/testclass.class.inc
new file mode 100644
index 0000000..f5fe741
--- /dev/null
+++ b/ext/spl/tests/testclass.class.inc
@@ -0,0 +1,9 @@
+<?php
+
+echo __FILE__ . "\n";
+
+class TestClass
+{
+}
+
+?> \ No newline at end of file
diff --git a/ext/spl/tests/testclass.inc b/ext/spl/tests/testclass.inc
new file mode 100644
index 0000000..ceb24c8
--- /dev/null
+++ b/ext/spl/tests/testclass.inc
@@ -0,0 +1,5 @@
+<?php
+
+echo __FILE__ . "\n";
+
+?> \ No newline at end of file
diff --git a/ext/spl/tests/testclass.php.inc b/ext/spl/tests/testclass.php.inc
new file mode 100644
index 0000000..ceb24c8
--- /dev/null
+++ b/ext/spl/tests/testclass.php.inc
@@ -0,0 +1,5 @@
+<?php
+
+echo __FILE__ . "\n";
+
+?> \ No newline at end of file