Skip to content

Commit 9b794b7

Browse files
committed
ADD e2e testing into own directory
1 parent d37bfea commit 9b794b7

20 files changed

Lines changed: 88 additions & 43 deletions

build/e2e/data/BaseTraitClass.php

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

build/e2e/data/TraitClass.php

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

build/e2e/data/TraitClassProblems.php

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

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@
4646
"analyse": "phpstan analyse",
4747
"lint": "parallel-lint src tests",
4848
"test": "phpunit",
49+
"e2e": "phpstan analyse --configuration=e2e/phpstan-e2e.neon --error-format=json | php e2e/test-runner",
4950
"ci": [
5051
"@composer-validate",
5152
"@lint",
5253
"@cs",
5354
"@test",
54-
"@analyse"
55+
"@analyse",
56+
"@e2e"
5557
]
5658
},
5759
"extra": {
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?php
22

3-
namespace DaveLiddament\PhpstanPhpLanguageExtensions\Build\e2e;
4-
3+
/**
4+
* Script takes JSON output from PHPStan and a list of expected errors. It checks this list matches.
5+
*
6+
* This should be called from the `test-runner` script.
7+
*/
58
final class PHPStanResultsChecker
69
{
710
private const IDENTIFIER_PREFIX = 'phpExtensionLibrary.';
8-
private const FILE_PATH_TO_REMOVE = 'build/e2e/data/';
11+
private const FILE_PATH_TO_REMOVE = 'e2e/data/';
912

1013
/**
11-
* @param array<int,string> $expectedResults
14+
* @param array<int,string> $expectedResults see `test-runner` script for format
1215
*/
1316
public function checkResults(string $phpstanResultsAsJsonString, array $expectedResults): void
1417
{

e2e/data/BaseTraitClass.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace data;
4+
5+
class BaseTraitClass
6+
{
7+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace DaveLiddament\PhpstanPhpLanguageExtensions\Build\e2e\data;
3+
namespace data;
44

55
class FriendProblems
66
{

e2e/data/MustUse.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace data;
4+
5+
use DaveLiddament\PhpLanguageExtensions\MustUseResult;
6+
7+
class MustUse
8+
{
9+
#[MustUseResult]
10+
public function getResult(): int
11+
{
12+
return 1;
13+
}
14+
15+
public function code(): void
16+
{
17+
echo $this->getResult();
18+
$this->getResult();
19+
}
20+
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?php
22

3-
namespace DaveLiddament\PhpstanPhpLanguageExtensions\Build\e2e\data;
3+
namespace data;
44

55
use DaveLiddament\PhpLanguageExtensions\RestrictTraitTo;
66

77
#[RestrictTraitTo(BaseTraitClass::class)]
88
trait MyTrait
99
{
10-
11-
}
10+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace DaveLiddament\PhpstanPhpLanguageExtensions\Build\e2e\data;
3+
namespace data;
44

55
use DaveLiddament\PhpLanguageExtensions\Friend;
66

0 commit comments

Comments
 (0)