mirror of
https://github.com/danog/psalm-plugin-phpunit.git
synced 2024-12-02 09:27:56 +01:00
commit
34164fbbb5
21
.travis.yml
Normal file
21
.travis.yml
Normal file
@ -0,0 +1,21 @@
|
||||
language: php
|
||||
php:
|
||||
- 7.3
|
||||
before_install:
|
||||
- phpenv config-rm xdebug.ini || true
|
||||
|
||||
install:
|
||||
- composer install
|
||||
- if [[ "$DEPS" = 'high' ]]; then travis_retry composer $DEFAULT_COMPOSER_FLAGS update; fi
|
||||
- if [[ "$DEPS" = 'low' ]]; then travis_retry composer $DEFAULT_COMPOSER_FLAGS --prefer-lowest --prefer-stable update; fi
|
||||
- if [[ "$DEPS" = 'stable' ]]; then travis_retry composer $DEFAULT_COMPOSER_FLAGS --prefer-stable update; fi
|
||||
|
||||
script: composer check
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- DEPS="low"
|
||||
- DEPS="high"
|
||||
- DEPS="stable"
|
||||
global:
|
||||
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-suggest"
|
11
codeception.yml
Normal file
11
codeception.yml
Normal file
@ -0,0 +1,11 @@
|
||||
namespace: Psalm\PhpUnitPlugin\Tests
|
||||
paths:
|
||||
tests: tests
|
||||
output: tests/_output
|
||||
data: tests/_data
|
||||
support: tests/_support
|
||||
envs: tests/_envs
|
||||
actor_suffix: Tester
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunFailed
|
@ -14,7 +14,9 @@
|
||||
"vimeo/psalm": "^3.0 || dev-master"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "^3.3"
|
||||
"squizlabs/php_codesniffer": "^3.3.1",
|
||||
"codeception/base": "^2.5",
|
||||
"weirdan/codeception-psalm-module": "dev-master"
|
||||
},
|
||||
"extra": {
|
||||
"psalm": {
|
||||
@ -26,13 +28,20 @@
|
||||
"Psalm\\PhpUnitPlugin\\": ["."]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Psalm\\PhpUnitPlugin\\Tests\\": ["tests/_support"]
|
||||
}
|
||||
},
|
||||
"scripts" : {
|
||||
"check": [
|
||||
"@cs-check",
|
||||
"@analyze"
|
||||
"@analyze",
|
||||
"@test"
|
||||
],
|
||||
"analyze": "psalm",
|
||||
"cs-check": "phpcs",
|
||||
"cs-fix": "phpcbf"
|
||||
"cs-fix": "phpcbf",
|
||||
"test": "codecept run -v"
|
||||
}
|
||||
}
|
||||
|
@ -9,13 +9,16 @@
|
||||
<directory name="." />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
<directory name="stubs" />
|
||||
<directory name="stubs" />
|
||||
<directory name="tests/_support" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
|
||||
<issueHandlers>
|
||||
|
||||
<LessSpecificReturnType errorLevel="info" />
|
||||
|
||||
</issueHandlers>
|
||||
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
|
||||
</plugins>
|
||||
</psalm>
|
||||
|
0
tests/_data/.gitkeep
Normal file
0
tests/_data/.gitkeep
Normal file
2
tests/_output/.gitignore
vendored
Normal file
2
tests/_output/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
2
tests/_run/.gitignore
vendored
Normal file
2
tests/_run/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
26
tests/_support/AcceptanceTester.php
Normal file
26
tests/_support/AcceptanceTester.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace Psalm\PhpUnitPlugin\Tests;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class AcceptanceTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\AcceptanceTesterActions;
|
||||
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
10
tests/_support/Helper/Acceptance.php
Normal file
10
tests/_support/Helper/Acceptance.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Psalm\PhpUnitPlugin\Tests\Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
class Acceptance extends \Codeception\Module
|
||||
{
|
||||
|
||||
}
|
2
tests/_support/_generated/.gitignore
vendored
Normal file
2
tests/_support/_generated/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
7
tests/acceptance.suite.yml
Normal file
7
tests/acceptance.suite.yml
Normal file
@ -0,0 +1,7 @@
|
||||
actor: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- Cli
|
||||
- Filesystem
|
||||
- \Weirdan\Codeception\Psalm\Module
|
||||
- \Psalm\PhpUnitPlugin\Tests\Helper\Acceptance
|
28
tests/acceptance/Assert.feature
Normal file
28
tests/acceptance/Assert.feature
Normal file
@ -0,0 +1,28 @@
|
||||
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;
|
||||
|
||||
"""
|
||||
|
||||
Scenario: Asserting instanceof
|
||||
Given I have the following code
|
||||
"""
|
||||
function f(): \Exception {
|
||||
return rand(0,1) ? new \RuntimeException : new \InvalidArgumentException;
|
||||
}
|
||||
function acceptsRuntimeException(\RuntimeException $_e): void {}
|
||||
|
||||
$e = f();
|
||||
Assert::assertInstanceOf(\RuntimeException::class, $e);
|
||||
acceptsRuntimeException($e);
|
||||
"""
|
||||
When I run Psalm
|
||||
Then I see no errors
|
Loading…
Reference in New Issue
Block a user