@@ -30,6 +30,26 @@ public function testConstructor()
30
30
*/
31
31
public function testAccept ($ mode , $ expected )
32
32
{
33
+ if (!is_callable ($ mode )) {
34
+ switch ($ mode ) {
35
+ case SortableIterator::SORT_BY_ACCESSED_TIME :
36
+ file_get_contents (self ::toAbsolute ('.git ' ));
37
+ sleep (1 );
38
+ file_get_contents (self ::toAbsolute ('.bar ' ));
39
+ break ;
40
+ case SortableIterator::SORT_BY_CHANGED_TIME :
41
+ file_put_contents (self ::toAbsolute ('test.php ' ), 'foo ' );
42
+ sleep (1 );
43
+ file_put_contents (self ::toAbsolute ('test.py ' ), 'foo ' );
44
+ break ;
45
+ case SortableIterator::SORT_BY_MODIFIED_TIME :
46
+ file_put_contents (self ::toAbsolute ('test.php ' ), 'foo ' );
47
+ sleep (1 );
48
+ file_put_contents (self ::toAbsolute ('test.py ' ), 'foo ' );
49
+ break ;
50
+ }
51
+ }
52
+
33
53
$ inner = new Iterator (self ::$ files );
34
54
35
55
$ iterator = new SortableIterator ($ inner , $ mode );
@@ -82,9 +102,54 @@ public function getAcceptData()
82
102
'toto ' ,
83
103
);
84
104
105
+ $ sortByAccessedTime = array (
106
+ 'foo/bar.tmp ' ,
107
+ 'test.php ' ,
108
+ 'toto ' ,
109
+ 'foo bar ' ,
110
+ 'foo ' ,
111
+ 'test.py ' ,
112
+ '.foo ' ,
113
+ '.foo/.bar ' ,
114
+ '.foo/bar ' ,
115
+ '.git ' ,
116
+ '.bar '
117
+ );
118
+
119
+ $ sortByChangedTime = array (
120
+ 'foo ' ,
121
+ 'foo/bar.tmp ' ,
122
+ 'toto ' ,
123
+ '.git ' ,
124
+ '.bar ' ,
125
+ '.foo ' ,
126
+ 'foo bar ' ,
127
+ '.foo/.bar ' ,
128
+ '.foo/bar ' ,
129
+ 'test.php ' ,
130
+ 'test.py '
131
+ );
132
+
133
+ $ sortByModifiedTime = array (
134
+ 'foo/bar.tmp ' ,
135
+ 'foo ' ,
136
+ 'toto ' ,
137
+ '.git ' ,
138
+ '.bar ' ,
139
+ '.foo ' ,
140
+ 'foo bar ' ,
141
+ '.foo/.bar ' ,
142
+ '.foo/bar ' ,
143
+ 'test.php ' ,
144
+ 'test.py '
145
+ );
146
+
85
147
return array (
86
148
array (SortableIterator::SORT_BY_NAME , $ this ->toAbsolute ($ sortByName )),
87
149
array (SortableIterator::SORT_BY_TYPE , $ this ->toAbsolute ($ sortByType )),
150
+ array (SortableIterator::SORT_BY_ACCESSED_TIME , $ this ->toAbsolute ($ sortByAccessedTime )),
151
+ array (SortableIterator::SORT_BY_CHANGED_TIME , $ this ->toAbsolute ($ sortByChangedTime )),
152
+ array (SortableIterator::SORT_BY_MODIFIED_TIME , $ this ->toAbsolute ($ sortByModifiedTime )),
88
153
array (function (\SplFileInfo $ a , \SplFileInfo $ b ) { return strcmp ($ a ->getRealpath (), $ b ->getRealpath ()); }, $ this ->toAbsolute ($ customComparison )),
89
154
);
90
155
}
0 commit comments