Skip to content

Commit

Permalink
Merge pull request #65 from weirdan/update-to-codeception-4.x
Browse files Browse the repository at this point in the history
Update to Codeception 4.x
  • Loading branch information
weirdan authored Apr 5, 2020
2 parents 4b662fd + 63838b8 commit a87e003
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 169 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"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": {
"codeception/base": "^2.5",
"codeception/codeception": "^4.0.3",
"squizlabs/php_codesniffer": "^3.3.1",
"weirdan/codeception-psalm-module": "^0.4.0"
},
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
6 changes: 3 additions & 3 deletions tests/acceptance/TestCase.feature
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Feature: TestCase
private $i;
/** @return void */
public function setUp() {
public function setUp(): void {
$this->i = $this->prophesize(I::class);
}
Expand Down Expand Up @@ -712,7 +712,7 @@ Feature: TestCase
private $i;
/** @return void */
public function setUp() {
public function setUp(): void {
$this->i = $this->prophesize(I::class);
}
Expand All @@ -739,7 +739,7 @@ Feature: TestCase
protected $i;
/** @return void */
public function setUp() {
public function setUp(): void {
$this->i = $this->prophesize(I::class);
}
}
Expand Down

0 comments on commit a87e003

Please sign in to comment.