Skip to content

Commit

Permalink
[11.x] Test application storage path (#51848)
Browse files Browse the repository at this point in the history
* Test application storage path

* StyleCI
  • Loading branch information
seriquynh authored Jun 20, 2024
1 parent c839b3e commit d0c5a40
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/Foundation/FoundationApplicationBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ protected function tearDown(): void

unset($_ENV['APP_BASE_PATH']);

unset($_ENV['LARAVEL_STORAGE_PATH'], $_SERVER['LARAVEL_STORAGE_PATH']);

parent::tearDown();
}

Expand Down Expand Up @@ -41,4 +43,48 @@ public function testBaseDirectoryWithComposer()

$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());
}
}

0 comments on commit d0c5a40

Please sign in to comment.