-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvaderTest.php
57 lines (42 loc) · 1.24 KB
/
InvaderTest.php
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
<?php
use JesseGall\Invader\Invader;
use PHPUnit\Framework\TestCase;
class InvaderTest extends TestCase
{
public function test_can_access_private_property()
{
$target = new class {
private string $property = 'expected';
};
$invader = new Invader($target);
$this->assertEquals('expected', $invader->property);
}
public function test_can_set_private_property()
{
$target = new class {
private string $property = 'initial';
public function getProperty(): string
{
return $this->property;
}
};
$invader = new Invader($target);
$invader->property = 'expected';
$this->assertEquals('expected', $target->getProperty());
}
public function test_can_call_private_method()
{
$target = new class {
private function method(int $a, int $b): string
{
return $a + $b;
}
};
$invader = new Invader($target);
$this->assertEquals(5, $invader->method(2, 3));
}
public function test_helper_method_returns_invader()
{
$this->assertInstanceOf(Invader::class, invade(new stdClass()));
}
}