Skip to content

Commit cae4eb1

Browse files
committed
Test node property types
1 parent 55d38eb commit cae4eb1

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace mglaman\PHPStanDrupal\Tests\Type;
6+
7+
use mglaman\PHPStanDrupal\Tests\AdditionalConfigFilesTrait;
8+
use PHPStan\Testing\TypeInferenceTestCase;
9+
10+
final class EntityPropertyTypeTest extends TypeInferenceTestCase
11+
{
12+
use AdditionalConfigFilesTrait;
13+
14+
public function dataFileAsserts(): iterable
15+
{
16+
yield from $this->gatherAssertTypes(__DIR__ . '/data/entity-properties.php');
17+
}
18+
19+
/**
20+
* @dataProvider dataFileAsserts
21+
* @param string $assertType
22+
* @param string $file
23+
* @param mixed ...$args
24+
*/
25+
public function testFileAsserts(
26+
string $assertType,
27+
string $file,
28+
...$args
29+
): void
30+
{
31+
$this->assertFileAsserts($assertType, $file, ...$args);
32+
}
33+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace DrupalEntity;
4+
5+
use Drupal\node\Entity\Node;
6+
use Drupal\phpstan_fixtures\Entity\ReflectionEntityTest;
7+
use function PHPStan\Testing\assertType;
8+
9+
$node = Node::create(['type' => 'page']);
10+
assertType('Drupal\Core\Field\FieldItemListInterface', $node->uid);
11+
12+
$entity = ReflectionEntityTest::create();
13+
assertType('Drupal\Core\Field\EntityReferenceFieldItemListInterface', $entity->user_id);

0 commit comments

Comments
 (0)