Skip to content

Commit 1fcd8ca

Browse files
committed
Rewrite tests to use TypeInferenceTestCase instead of LevelsTestCase
1 parent 5e52821 commit 1fcd8ca

File tree

43 files changed

+197
-913
lines changed

Some content is hidden

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

43 files changed

+197
-913
lines changed

tests/DoctrineIntegration/ORM/EntityManagerIntegrationTest.php

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\DoctrineIntegration\ORM;
4+
5+
use Composer\InstalledVersions;
6+
use PHPStan\Testing\TypeInferenceTestCase;
7+
use function strpos;
8+
9+
class EntityManagerTypeInferenceTest extends TypeInferenceTestCase
10+
{
11+
12+
/**
13+
* @return iterable<mixed>
14+
*/
15+
public function dataFileAsserts(): iterable
16+
{
17+
yield from $this->gatherAssertTypes(__DIR__ . '/data/entityManagerDynamicReturn.php');
18+
yield from $this->gatherAssertTypes(__DIR__ . '/data/entityManagerMergeReturn.php');
19+
yield from $this->gatherAssertTypes(__DIR__ . '/data/customRepositoryUsage.php');
20+
yield from $this->gatherAssertTypes(__DIR__ . '/data/queryBuilder.php');
21+
22+
$version = InstalledVersions::getVersion('doctrine/dbal');
23+
$hasDbal3 = $version !== null && strpos($version, '3.') === 0;
24+
25+
if ($hasDbal3) {
26+
yield from $this->gatherAssertTypes(__DIR__ . '/data/dbalQueryBuilderExecuteDynamicReturnDbal3.php');
27+
} else {
28+
yield from $this->gatherAssertTypes(__DIR__ . '/data/dbalQueryBuilderExecuteDynamicReturn.php');
29+
}
30+
}
31+
32+
/**
33+
* @dataProvider dataFileAsserts
34+
* @param mixed ...$args
35+
*/
36+
public function testFileAsserts(
37+
string $assertType,
38+
string $file,
39+
...$args
40+
): void
41+
{
42+
$this->assertFileAsserts($assertType, $file, ...$args);
43+
}
44+
45+
public static function getAdditionalConfigFiles(): array
46+
{
47+
return [__DIR__ . '/phpstan.neon'];
48+
}
49+
50+
}

tests/DoctrineIntegration/ORM/EntityManagerWithoutObjectManagerLoaderIntegrationTest.php

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\DoctrineIntegration\ORM;
4+
5+
use Composer\InstalledVersions;
6+
use PHPStan\Testing\TypeInferenceTestCase;
7+
use function strpos;
8+
9+
class EntityManagerWithoutObjectManagerLoaderTypeInferenceTest extends TypeInferenceTestCase
10+
{
11+
12+
/**
13+
* @return iterable<mixed>
14+
*/
15+
public function dataFileAsserts(): iterable
16+
{
17+
yield from $this->gatherAssertTypes(__DIR__ . '/data/entityManagerDynamicReturn.php');
18+
yield from $this->gatherAssertTypes(__DIR__ . '/data/entityManagerMergeReturn.php');
19+
yield from $this->gatherAssertTypes(__DIR__ . '/data/customRepositoryUsage.php');
20+
21+
$version = InstalledVersions::getVersion('doctrine/dbal');
22+
$hasDbal3 = $version !== null && strpos($version, '3.') === 0;
23+
24+
if ($hasDbal3) {
25+
yield from $this->gatherAssertTypes(__DIR__ . '/data/dbalQueryBuilderExecuteDynamicReturnDbal3.php');
26+
} else {
27+
yield from $this->gatherAssertTypes(__DIR__ . '/data/dbalQueryBuilderExecuteDynamicReturn.php');
28+
}
29+
}
30+
31+
/**
32+
* @dataProvider dataFileAsserts
33+
* @param mixed ...$args
34+
*/
35+
public function testFileAsserts(
36+
string $assertType,
37+
string $file,
38+
...$args
39+
): void
40+
{
41+
$this->assertFileAsserts($assertType, $file, ...$args);
42+
}
43+
44+
public static function getAdditionalConfigFiles(): array
45+
{
46+
return [__DIR__ . '/phpstan-without-object-manager-loader.neon'];
47+
}
48+
49+
}

tests/DoctrineIntegration/ORM/EntityRepositoryDynamicReturnIntegrationTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace PHPStan\DoctrineIntegration\ORM;
44

55
use PHPStan\Testing\LevelsTestCase;
6-
use const PHP_MAJOR_VERSION;
7-
use const PHP_MINOR_VERSION;
86

97
final class EntityRepositoryDynamicReturnIntegrationTest extends LevelsTestCase
108
{
@@ -21,10 +19,6 @@ public function dataTopics(): array
2119

2220
public function getDataPath(): string
2321
{
24-
if (PHP_MAJOR_VERSION === 7 && PHP_MINOR_VERSION === 1) {
25-
return __DIR__ . '/data-php-7.1';
26-
}
27-
2822
return __DIR__ . '/data';
2923
}
3024

tests/DoctrineIntegration/ORM/EntityRepositoryWithoutObjectManagerLoaderDynamicReturnIntegrationTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace PHPStan\DoctrineIntegration\ORM;
44

55
use PHPStan\Testing\LevelsTestCase;
6-
use const PHP_MAJOR_VERSION;
7-
use const PHP_MINOR_VERSION;
86

97
final class EntityRepositoryWithoutObjectManagerLoaderDynamicReturnIntegrationTest extends LevelsTestCase
108
{
@@ -21,10 +19,6 @@ public function dataTopics(): array
2119

2220
public function getDataPath(): string
2321
{
24-
if (PHP_MAJOR_VERSION === 7 && PHP_MINOR_VERSION === 1) {
25-
return __DIR__ . '/data-php-7.1';
26-
}
27-
2822
return __DIR__ . '/data';
2923
}
3024

tests/DoctrineIntegration/ORM/data-php-7.1/entityRepositoryDynamicReturn-0.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/DoctrineIntegration/ORM/data-php-7.1/entityRepositoryDynamicReturn-2.json

Lines changed: 0 additions & 47 deletions
This file was deleted.

tests/DoctrineIntegration/ORM/data-php-7.1/entityRepositoryDynamicReturn-4.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/DoctrineIntegration/ORM/data-php-7.1/entityRepositoryDynamicReturn-5.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/DoctrineIntegration/ORM/data-php-7.1/entityRepositoryDynamicReturn-6.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/DoctrineIntegration/ORM/data-php-7.1/entityRepositoryDynamicReturn-7.json

Lines changed: 0 additions & 42 deletions
This file was deleted.

tests/DoctrineIntegration/ORM/data-php-7.1/entityRepositoryDynamicReturn-9.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)