Skip to content

Commit

Permalink
Add tests for custom public url on private containers
Browse files Browse the repository at this point in the history
  • Loading branch information
hedii committed Oct 14, 2020
1 parent 9c054fe commit 45eec83
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/PrivateContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,50 @@ public function testItDoesntUsePrefixIfPrefixIsNull(): void
);
}

public function testItUseACustomPublicUrl(): void
{
$this->app['config']->set('filesystems.disks.ovh-swift', $this->getOvhSwiftConfiguration([
'visibility' => 'private',
'containerName' => 'test-private',
'publicUrl' => 'http://foo.example.com',
'prefix' => null,
]));

$fileName = $this->randomFileName();
$content = $this->randomContent();

Storage::put($fileName, $content);

$this->assertTrue(
Str::startsWith(
Storage::temporaryUrl($fileName, Carbon::now()->addMinute()),
"http://foo.example.com/{$fileName}"
),
);
}

public function testItPreservesPrefixWithACustomPublicUrl(): void
{
$this->app['config']->set('filesystems.disks.ovh-swift', $this->getOvhSwiftConfiguration([
'visibility' => 'private',
'containerName' => 'test-private',
'publicUrl' => 'http://foo.example.com',
'prefix' => 'a-prefix',
]));

$fileName = $this->randomFileName();
$content = $this->randomContent();

Storage::put($fileName, $content);

$this->assertTrue(
Str::startsWith(
Storage::temporaryUrl($fileName, Carbon::now()->addMinute()),
"http://foo.example.com/a-prefix/{$fileName}"
),
);
}

public function testItThrowsWhenUsingUrlOnPrivateContainer(): void
{
$this->app['config']->set('filesystems.disks.ovh-swift', $this->getOvhSwiftConfiguration([
Expand Down

0 comments on commit 45eec83

Please sign in to comment.