psalm-plugin-phpunit/tests/acceptance/Assert.feature

33 lines
739 B
Gherkin
Raw Normal View History

Feature: Assert
In order to use PHPUnit safely
As a Psalm user
I need Psalm to typecheck asserts
Background:
Given I have the following code preamble
"""
<?php
namespace NS;
use PHPUnit\Framework\Assert;
"""
2019-02-10 07:19:06 +01:00
Scenario: Assert::assertInstanceOf()
Given I have the following code
"""
function f(): \Exception {
return rand(0,1) ? new \RuntimeException : new \InvalidArgumentException;
}
2019-02-13 22:03:21 +01:00
/**
* @return void
*/
function acceptsRuntimeException(\RuntimeException $_e) {}
$e = f();
Assert::assertInstanceOf(\RuntimeException::class, $e);
acceptsRuntimeException($e);
"""
When I run Psalm
Then I see no errors