2021-07-06 16:28:37 +02:00
|
|
|
Feature: Path helpers
|
2020-08-15 07:30:17 +02:00
|
|
|
The global path helpers will return the correct path
|
|
|
|
|
|
|
|
Background:
|
|
|
|
Given I have the following config
|
|
|
|
"""
|
|
|
|
<?xml version="1.0"?>
|
2022-02-21 10:15:13 +01:00
|
|
|
<psalm errorLevel="1">
|
2020-08-15 07:30:17 +02:00
|
|
|
<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: base path can be resolved
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once base_path('routes/console.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: basePath can be resolved from application instance
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once app()->basePath('routes/console.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: app path can be resolved
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once app_path('model.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: path can be resolved from application instance
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once app()->path('model.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: config path can be resolved
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once config_path('file.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: path can be resolved from application instance
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once app()->configPath('file.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: database path can be resolved
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once database_path('migration.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: databasePath can be resolved from application instance
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once app()->databasePath('migration.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: public path can be resolved
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once public_path('file.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: public path can be resolved from application instance
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once app()->make('path.public');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
2021-06-29 06:26:56 +02:00
|
|
|
Then I see no errors
|
2020-08-15 07:30:17 +02:00
|
|
|
|
|
|
|
Scenario: resource path can be resolved
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once resource_path('file.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: resource path can be resolved from application instance
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once app()->resourcePath('file.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: storage path can be resolved
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once storage_path('file.php');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see these errors
|
|
|
|
| Type | Message |
|
|
|
|
| MissingFile | Cannot find file |
|
|
|
|
|
|
|
|
Scenario: storage path can be resolved from application instance
|
|
|
|
Given I have the following code
|
|
|
|
"""
|
|
|
|
require_once app()->make('path.storage');
|
|
|
|
"""
|
|
|
|
When I run Psalm
|
|
|
|
Then I see no errors
|