Skip to content

Commit

Permalink
de-duplicate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jul 20, 2022
1 parent f00cdbc commit 2e6e614
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
5 changes: 3 additions & 2 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -934,15 +934,16 @@ public function dataFileAsserts(): iterable
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7580.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/this-subtractable.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/match-expression-inference.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-1519.php');

if (PHP_VERSION_ID < 80000) {
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7663.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7663-php7.php');
}
if (PHP_VERSION_ID >= 80000) {
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7663-php8.php');
}
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7663.php');

yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-1519.php');
}

/**
Expand Down
16 changes: 16 additions & 0 deletions tests/PHPStan/Analyser/data/bug-7663-php7.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Bug7663;

use function PHPStan\Testing\assertType;

class HelloWorld7
{
/**
* @param 'de_DE'|'en_US' $language
*/
public function sayHello($language): void
{
assertType("false", substr('de_DE', 10, -10));
}
}
7 changes: 0 additions & 7 deletions tests/PHPStan/Analyser/data/bug-7663-php8.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ class HelloWorld8
*/
public function sayHello($language): void
{
assertType("'de'|'en'", substr($language, 0, 2));
assertType("'de_DE'|'en_US'", substr($language, 0, 10));

assertType("'DE'|'US'", substr($language, 3));
assertType("'_DE'|'_US'", substr($language, -3));
assertType("'_'", substr($language, -3, 1));

assertType("''", substr('de_DE', 10, -10));
}
}
4 changes: 1 addition & 3 deletions tests/PHPStan/Analyser/data/bug-7663.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use function PHPStan\Testing\assertType;

class HelloWorld7
class HelloWorld
{
/**
* @param 'de_DE'|'en_US' $language
Expand All @@ -17,7 +17,5 @@ public function sayHello($language): void
assertType("'DE'|'US'", substr($language, 3));
assertType("'_DE'|'_US'", substr($language, -3));
assertType("'_'", substr($language, -3, 1));

assertType("false", substr('de_DE', 10, -10));
}
}

0 comments on commit 2e6e614

Please sign in to comment.