mirror of
https://github.com/flarum/core.git
synced 2025-08-06 00:17:31 +02:00
Clean up usages / deprecate path helpers (#2155)
* Write source map without creating temp file Less I/O, and one less place where we access the global path helpers. * Drop useless app_path() helper This was probably taken straight from Laravel. There is no equivalent concept in Flarum, so this should be safe to remove. * Deprecate global path helpers Developers using these helpers can inject the `Paths` class instead. * Stop storing paths as strings in container * Avoid using path helpers from Application class * Deprecate path helpers from Application class * Avoid using public_path() in prerequisite check a) The comparison was already outdated, as a different path was passed. b) We're trying to get rid of these global helpers.
This commit is contained in:
0
framework/core/tests/fixtures/writable_paths/writable/.keep
vendored
Normal file
0
framework/core/tests/fixtures/writable_paths/writable/.keep
vendored
Normal file
@@ -7,6 +7,7 @@
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Foundation\Paths;
|
||||
use Flarum\Install\AdminUser;
|
||||
use Flarum\Install\BaseUrl;
|
||||
use Flarum\Install\DatabaseConfig;
|
||||
@@ -38,10 +39,12 @@ echo "\nOff we go...\n";
|
||||
*/
|
||||
|
||||
$installation = new Installation(
|
||||
__DIR__.'/tmp',
|
||||
__DIR__.'/tmp/public',
|
||||
__DIR__.'/tmp/storage',
|
||||
__DIR__.'/../../vendor'
|
||||
new Paths([
|
||||
'base' => __DIR__.'/tmp',
|
||||
'public' => __DIR__.'/tmp/public',
|
||||
'storage' => __DIR__.'/tmp/storage',
|
||||
'vendor' => __DIR__.'/../../vendor',
|
||||
])
|
||||
);
|
||||
|
||||
$pipeline = $installation
|
||||
|
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Tests\unit\Install\Prerequisite;
|
||||
|
||||
use Flarum\Install\Prerequisite\WritablePaths;
|
||||
use Flarum\Tests\unit\TestCase;
|
||||
|
||||
class WritablePathsTest extends TestCase
|
||||
{
|
||||
public function test_no_problems_when_all_directories_are_writable()
|
||||
{
|
||||
$writable = new WritablePaths([
|
||||
__DIR__.'/../../../fixtures/writable_paths/writable',
|
||||
]);
|
||||
|
||||
$this->assertCount(0, $writable->problems());
|
||||
}
|
||||
|
||||
public function test_paths_can_be_given_with_wildcard()
|
||||
{
|
||||
$writable = new WritablePaths([
|
||||
__DIR__.'/../../../fixtures/writable_paths/writable/*',
|
||||
]);
|
||||
|
||||
$this->assertCount(0, $writable->problems());
|
||||
}
|
||||
|
||||
public function test_problems_when_one_path_is_missing()
|
||||
{
|
||||
$writable = new WritablePaths([
|
||||
__DIR__.'/../../../fixtures/writable_paths/missing',
|
||||
__DIR__.'/../../../fixtures/writable_paths/writable',
|
||||
]);
|
||||
|
||||
$problems = $writable->problems();
|
||||
$this->assertCount(1, $problems);
|
||||
$this->assertRegExp(
|
||||
"%^The .+/tests/fixtures/writable_paths/missing directory doesn't exist$%",
|
||||
$problems[0]['message']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'This directory is necessary for the installation. Please create the folder.',
|
||||
$problems[0]['detail']
|
||||
);
|
||||
}
|
||||
|
||||
public function test_problem_details_filter_out_wildcard()
|
||||
{
|
||||
$writable = new WritablePaths([
|
||||
__DIR__.'/../../../fixtures/writable_paths/missing/*',
|
||||
]);
|
||||
|
||||
$problems = $writable->problems();
|
||||
$this->assertCount(1, $problems);
|
||||
$this->assertRegExp(
|
||||
"%^The .+/tests/fixtures/writable_paths/missing directory doesn't exist$%",
|
||||
$problems[0]['message']
|
||||
);
|
||||
$this->assertEquals(
|
||||
'This directory is necessary for the installation. Please create the folder.',
|
||||
$problems[0]['detail']
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user