Skip to content

Commit

Permalink
Write more tests, fix filesystem support for s3
Browse files Browse the repository at this point in the history
  • Loading branch information
stancl committed Feb 8, 2019
1 parent dc21bfa commit 2c69c37
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"orchestra/testbench": "~3.0",
"laravel/framework": "5.7.*",
"vlucas/phpdotenv": "^2.2",
"psy/psysh": "@stable"
"psy/psysh": "@stable",
"league/flysystem-aws-s3-v3": "~1.0"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="AWS_DEFAULT_REGION" value="us-west-2"/>
</php>
</phpunit>
6 changes: 5 additions & 1 deletion tests/BootstrapsTenancyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ public function filesystem_is_suffixed()
if ($override = config("tenancy.filesystem.root_override.{$disk}")) {
$correct_path_prefix = str_replace("%storage_path%", storage_path(), $override);
} else {
$correct_path_prefix = $old_storage_facade_roots[$disk] . "/$suffix/";
if ($base = $old_storage_facade_roots[$disk]) {
$correct_path_prefix = $base . "/$suffix/";
} else {
$correct_path_prefix = "$suffix/";
}
}

$this->assertSame($correct_path_prefix, $current_path_prefix);
Expand Down
6 changes: 5 additions & 1 deletion tests/ReidentificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public function storage_facade_roots_are_correct()
if ($override = config("tenancy.filesystem.root_override.{$disk}")) {
$correct_path_prefix = str_replace("%storage_path%", storage_path(), $override);
} else {
$correct_path_prefix = $originals[$disk] . "/$suffix/";
if ($base = $originals[$disk]) {
$correct_path_prefix = $base . "/$suffix/";
} else {
$correct_path_prefix = "$suffix/";
}
}

$this->assertSame($correct_path_prefix, $current_path_prefix);
Expand Down
12 changes: 12 additions & 0 deletions tests/TenantStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ public function setUp()
$this->storage = app(StorageDriver::class);
}

/** @test */
public function deleting_a_tenant_works()
{
$abc = tenant()->create('abc.localhost');

$this->assertTrue(tenant()->all()->contains($abc));

tenant()->delete($abc['uuid']);

$this->assertFalse(tenant()->all()->contains($abc));
}

/** @test */
public function put_works_with_key_and_value_as_separate_args()
{
Expand Down
5 changes: 5 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ protected function getEnvironmentSetUp($app)
'suffix' => '.sqlite',
],
'database.connections.sqlite.database' => ':memory:',
'tenancy.filesystem.disks' => [
'local',
'public',
's3',
],
]);
}

Expand Down

0 comments on commit 2c69c37

Please sign in to comment.