introduce testing

This commit is contained in:
Feek 2020-04-08 00:28:39 -07:00
parent 6c0b792d9a
commit 8ef4d611ed
16 changed files with 185 additions and 4 deletions

10
codeception.yml Normal file
View 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

View File

@ -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"
}
}

View File

@ -209,6 +209,6 @@ abstract class AbstractPlugin implements PluginEntryPointInterface
*/
protected function getEnvironmentSetUp($app): void
{
// ..
$app['config']->set('app.key', 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF');
}
}

View File

@ -33,4 +33,4 @@ class AuthReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypePro
return Type::getMixed();
}
}
}

0
tests/_data/.gitkeep Normal file
View File

2
tests/_output/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
tests/_run/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

View 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
*/
}

View 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
*/
}

View 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
{
}

View 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
{
}

View 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
{
}

View 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
View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -0,0 +1,6 @@
actor: AcceptanceTester
modules:
enabled:
- Cli
- Filesystem
- \Weirdan\Codeception\Psalm\Module

View 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