-
-
Notifications
You must be signed in to change notification settings - Fork 117
/
IncludeWalkerTest.php
96 lines (83 loc) · 2.75 KB
/
IncludeWalkerTest.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace Phpactor\WorseReflection\Tests\Integration\Core\Inference\FrameWalker;
use Phpactor\WorseReflection\Tests\Integration\Core\Inference\FrameWalkerTestCase;
use Phpactor\WorseReflection\Core\Inference\Frame;
use Generator;
class IncludeWalkerTest extends FrameWalkerTestCase
{
public function setUp(): void
{
parent::setUp();
$this->workspace()->reset();
$this->workspace()->put('foo.php', '<?php $foo = "bar";');
$this->workspace()->put('return_value.php', '<?php return "bar";');
}
public function provideWalk(): Generator
{
// disabled this walker for now due to perforamnce and behavioral
// issues.
return;
yield 'Require relative' => [
<<<'EOT'
<?php
require('foo.php');
<>
EOT
,
function (Frame $frame): void {
$this->assertCount(1, $frame->locals());
$this->assertEquals('foo', $frame->locals()->first()->name());
}
];
yield 'Require absolute' => [
<<<EOT
<?php
require('{$this->workspace()->path('foo.php')}');
<>
EOT
,
function (Frame $frame): void {
$this->assertCount(1, $frame->locals());
$this->assertEquals('foo', $frame->locals()->first()->name());
}
];
yield 'Include' => [
<<<'EOT'
<?php
include('foo.php');
<>
EOT
,
function (Frame $frame): void {
$this->assertCount(1, $frame->locals());
$this->assertEquals('foo', $frame->locals()->first()->name());
}
];
yield 'Returns value' => [
<<<'EOT'
<?php
$foo = require('return_value.php');
<>
EOT
,
function (Frame $frame): void {
$this->assertCount(1, $frame->locals());
$this->assertEquals('foo', $frame->locals()->last()->name());
$this->assertEquals('"bar"', (string) $frame->locals()->last()->type());
}
];
yield 'Returns from constant' => [
<<<'EOT'
<?php
$foo = require(__DIR__ . '/return_value.php');
<>
EOT
,
function (Frame $frame): void {
$this->assertCount(1, $frame->locals());
$this->assertEquals('foo', $frame->locals()->last()->name());
$this->assertEquals('"bar"', (string) $frame->locals()->last()->type());
}
];
}
}