Skip to content

Commit a05b25b

Browse files
committed
Write more complex tests
1 parent a467aa5 commit a05b25b

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Test is_countable() function
3+
--FILE--
4+
<?php
5+
6+
var_dump(is_countable(new class extends ArrayIterator {}));
7+
var_dump(is_countable((array) new stdClass()));
8+
var_dump(is_countable(new class implements Countable {
9+
public function count()
10+
{
11+
return count(1, 'foo');
12+
}
13+
}));
14+
15+
16+
?>
17+
--EXPECTF--
18+
bool(true)
19+
bool(true)
20+
bool(true)

ext/standard/tests/general_functions/is_countable.phpt renamed to ext/standard/tests/general_functions/is_countable_with_variables.phpt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Test is_countable() function
44
<?php
55

66
var_dump(is_countable([1, 2, 3]));
7-
var_dump(is_countable(new ArrayIterator(['foo', 'bar', 'baz'])));
8-
var_dump(is_countable(new ArrayIterator()));
9-
var_dump(is_countable(new stdClass()));
7+
var_dump(is_countable((array) 1));
8+
var_dump(is_countable((object) ['foo', 'bar', 'baz']));
9+
1010

1111
$foo = ['', []];
1212

@@ -23,7 +23,6 @@ if (!is_countable($bar)) {
2323
--EXPECTF--
2424
bool(true)
2525
bool(true)
26-
bool(true)
2726
bool(false)
2827
int(2)
2928

0 commit comments

Comments
 (0)