diff --git a/.gitignore b/.gitignore
index 53129d62..fd3181fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ vendor/
.vscode/
psysh
.phpunit.result.cache
+phpunit_var_*.xml
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index 26f7e0b2..d4f07804 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -30,5 +30,6 @@
+
\ No newline at end of file
diff --git a/test b/test
index b22f03b1..67ce4feb 100755
--- a/test
+++ b/test
@@ -2,4 +2,26 @@
# for development
docker-compose up -d
-docker-compose exec test vendor/bin/phpunit "$@"
\ No newline at end of file
+
+# 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
diff --git a/tests/TenantStorageTest.php b/tests/TenantStorageTest.php
index bfbfa368..1c885e31 100644
--- a/tests/TenantStorageTest.php
+++ b/tests/TenantStorageTest.php
@@ -2,8 +2,6 @@
namespace Stancl\Tenancy\Tests;
-use Stancl\Tenancy\Interfaces\StorageDriver;
-
class TenantStorageTest extends TestCase
{
/** @test */
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 200c70b0..e1659a8b 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -9,6 +9,13 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
public $autoCreateTenant = true;
public $autoInitTenancy = true;
+ private function checkRequirements(): void
+ {
+ parent::checkRequirements();
+
+ dd($this->getAnnotations());
+ }
+
/**
* Setup the test environment
*
@@ -81,6 +88,20 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
'tenancy.redis.prefixed_connections' => ['default'],
'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()