1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
<?php
namespace Illuminate\Tests\Foundation;
use Illuminate\Foundation\Application;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class FoundationApplicationBuilderTest extends TestCase
{
protected function tearDown(): void
{
m::close();
unset($_ENV['APP_BASE_PATH']);
unset($_ENV['LARAVEL_STORAGE_PATH'], $_SERVER['LARAVEL_STORAGE_PATH']);
parent::tearDown();
}
public function testBaseDirectoryWithArg()
{
$_ENV['APP_BASE_PATH'] = __DIR__.'/as-env';
$app = Application::configure(__DIR__.'/as-arg')->create();
$this->assertSame(__DIR__.'/as-arg', $app->basePath());
}
public function testBaseDirectoryWithEnv()
{
$_ENV['APP_BASE_PATH'] = __DIR__.'/as-env';
$app = Application::configure()->create();
$this->assertSame(__DIR__.'/as-env', $app->basePath());
}
public function testBaseDirectoryWithComposer()
{
$app = Application::configure()->create();
$this->assertSame(dirname(__DIR__, 2), $app->basePath());
}
public function testStoragePathWithGlobalEnvVariable()
{
$_ENV['LARAVEL_STORAGE_PATH'] = __DIR__.'/env-storage';
$app = Application::configure()->create();
$this->assertSame(__DIR__.'/env-storage', $app->storagePath());
}
public function testStoragePathWithGlobalServerVariable()
{
$_SERVER['LARAVEL_STORAGE_PATH'] = __DIR__.'/server-storage';
$app = Application::configure()->create();
$this->assertSame(__DIR__.'/server-storage', $app->storagePath());
}
public function testStoragePathPrefersEnvVariable()
{
$_ENV['LARAVEL_STORAGE_PATH'] = __DIR__.'/env-storage';
$_SERVER['LARAVEL_STORAGE_PATH'] = __DIR__.'/server-storage';
$app = Application::configure()->create();
$this->assertSame(__DIR__.'/env-storage', $app->storagePath());
}
public function testStoragePathBasedOnBasePath()
{
$app = Application::configure()->create();
$this->assertSame($app->basePath().DIRECTORY_SEPARATOR.'storage', $app->storagePath());
}
public function testStoragePathCanBeCustomized()
{
$_ENV['LARAVEL_STORAGE_PATH'] = __DIR__.'/env-storage';
$app = Application::configure()->create();
$app->useStoragePath(__DIR__.'/custom-storage');
$this->assertSame(__DIR__.'/custom-storage', $app->storagePath());
}
}
|