Skip to content

Commit 5005471

Browse files
committed
Bring over enven more PHPactor tests
1 parent 4e35de7 commit 5005471

51 files changed

Lines changed: 1138 additions & 104 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/todo/testing.md

Lines changed: 121 additions & 104 deletions
Large diffs are not rendered by default.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// test: arrow function parameter type resolves inside array_map call
2+
// feature: completion
3+
// Adapted from phpactor arrow_function/parameter2.test
4+
// ignore: arrow function parameter type not resolved for completion
5+
// expect: nodeMethod(
6+
---
7+
<?php
8+
9+
namespace Foo;
10+
11+
class TypeNode {
12+
public function nodeMethod(): void {}
13+
}
14+
15+
/** @var array<TypeNode> $parameters */
16+
array_map(
17+
fn (TypeNode $node) => $node-><>,
18+
$parameters
19+
);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// test: arrow function parameter type resolves for completion
2+
// feature: completion
3+
// Adapted from phpactor arrow_function/parameter.test
4+
// ignore: arrow function parameter type not resolved for completion
5+
// expect: fooMethod(
6+
---
7+
<?php
8+
9+
class Foo {
10+
public function fooMethod(): void {}
11+
}
12+
13+
$fn = fn (Foo $foo) => $foo-><>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// test: __invoke with Generator return type resolves item type in foreach
2+
// feature: completion
3+
// Adapted from phpactor call-expression/invoke2.test
4+
// ignore: needs __invoke() return type resolution and Generator generic foreach support
5+
// expect: format(
6+
---
7+
<?php
8+
9+
class Foobar
10+
{
11+
/**
12+
* @return \Generator<DateTime>
13+
*/
14+
public function __invoke(): \Generator
15+
{
16+
yield new DateTime();
17+
}
18+
}
19+
20+
class DateTime {
21+
public function format(string $f): string {}
22+
}
23+
24+
class Baz
25+
{
26+
private Foobar $foo;
27+
28+
public function __construct(Foobar $foo) {
29+
$this->foo = $foo;
30+
}
31+
32+
public function baz(): void {
33+
foreach (($this->foo)() as $bar) {
34+
$bar-><>
35+
}
36+
}
37+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// test: chained method call from static method with arguments resolves return type
2+
// feature: completion
3+
// Adapted from phpactor WorseClassMemberCompletorTest 'chained static method call with arguments'
4+
// expect: goodbye(
5+
---
6+
<?php
7+
8+
class BarBar {
9+
public function hello($one, $two): Foobar {}
10+
}
11+
12+
class Foobar {
13+
public function goodbye(): BarBar {}
14+
15+
public static function create(): BarBar {}
16+
}
17+
18+
Foobar::create()
19+
->hello('one', 'two')
20+
-><>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// test: completion on assignment still resolves the variable type
2+
// feature: completion
3+
// Adapted from phpactor WorseClassMemberCompletorTest 'Completion on assignment'
4+
// expect: method1(
5+
---
6+
<?php
7+
8+
class Foobar
9+
{
10+
public function method1() {}
11+
}
12+
13+
$foobar = new Foobar();
14+
$foobar = $foobar->meth<>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// test: constant visibility from inside class shows private and protected constants
2+
// feature: completion
3+
// Adapted from phpactor WorseClassMemberCompletorTest 'Constant visibility from inside'
4+
// expect: BARFOO
5+
// expect: BARFOX
6+
// expect: FOOBAR
7+
---
8+
<?php
9+
10+
class Foobar
11+
{
12+
const FOOBAR = 'foobar';
13+
private const BARFOO = 'barfoo';
14+
protected const BARFOX = 'barfox';
15+
16+
public function fog(): void
17+
{
18+
$foobar = self::<>
19+
}
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// test: constant visibility from outside class hides private and protected constants
2+
// feature: completion
3+
// Adapted from phpactor WorseClassMemberCompletorTest 'Constant visibility from outside'
4+
// expect: FOOBAR
5+
// expect_absent: BARFOO
6+
// expect_absent: BARFOX
7+
---
8+
<?php
9+
10+
class Foobar
11+
{
12+
const FOOBAR = 'foobar';
13+
private const BARFOO = 'barfoo';
14+
protected const BARFOX = 'barfox';
15+
}
16+
17+
$foobar = new Foobar();
18+
$foobar::<>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// test: partially completed method with text after cursor still completes
2+
// feature: completion
3+
// Adapted from phpactor WorseClassMemberCompletorTest 'Partially completed method with text after'
4+
// expect: bbb(
5+
---
6+
<?php
7+
8+
class Foobar
9+
{
10+
public function aaa()
11+
{
12+
$this->bb<>new Foobar();
13+
}
14+
15+
public function bbb() {}
16+
public function ccc() {}
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// test: static property access after chained arrow accessor resolves type
2+
// feature: completion
3+
// Adapted from phpactor WorseClassMemberCompletorTest 'Static property with previous arrow accessor'
4+
// ignore: mixed arrow then static accessor chaining ($obj->prop::$static) not resolved
5+
// expect: $foo
6+
---
7+
<?php
8+
9+
class Foobar
10+
{
11+
public static $foo;
12+
13+
/**
14+
* @var Foobar
15+
*/
16+
public $me;
17+
}
18+
19+
$foobar = new Foobar();
20+
$foobar->me::<>

0 commit comments

Comments
 (0)