mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:44:03 +00:00
wip
This commit is contained in:
parent
2cf96423b0
commit
7c598ae2fe
5 changed files with 46 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,3 +4,4 @@ vendor/
|
||||||
.vscode/
|
.vscode/
|
||||||
psysh
|
psysh
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
phpunit_var_*.xml
|
||||||
|
|
@ -30,5 +30,6 @@
|
||||||
<env name="SESSION_DRIVER" value="array"/>
|
<env name="SESSION_DRIVER" value="array"/>
|
||||||
<env name="DB_CONNECTION" value="sqlite"/>
|
<env name="DB_CONNECTION" value="sqlite"/>
|
||||||
<env name="AWS_DEFAULT_REGION" value="us-west-2"/>
|
<env name="AWS_DEFAULT_REGION" value="us-west-2"/>
|
||||||
|
<env name="STANCL_TENANCY_TEST_VARIANT" value="1"/>
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
24
test
24
test
|
|
@ -2,4 +2,26 @@
|
||||||
|
|
||||||
# for development
|
# for development
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
docker-compose exec test vendor/bin/phpunit "$@"
|
|
||||||
|
# Specify variant using `export VARIANT=1`
|
||||||
|
if [[ -z "${VARIANT}" ]]; then
|
||||||
|
variants=(1 2)
|
||||||
|
else
|
||||||
|
variants=( $VARIANT )
|
||||||
|
fi
|
||||||
|
|
||||||
|
for variant in "${variants[@]}"
|
||||||
|
do
|
||||||
|
export filename_base="phpunit_var_$variant"
|
||||||
|
|
||||||
|
(cat phpunit.xml | sed -e "s/\"STANCL_TENANCY_TEST_VARIANT\" value=\"1\"/\"STANCL_TENANCY_TEST_VARIANT\" value=\"$variant\"/g") > "$filename_base.xml"
|
||||||
|
|
||||||
|
printf "Test variant: $variant\n\n"
|
||||||
|
|
||||||
|
docker-compose exec test vendor/bin/phpunit \
|
||||||
|
--configuration "$filename_base.xml" \
|
||||||
|
--coverage-php "$filename_base.cov" \
|
||||||
|
"$@"
|
||||||
|
done
|
||||||
|
|
||||||
|
# todo merge cov reports
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Tests;
|
namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
use Stancl\Tenancy\Interfaces\StorageDriver;
|
|
||||||
|
|
||||||
class TenantStorageTest extends TestCase
|
class TenantStorageTest extends TestCase
|
||||||
{
|
{
|
||||||
/** @test */
|
/** @test */
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,13 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
public $autoCreateTenant = true;
|
public $autoCreateTenant = true;
|
||||||
public $autoInitTenancy = true;
|
public $autoInitTenancy = true;
|
||||||
|
|
||||||
|
private function checkRequirements(): void
|
||||||
|
{
|
||||||
|
parent::checkRequirements();
|
||||||
|
|
||||||
|
dd($this->getAnnotations());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the test environment
|
* Setup the test environment
|
||||||
*
|
*
|
||||||
|
|
@ -81,6 +88,20 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
'tenancy.redis.prefixed_connections' => ['default'],
|
'tenancy.redis.prefixed_connections' => ['default'],
|
||||||
'tenancy.migrations_directory' => database_path('../migrations'),
|
'tenancy.migrations_directory' => database_path('../migrations'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
switch((string) env('STANCL_TENANCY_TEST_VARIANT', '1')) {
|
||||||
|
case '2':
|
||||||
|
$app['config']->set([
|
||||||
|
'tenancy.redis.tenancy' => true,
|
||||||
|
'database.redis.client' => 'phpredis',
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$app['config']->set([
|
||||||
|
'tenancy.redis.tenancy' => false,
|
||||||
|
'database.redis.client' => 'predis',
|
||||||
|
]);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadDotEnv()
|
protected function loadDotEnv()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue