psalm-plugin-laravel/tests/acceptance/AbortIf.feature

52 lines
1.1 KiB
Gherkin
Raw Normal View History

2021-07-06 16:28:37 +02:00
Feature: abort_if()
The global abort_if helper is supported
2020-07-21 05:56:35 +02:00
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);
"""
2021-07-06 16:18:23 +02:00
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;
}
"""
2020-07-21 05:56:35 +02:00
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