mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2024-11-26 20:34:48 +01:00
introduce testing
This commit is contained in:
parent
6c0b792d9a
commit
8ef4d611ed
10
codeception.yml
Normal file
10
codeception.yml
Normal file
@ -0,0 +1,10 @@
|
||||
paths:
|
||||
tests: tests
|
||||
output: tests/_output
|
||||
data: tests/_data
|
||||
support: tests/_support
|
||||
envs: tests/_envs
|
||||
actor_suffix: Tester
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunFailed
|
@ -4,8 +4,10 @@
|
||||
"type": "psalm-plugin",
|
||||
"require": {
|
||||
"barryvdh/laravel-ide-helper": "^2.6",
|
||||
"laravel/framework": "^5.5 || ^6.0",
|
||||
"vimeo/psalm": "^3.8.2",
|
||||
"orchestra/testbench": "^3.5 || ^4.0 || ^5.0"
|
||||
"orchestra/testbench": "^3.5 || ^4.0 || ^5.0",
|
||||
"psr/event-dispatcher": "^1.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
@ -24,10 +26,16 @@
|
||||
"Psalm\\LaravelPlugin\\": "src"
|
||||
}
|
||||
},
|
||||
"scripts" : {
|
||||
"scripts": {
|
||||
"check": [
|
||||
"@analyze"
|
||||
],
|
||||
"analyze": "psalm"
|
||||
},
|
||||
"require-dev": {
|
||||
"codeception/codeception": "^4.1",
|
||||
"codeception/module-phpbrowser": "^1.0.0",
|
||||
"codeception/module-asserts": "^1.0.0",
|
||||
"weirdan/codeception-psalm-module": "^0.4.0"
|
||||
}
|
||||
}
|
||||
|
@ -209,6 +209,6 @@ abstract class AbstractPlugin implements PluginEntryPointInterface
|
||||
*/
|
||||
protected function getEnvironmentSetUp($app): void
|
||||
{
|
||||
// ..
|
||||
$app['config']->set('app.key', 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF');
|
||||
}
|
||||
}
|
||||
|
@ -33,4 +33,4 @@ class AuthReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypePro
|
||||
|
||||
return Type::getMixed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
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
|
||||
|
||||
|
||||
/**
|
||||
* 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 void pause()
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class AcceptanceTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\AcceptanceTesterActions;
|
||||
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
26
tests/_support/FunctionalTester.php
Normal file
26
tests/_support/FunctionalTester.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* 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 void pause()
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class FunctionalTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\FunctionalTesterActions;
|
||||
|
||||
/**
|
||||
* 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 Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
class Acceptance extends \Codeception\Module
|
||||
{
|
||||
|
||||
}
|
10
tests/_support/Helper/Functional.php
Normal file
10
tests/_support/Helper/Functional.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
class Functional extends \Codeception\Module
|
||||
{
|
||||
|
||||
}
|
10
tests/_support/Helper/Unit.php
Normal file
10
tests/_support/Helper/Unit.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
class Unit extends \Codeception\Module
|
||||
{
|
||||
|
||||
}
|
26
tests/_support/UnitTester.php
Normal file
26
tests/_support/UnitTester.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* 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 void pause()
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class UnitTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\UnitTesterActions;
|
||||
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
2
tests/_support/_generated/.gitignore
vendored
Normal file
2
tests/_support/_generated/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
6
tests/acceptance.suite.yml
Normal file
6
tests/acceptance.suite.yml
Normal file
@ -0,0 +1,6 @@
|
||||
actor: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- Cli
|
||||
- Filesystem
|
||||
- \Weirdan\Codeception\Psalm\Module
|
43
tests/acceptance/RedirectReturnType.feature
Normal file
43
tests/acceptance/RedirectReturnType.feature
Normal file
@ -0,0 +1,43 @@
|
||||
Feature: redirect
|
||||
The global redirect helper will return the correct type depending on args
|
||||
|
||||
Background:
|
||||
Given I have the following config
|
||||
"""
|
||||
<?xml version="1.0"?>
|
||||
<psalm totallyTyped="true">
|
||||
<projectFiles>
|
||||
<directory name="."/>
|
||||
<ignoreFiles> <directory name="../../vendor"/> </ignoreFiles>
|
||||
</projectFiles>
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
|
||||
</plugins>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
Scenario:
|
||||
Given I have the following code
|
||||
"""
|
||||
<?php
|
||||
class Foo {
|
||||
public function bar(): \Illuminate\Routing\Redirector {
|
||||
return redirect();
|
||||
}
|
||||
}
|
||||
"""
|
||||
When I run Psalm
|
||||
Then I see no errors
|
||||
|
||||
Scenario:
|
||||
Given I have the following code
|
||||
"""
|
||||
<?php
|
||||
class Foo {
|
||||
public function bar(): Illuminate\Http\RedirectResponse {
|
||||
return redirect('foo');
|
||||
}
|
||||
}
|
||||
"""
|
||||
When I run Psalm
|
||||
Then I see no errors
|
Loading…
Reference in New Issue
Block a user