-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #230 from psalm/config-helper
feature: add basic stub for config helper
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Feature: Config helper | ||
The global config helper will return a strict type | ||
|
||
Background: | ||
Given I have the following config | ||
""" | ||
<?xml version="1.0"?> | ||
<psalm errorLevel="1"> | ||
<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: config with no arguments returns a repository instance | ||
Given I have the following code | ||
""" | ||
function test(): \Illuminate\Config\Repository { | ||
return config(); | ||
} | ||
""" | ||
When I run Psalm | ||
Then I see no errors | ||
|
||
Scenario: config with one argument | ||
Given I have the following code | ||
""" | ||
/** | ||
* @return mixed | ||
*/ | ||
function test() | ||
{ | ||
return config('app.name'); | ||
} | ||
""" | ||
When I run Psalm | ||
Then I see no errors | ||
|
||
Scenario: config with first null argument and second argument provided | ||
Given I have the following code | ||
""" | ||
/** | ||
* @return mixed | ||
*/ | ||
function test() | ||
{ | ||
return config('app.non-existent', false); | ||
} | ||
""" | ||
When I run Psalm | ||
Then I see no errors | ||
|
||
Scenario: config setting at runtime | ||
Given I have the following code | ||
""" | ||
/** | ||
* @return null | ||
*/ | ||
function test() | ||
{ | ||
return config(['app.non-existent' => false]); | ||
} | ||
""" | ||
When I run Psalm | ||
Then I see no errors |