diff --git a/composer.json b/composer.json index c9f777e..7fc0340 100644 --- a/composer.json +++ b/composer.json @@ -62,8 +62,9 @@ } }, "scripts": { - "test": "vendor/bin/testbench package:test", + "analyse": "vendor/bin/phpstan analyse --verbose --debug --level max", + "cloc": "cloc --exclude-dir=output,vendor .", "format": "vendor/bin/php-cs-fixer fix", - "analyse": "vendor/bin/phpstan analyse --verbose --debug --level max" + "test": "vendor/bin/phpunit" } } diff --git a/database/migrations-laravel/0001_01_01_000000_create_users_table.php b/database/migrations-laravel/0001_01_01_000000_create_users_table.php deleted file mode 100644 index 5ef79e4..0000000 --- a/database/migrations-laravel/0001_01_01_000000_create_users_table.php +++ /dev/null @@ -1,51 +0,0 @@ -id(); - $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); - $table->rememberToken(); - $table->timestamps(); - }); - - Schema::create('password_reset_tokens', function (Blueprint $table) { - $table->string('email')->primary(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); - - Schema::create('sessions', function (Blueprint $table) { - $table->string('id')->primary(); - $table->foreignId('user_id')->nullable()->index(); - $table->string('ip_address', 45)->nullable(); - $table->text('user_agent')->nullable(); - $table->longText('payload'); - $table->integer('last_activity')->index(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('users'); - Schema::dropIfExists('password_reset_tokens'); - Schema::dropIfExists('sessions'); - } -}; diff --git a/database/migrations-laravel/0001_01_01_000001_create_cache_table.php b/database/migrations-laravel/0001_01_01_000001_create_cache_table.php deleted file mode 100644 index 960e12b..0000000 --- a/database/migrations-laravel/0001_01_01_000001_create_cache_table.php +++ /dev/null @@ -1,37 +0,0 @@ -string('key')->primary(); - $table->mediumText('value'); - $table->integer('expiration'); - }); - - Schema::create('cache_locks', function (Blueprint $table) { - $table->string('key')->primary(); - $table->string('owner'); - $table->integer('expiration'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('cache'); - Schema::dropIfExists('cache_locks'); - } -}; diff --git a/database/migrations-laravel/0001_01_01_000002_create_jobs_table.php b/database/migrations-laravel/0001_01_01_000002_create_jobs_table.php deleted file mode 100644 index 0dcb8c4..0000000 --- a/database/migrations-laravel/0001_01_01_000002_create_jobs_table.php +++ /dev/null @@ -1,59 +0,0 @@ -id(); - $table->string('queue')->index(); - $table->longText('payload'); - $table->unsignedTinyInteger('attempts'); - $table->unsignedInteger('reserved_at')->nullable(); - $table->unsignedInteger('available_at'); - $table->unsignedInteger('created_at'); - }); - - Schema::create('job_batches', function (Blueprint $table) { - $table->string('id')->primary(); - $table->string('name'); - $table->integer('total_jobs'); - $table->integer('pending_jobs'); - $table->integer('failed_jobs'); - $table->longText('failed_job_ids'); - $table->mediumText('options')->nullable(); - $table->integer('cancelled_at')->nullable(); - $table->integer('created_at'); - $table->integer('finished_at')->nullable(); - }); - - Schema::create('failed_jobs', function (Blueprint $table) { - $table->id(); - $table->string('uuid')->unique(); - $table->text('connection'); - $table->text('queue'); - $table->longText('payload'); - $table->longText('exception'); - $table->timestamp('failed_at')->useCurrent(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('jobs'); - Schema::dropIfExists('job_batches'); - Schema::dropIfExists('failed_jobs'); - } -}; diff --git a/database/migrations-laravel/2024_03_13_210031_create_personal_access_tokens_table.php b/database/migrations-laravel/2024_03_13_210031_create_personal_access_tokens_table.php deleted file mode 100644 index 8dd13c9..0000000 --- a/database/migrations-laravel/2024_03_13_210031_create_personal_access_tokens_table.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - $table->morphs('tokenable'); - $table->string('name'); - $table->string('token', 64)->unique(); - $table->text('abilities')->nullable(); - $table->timestamp('last_used_at')->nullable(); - $table->timestamp('expires_at')->nullable(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('personal_access_tokens'); - } -}; diff --git a/database/migrations-playground/0001_01_01_000000_create_users_table.php b/database/migrations-playground/0001_01_01_000000_create_users_table.php deleted file mode 100644 index d3ca506..0000000 --- a/database/migrations-playground/0001_01_01_000000_create_users_table.php +++ /dev/null @@ -1,175 +0,0 @@ -uuid('id')->primary(); - - // IDs - - $table->uuid('created_by_id')->nullable()->index(); - $table->uuid('modified_by_id')->nullable()->index(); - $table->string('user_type')->nullable()->index(); - - // Date columns - - $table->timestamps(); - - $table->timestamp('email_verified_at')->nullable(); - // $table->dateTime('email_verified_at')->nullable(); - - $table->dateTime('banned_at')->nullable(); - $table->dateTime('suspended_at')->nullable(); - - $table->softDeletes(); - - // Permissions - - $table->bigInteger('gids')->default(0)->unsigned(); - $table->bigInteger('po')->default(0)->unsigned(); - $table->bigInteger('pg')->default(0)->unsigned(); - $table->bigInteger('pw')->default(0)->unsigned(); - - $table->rememberToken(); - - $table->string('role')->default(''); - - // Status - - $table->bigInteger('status')->default(0)->unsigned(); - $table->bigInteger('rank')->default(0); - $table->bigInteger('size')->default(0); - - // Matrix - - $table->string('matrix')->default(''); - $table->bigInteger('x')->nullable(); - $table->bigInteger('y')->nullable(); - $table->bigInteger('z')->nullable(); - $table->decimal('r', 65, 10)->nullable()->default(null); - $table->decimal('theta', 10, 6)->nullable()->default(null); - $table->decimal('rho', 10, 6)->nullable()->default(null); - $table->decimal('phi', 10, 6)->nullable()->default(null); - $table->decimal('elevation', 65, 10)->nullable()->default(null); - $table->decimal('latitude', 8, 6)->nullable()->default(null); - $table->decimal('longitude', 9, 6)->nullable()->default(null); - - // Flags - - $table->boolean('active')->default(1)->index(); - $table->boolean('banned')->default(0)->index(); - $table->boolean('flagged')->default(0)->index(); - $table->boolean('internal')->default(0)->index(); - $table->boolean('locked')->default(0)->index(); - $table->boolean('problem')->default(0)->index(); - $table->boolean('suspended')->default(0)->index(); - $table->boolean('unknown')->default(0)->index(); - - // Strings - - $table->string('name')->default(''); - $table->string('email')->unique(); - $table->string('password')->default(''); - $table->string('phone')->nullable(); - $table->string('locale')->default(''); - $table->string('timezone')->default(''); - - $table->string('label')->default(''); - $table->string('title')->default(''); - $table->string('byline')->default(''); - $table->string('slug')->nullable()->default(null)->index(); - - // A link to the external source of the user. - $table->string('url')->default(''); - - $table->string('description')->default(''); - - // The introduction should be the first 255 characters or less of the content. - // The introduction is visible to the client. No HTML. - $table->string('introduction')->default(''); - - // The HTML content of the user. - $table->mediumText('content')->nullable(); - - // The summary of the content, HTML allowed, to be shown to the client. - $table->mediumText('summary')->nullable(); - - // UI - - $table->string('icon')->default(''); - $table->string('image')->default(''); - $table->string('avatar')->default(''); - $table->json('ui')->nullable()->default(new Expression('(JSON_OBJECT())')); - - $table->json('abilities') - ->default(new Expression('(JSON_ARRAY())')) - ->comment('Array of ability strings'); - $table->longText('accounts') - ->comment('Encrypted user account objects'); - $table->longText('address') - ->comment('Encrypted user address object'); - $table->longText('contact') - ->comment('Encrypted contact object'); - $table->longText('meta') - ->comment('Encrypted meta object'); - $table->longText('notes') - ->comment('Encrypted array of note objects'); - $table->longText('options') - ->comment('Encrypted options object'); - $table->longText('registration') - ->comment('Encrypted registration information object'); - $table->json('roles') - ->default(new Expression('(JSON_ARRAY())')) - ->comment('Array of role strings'); - $table->json('permissions') - ->default(new Expression('(JSON_ARRAY())')) - ->comment('Array of permission strings'); - $table->json('privileges') - ->default(new Expression('(JSON_ARRAY())')) - ->comment('Array of privilege strings'); - $table->longText('sources') - ->comment('Encrypted array of sources'); - - }); - - Schema::create('password_reset_tokens', function (Blueprint $table) { - $table->string('email')->primary(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); - - Schema::create('sessions', function (Blueprint $table) { - $table->string('id')->primary(); - $table->foreignId('user_id')->nullable()->index(); - $table->string('ip_address', 45)->nullable(); - $table->text('user_agent')->nullable(); - $table->longText('payload'); - $table->integer('last_activity')->index(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('users'); - Schema::dropIfExists('password_reset_tokens'); - Schema::dropIfExists('sessions'); - } -}; diff --git a/database/migrations-playground/0001_01_01_000001_create_cache_table.php b/database/migrations-playground/0001_01_01_000001_create_cache_table.php deleted file mode 100644 index 960e12b..0000000 --- a/database/migrations-playground/0001_01_01_000001_create_cache_table.php +++ /dev/null @@ -1,37 +0,0 @@ -string('key')->primary(); - $table->mediumText('value'); - $table->integer('expiration'); - }); - - Schema::create('cache_locks', function (Blueprint $table) { - $table->string('key')->primary(); - $table->string('owner'); - $table->integer('expiration'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('cache'); - Schema::dropIfExists('cache_locks'); - } -}; diff --git a/database/migrations-playground/0001_01_01_000002_create_jobs_table.php b/database/migrations-playground/0001_01_01_000002_create_jobs_table.php deleted file mode 100644 index 0dcb8c4..0000000 --- a/database/migrations-playground/0001_01_01_000002_create_jobs_table.php +++ /dev/null @@ -1,59 +0,0 @@ -id(); - $table->string('queue')->index(); - $table->longText('payload'); - $table->unsignedTinyInteger('attempts'); - $table->unsignedInteger('reserved_at')->nullable(); - $table->unsignedInteger('available_at'); - $table->unsignedInteger('created_at'); - }); - - Schema::create('job_batches', function (Blueprint $table) { - $table->string('id')->primary(); - $table->string('name'); - $table->integer('total_jobs'); - $table->integer('pending_jobs'); - $table->integer('failed_jobs'); - $table->longText('failed_job_ids'); - $table->mediumText('options')->nullable(); - $table->integer('cancelled_at')->nullable(); - $table->integer('created_at'); - $table->integer('finished_at')->nullable(); - }); - - Schema::create('failed_jobs', function (Blueprint $table) { - $table->id(); - $table->string('uuid')->unique(); - $table->text('connection'); - $table->text('queue'); - $table->longText('payload'); - $table->longText('exception'); - $table->timestamp('failed_at')->useCurrent(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('jobs'); - Schema::dropIfExists('job_batches'); - Schema::dropIfExists('failed_jobs'); - } -}; diff --git a/database/migrations-playground/2024_03_13_210031_create_personal_access_tokens_table.php b/database/migrations-playground/2024_03_13_210031_create_personal_access_tokens_table.php deleted file mode 100644 index ccdd208..0000000 --- a/database/migrations-playground/2024_03_13_210031_create_personal_access_tokens_table.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - $table->uuidMorphs('tokenable'); - $table->string('name'); - $table->string('token', 64)->unique(); - $table->text('abilities')->nullable(); - $table->timestamp('last_used_at')->nullable(); - $table->timestamp('expires_at')->nullable(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('personal_access_tokens'); - } -}; diff --git a/tests/Feature/Console/Commands/About/CommandTest.php b/tests/Feature/Console/Commands/About/CommandTest.php index 05e5f82..8543a02 100644 --- a/tests/Feature/Console/Commands/About/CommandTest.php +++ b/tests/Feature/Console/Commands/About/CommandTest.php @@ -18,6 +18,10 @@ class CommandTest extends TestCase { public function test_command_about_displays_package_information_and_succeed_with_code_0(): void { + config([ + 'playground-matrix.load.migrations' => true, + ]); + /** * @var \Illuminate\Testing\PendingCommand $result */ @@ -25,16 +29,4 @@ public function test_command_about_displays_package_information_and_succeed_with $result->assertExitCode(0); $result->expectsOutputToContain('Playground: Matrix'); } - - // public function test_dump_console_about(): void - // { - // $result = $this->withoutMockingConsoleOutput()->artisan('about'); - // dump(\Illuminate\Support\Facades\Artisan::output()); - // } - - // public function test_dump_console_route_list(): void - // { - // $result = $this->withoutMockingConsoleOutput()->artisan('route:list -vvv'); - // dump(\Illuminate\Support\Facades\Artisan::output()); - // } } diff --git a/tests/Feature/Models/ModelCase.php b/tests/Feature/Models/ModelCase.php index f5bce08..6dc3eaf 100644 --- a/tests/Feature/Models/ModelCase.php +++ b/tests/Feature/Models/ModelCase.php @@ -18,31 +18,13 @@ class ModelCase extends BaseModelCase use DatabaseTransactions; use PackageProviders; + protected bool $hasMigrations = true; + protected bool $load_migrations_laravel = false; protected bool $load_migrations_package = true; protected bool $load_migrations_playground = true; - /** - * Define database migrations. - * - * @api - * - * @return void - */ - protected function defineDatabaseMigrations() - { - if (! empty(env('TEST_DB_MIGRATIONS'))) { - if ($this->load_migrations_laravel) { - $this->loadMigrationsFrom(dirname(dirname(dirname(__DIR__))).'/database/migrations-laravel'); - } - if ($this->load_migrations_package) { - $this->loadMigrationsFrom(dirname(dirname(dirname(__DIR__))).'/database/migrations'); - } - if ($this->load_migrations_playground) { - $this->loadMigrationsFrom(dirname(dirname(dirname(__DIR__))).'/database/migrations-playground'); - } - } - } + protected bool $setUpUserForPlayground = true; } diff --git a/tests/Feature/TestCase.php b/tests/Feature/TestCase.php index d622e43..52753a9 100644 --- a/tests/Feature/TestCase.php +++ b/tests/Feature/TestCase.php @@ -18,31 +18,13 @@ class TestCase extends OrchestraTestCase use DatabaseTransactions; use PackageProviders; + protected bool $hasMigrations = true; + protected bool $load_migrations_laravel = false; protected bool $load_migrations_package = true; protected bool $load_migrations_playground = true; - /** - * Define database migrations. - * - * @api - * - * @return void - */ - protected function defineDatabaseMigrations() - { - if (! empty(env('TEST_DB_MIGRATIONS'))) { - if ($this->load_migrations_laravel) { - $this->loadMigrationsFrom(dirname(dirname(__DIR__)).'/database/migrations-laravel'); - } - if ($this->load_migrations_package) { - $this->loadMigrationsFrom(dirname(dirname(__DIR__)).'/database/migrations'); - } - if ($this->load_migrations_playground) { - $this->loadMigrationsFrom(dirname(dirname(__DIR__)).'/database/migrations-playground'); - } - } - } + protected bool $setUpUserForPlayground = false; } diff --git a/tests/Unit/PackageProviders.php b/tests/Unit/PackageProviders.php index 0dea307..982d647 100644 --- a/tests/Unit/PackageProviders.php +++ b/tests/Unit/PackageProviders.php @@ -11,6 +11,8 @@ */ trait PackageProviders { + protected string $package_providers_dir = __DIR__; + protected function getPackageProviders($app) { return [