psalm-plugin-laravel/tests/acceptance/AbortIf.feature
feek 935357a7c8
Merge pull request #171 from caugner/test-abort
test: add test case for abort()
2021-07-06 14:24:43 -04:00

52 lines
1.1 KiB
Gherkin

Feature: abort_if()
The global abort_if helper is supported
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>
"""
And I have the following code preamble
"""
<?php declare(strict_types=1);
"""
Scenario: abort asserts not null
Given I have the following code
"""
/**
* @param string|null $nullable
*/
function test($nullable): string {
if (!$nullable) {
abort(422);
}
return $nullable;
}
"""
Scenario: abort_if asserts not null
Given I have the following code
"""
/**
* @param string|null $nullable
*/
function abortIfNullable($nullable): string {
abort_if(is_null($nullable), 422);
return $nullable;
}
"""
When I run Psalm
Then I see no errors