mirror of
https://github.com/danog/psalm-plugin-phpunit.git
synced 2024-11-26 20:15:08 +01:00
Added test infrastructure
- Added Codeception scaffolding - Added travis config - Added example test
This commit is contained in:
parent
1284e51d3c
commit
6e0f0643d6
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.1"
|
||||
"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/_generated" />
|
||||
</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