Skip to content

Commit

Permalink
Bump PHPUnit to 7.5+
Browse files Browse the repository at this point in the history
Codeception 4.x is not compatible with lower versions
  • Loading branch information
weirdan committed Apr 5, 2020
1 parent 20e147f commit 63838b8
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 165 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"ext-simplexml": "*",
"composer/semver": "^1.4",
"ocramius/package-versions": "^1.3",
"phpunit/phpunit": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"phpunit/phpunit": "^7.5 || ^8.0 || ^9.0",
"vimeo/psalm": "^3.6.2 || dev-master"
},
"require-dev": {
Expand Down
5 changes: 1 addition & 4 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ class Plugin implements PluginEntryPointInterface
/** @return void */
public function __invoke(RegistrationInterface $psalm, SimpleXMLElement $config = null)
{
$psalm->addStubFile(__DIR__ . '/../stubs/Assert.phpstub');
if ($this->packageVersionIs('phpunit/phpunit', '>=', '7.5')) {
$psalm->addStubFile(__DIR__ . '/../stubs/Assert_75.phpstub');
}
$psalm->addStubFile(__DIR__ . '/../stubs/Assert_75.phpstub');
$psalm->addStubFile(__DIR__ . '/../stubs/TestCase.phpstub');
$psalm->addStubFile(__DIR__ . '/../stubs/MockBuilder.phpstub');
$psalm->addStubFile(__DIR__ . '/../stubs/InvocationMocker.phpstub');
Expand Down
118 changes: 0 additions & 118 deletions stubs/Assert.phpstub

This file was deleted.

111 changes: 111 additions & 0 deletions stubs/Assert_75.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,115 @@ abstract class Assert
*/
public static function assertIsNotIterable($actual, string $message = '') {}

/**
* Asserts that a variable is of a given type.
*
* @param class-string $expected
* @param mixed $actual
* @param string $message
*
* @template T
* @template-typeof T $expected
* @psalm-assert T $actual
*/
public static function assertInstanceOf($expected, $actual, $message = '') {}

/**
* Asserts that a variable is of a given type.
*
* @param class-string $expected
* @param mixed $actual
* @param string $message
*
* @template T
* @template-typeof T $expected
* @psalm-assert !T $actual
*/
public static function assertNotInstanceOf($expected, $actual, $message = '') {}

/**
* Asserts that a condition is true.
*
* @param mixed $condition
* @param string $message
*
* @throws AssertionFailedError
* @psalm-assert true $condition
*/
public static function assertTrue($condition, $message = '') {}

/**
* Asserts that a condition is not true.
*
* @param mixed $condition
* @param string $message
*
* @throws AssertionFailedError
* @psalm-assert !true $condition
*/
public static function assertNotTrue($condition, $message = '') {}

/**
* Asserts that a condition is false.
*
* @param mixed $condition
* @param string $message
*
* @throws AssertionFailedError
* @psalm-assert false $condition
*/
public static function assertFalse($condition, $message = '') {}

/**
* Asserts that a condition is not false.
*
* @param mixed $condition
* @param string $message
*
* @throws AssertionFailedError
* @psalm-assert !false $condition
*/
public static function assertNotFalse($condition, $message = '') {}

/**
* Asserts that a variable is null.
*
* @param mixed $actual
* @param string $message
* @psalm-assert null $actual
*/
public static function assertNull($actual, $message = '') {}

/**
* Asserts that a variable is not null.
*
* @param mixed $actual
* @param string $message
* @psalm-assert !null $actual
*/
public static function assertNotNull($actual, $message = '') {}

/**
* Asserts that two variables are the same.
*
* @template T
* @param T $expected
* @param mixed $actual
* @param string $message
* @psalm-assert =T $actual
* @return void
*/
public static function assertSame($expected, $actual, $message = '') {}

/**
* Asserts that two variables are not the same.
*
* @template T
* @param T $expected
* @param mixed $actual
* @param string $message
* @psalm-assert !=T $actual
* @return void
*/
public static function assertNotSame($expected, $actual, $message = '') {}
}
42 changes: 0 additions & 42 deletions tests/acceptance/Assert.feature

This file was deleted.

19 changes: 19 additions & 0 deletions tests/acceptance/Assert75.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ Feature: Assert (PHPUnit 7.5+)
"""
And I have PHPUnit newer than "7.4.99999" (because of "new features in 7.5")

Scenario: Assert::assertInstanceOf()
Given I have the following code
"""
function f(): \Exception {
return rand(0,1) ? new \RuntimeException : new \InvalidArgumentException;
}
/**
* @return void
*/
function acceptsRuntimeException(\RuntimeException $_e) {}
$e = f();
Assert::assertInstanceOf(\RuntimeException::class, $e);
acceptsRuntimeException($e);
"""
When I run Psalm
Then I see no errors

Scenario: Assert::assertIsArray()
Given I have the following code
"""
Expand Down

0 comments on commit 63838b8

Please sign in to comment.