forked from phpstan/phpstan-phpunit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassert-same-count.php
More file actions
64 lines (50 loc) · 1.27 KB
/
assert-same-count.php
File metadata and controls
64 lines (50 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php declare(strict_types = 1);
namespace ExampleTestCase;
class AssertSameWithCountTestCase extends \PHPUnit\Framework\TestCase
{
public function testAssertSameWithCount()
{
$this->assertSame(5, count([1, 2, 3]));
}
public function testAssertSameWithCountMethodIsOK()
{
$foo = new \stdClass();
$this->assertSame(5, $foo->count()); // OK
}
public function testAssertSameIsDetectedWithDirectAssertAccess()
{
\PHPUnit\Framework\Assert::assertSame(5, count([1, 2, 3]));
}
public function testAssertSameWithCountMethodForCountableVariableIsNotOK()
{
$foo = new \stdClass();
$foo->bar = new Bar ();
$this->assertSame(5, $foo->bar->count());
}
public function testRecursiveCount($x)
{
$this->assertSame(5, count([1, 2, 3, $x], COUNT_RECURSIVE)); // OK
}
public function testNormalCount($x)
{
$this->assertSame(5, count([1, 2, 3, $x], COUNT_NORMAL));
}
public function testImplicitNormalCount($mode)
{
$this->assertSame(5, count([1, 2, 3], $mode));
}
public function testUnknownCountable($x, $mode)
{
$this->assertSame(5, count($x, $mode)); // OK
}
public function testUnknownCountMode($x, $mode)
{
$this->assertSame(5, count([1, 2, 3, $x], $mode)); // OK
}
}
class Bar implements \Countable {
public function count(): int
{
return 1;
}
}