update: tests performance

This commit is contained in:
HDVinnie
2023-08-26 20:34:17 -04:00
parent 54c534b3d1
commit d4e6248801
8 changed files with 2520 additions and 2533 deletions

View File

@@ -54,9 +54,9 @@ jobs:
- name: Generate Application Key
run: php artisan key:generate
- name: Clear Application Cache
run: php artisan optimize:clear
run: php artisan clear:all_cache
- name: Run PHPUnit Tests
run: ./vendor/bin/pest --compact --coverage
run: ./vendor/bin/pest --compact --coverage --parallel --processes=4
env:
DB_CONNECTION: mysql
DB_PORT: ${{ job.services.mysql.ports['3306'] }}

View File

@@ -36,7 +36,7 @@ class UserFactory extends Factory
{
return [
'username' => $this->faker->unique()->userName(),
'email' => $this->faker->unique()->safeEmail(),
'email' => 'unit3d@protnmail.com',
'password' => Hash::make('password'),
'passkey' => md5(random_bytes(60)),
'group_id' => Group::factory(),

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -31,8 +31,8 @@ class DatabaseSeeder extends Seeder
CategoriesTableSeeder::class,
TypesTableSeeder::class,
ArticlesTableSeeder::class,
PermissionsTableSeeder::class,
ForumsTableSeeder::class,
PermissionsTableSeeder::class,
ChatroomTableSeeder::class,
ChatStatusSeeder::class,
BotsTableSeeder::class,

View File

@@ -42,379 +42,379 @@ class PermissionsTableSeeder extends Seeder
'id' => 1,
'forum_id' => 1,
'group_id' => 1,
'show_forum' => 0,
'read_topic' => 0,
'reply_topic' => 0,
'start_topic' => 0,
'show_forum' => false,
'read_topic' => false,
'reply_topic' => false,
'start_topic' => false,
],
[
'id' => 2,
'forum_id' => 1,
'group_id' => 2,
'show_forum' => 0,
'read_topic' => 0,
'reply_topic' => 0,
'start_topic' => 0,
'show_forum' => false,
'read_topic' => false,
'reply_topic' => false,
'start_topic' => false,
],
[
'id' => 3,
'forum_id' => 1,
'group_id' => 3,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 4,
'forum_id' => 1,
'group_id' => 4,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 5,
'forum_id' => 1,
'group_id' => 5,
'show_forum' => 0,
'read_topic' => 0,
'reply_topic' => 0,
'start_topic' => 0,
'show_forum' => false,
'read_topic' => false,
'reply_topic' => false,
'start_topic' => false,
],
[
'id' => 6,
'forum_id' => 1,
'group_id' => 6,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 7,
'forum_id' => 1,
'group_id' => 7,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 8,
'forum_id' => 1,
'group_id' => 8,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 9,
'forum_id' => 1,
'group_id' => 9,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 10,
'forum_id' => 1,
'group_id' => 10,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 11,
'forum_id' => 1,
'group_id' => 11,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 12,
'forum_id' => 1,
'group_id' => 12,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 13,
'forum_id' => 1,
'group_id' => 13,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 14,
'forum_id' => 1,
'group_id' => 14,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 15,
'forum_id' => 1,
'group_id' => 15,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 16,
'forum_id' => 1,
'group_id' => 16,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 17,
'forum_id' => 1,
'group_id' => 17,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 18,
'forum_id' => 1,
'group_id' => 18,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 19,
'forum_id' => 2,
'group_id' => 1,
'show_forum' => 0,
'read_topic' => 0,
'reply_topic' => 0,
'start_topic' => 0,
'show_forum' => false,
'read_topic' => false,
'reply_topic' => false,
'start_topic' => false,
],
[
'id' => 20,
'forum_id' => 2,
'group_id' => 2,
'show_forum' => 0,
'read_topic' => 0,
'reply_topic' => 0,
'start_topic' => 0,
'show_forum' => false,
'read_topic' => false,
'reply_topic' => false,
'start_topic' => false,
],
[
'id' => 21,
'forum_id' => 2,
'group_id' => 3,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 22,
'forum_id' => 2,
'group_id' => 4,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 23,
'forum_id' => 2,
'group_id' => 5,
'show_forum' => 0,
'read_topic' => 0,
'reply_topic' => 0,
'start_topic' => 0,
'show_forum' => false,
'read_topic' => false,
'reply_topic' => false,
'start_topic' => false,
],
[
'id' => 24,
'forum_id' => 2,
'group_id' => 6,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 25,
'forum_id' => 2,
'group_id' => 7,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 26,
'forum_id' => 2,
'group_id' => 8,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 27,
'forum_id' => 2,
'group_id' => 9,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 28,
'forum_id' => 2,
'group_id' => 10,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 29,
'forum_id' => 2,
'group_id' => 11,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 30,
'forum_id' => 2,
'group_id' => 12,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 31,
'forum_id' => 2,
'group_id' => 13,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 32,
'forum_id' => 2,
'group_id' => 14,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 33,
'forum_id' => 2,
'group_id' => 15,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 34,
'forum_id' => 2,
'group_id' => 16,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 35,
'forum_id' => 2,
'group_id' => 17,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 36,
'forum_id' => 2,
'group_id' => 18,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 37,
'forum_id' => 1,
'group_id' => 19,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 38,
'forum_id' => 2,
'group_id' => 19,
'show_forum' => 1,
'read_topic' => 1,
'reply_topic' => 1,
'start_topic' => 1,
'show_forum' => true,
'read_topic' => true,
'reply_topic' => true,
'start_topic' => true,
],
[
'id' => 39,
'forum_id' => 1,
'group_id' => 20,
'show_forum' => 0,
'read_topic' => 0,
'reply_topic' => 0,
'start_topic' => 0,
'show_forum' => false,
'read_topic' => false,
'reply_topic' => false,
'start_topic' => false,
],
[
'id' => 40,
'forum_id' => 1,
'group_id' => 21,
'show_forum' => 0,
'read_topic' => 0,
'reply_topic' => 0,
'start_topic' => 0,
'show_forum' => false,
'read_topic' => false,
'reply_topic' => false,
'start_topic' => false,
],
[
'id' => 41,
'forum_id' => 2,
'group_id' => 20,
'show_forum' => 0,
'read_topic' => 0,
'reply_topic' => 0,
'start_topic' => 0,
'show_forum' => false,
'read_topic' => false,
'reply_topic' => false,
'start_topic' => false,
],
[
'id' => 42,
'forum_id' => 2,
'group_id' => 21,
'show_forum' => 0,
'read_topic' => 0,
'reply_topic' => 0,
'start_topic' => 0,
'show_forum' => false,
'read_topic' => false,
'reply_topic' => false,
'start_topic' => false,
],
];
}

View File

@@ -4,6 +4,7 @@ namespace Tests;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Hash;
trait CreatesApplication
{
@@ -16,6 +17,9 @@ trait CreatesApplication
$app->make(Kernel::class)->bootstrap();
// Set the bcrypt hashing rounds to just 4 for testing
Hash::setRounds(4);
return $app;
}
}

View File

@@ -2,72 +2,23 @@
namespace Tests;
use AllowDynamicProperties;
use JMac\Testing\Traits\AdditionalAssertions;
use App\Console\Kernel;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\RefreshDatabaseState;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use JMac\Testing\Traits\AdditionalAssertions;
#[AllowDynamicProperties] abstract class TestCase extends BaseTestCase
abstract class TestCase extends BaseTestCase
{
use AdditionalAssertions;
use CreatesApplication;
use RefreshDatabase;
use LazilyRefreshDatabase;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->artisan('config:clear');
$this->artisan('route:clear');
$this->artisan('cache:clear');
// For LARAVEL_START used in sub-footer
if (!\defined('LARAVEL_START')) {
\define('LARAVEL_START', microtime(true));
}
}
/**
* Overrides the method in the default trait.
*
* @see https://alexvanderbist.com/posts/2019/how-migrations-might-be-slowing-down-your-laravel-tests
*/
protected function refreshTestDatabase(): void
{
if (!RefreshDatabaseState::$migrated) {
if (config('database.pristine-db-file')) {
// If a flat file is defined, load it.
$this->artisan('db:load --quiet');
$this->artisan('migrate');
} else {
// Otherwise, proceed using default strategy.
$this->artisan('migrate:fresh', [
'--drop-views' => $this->shouldDropViews(),
'--drop-types' => $this->shouldDropTypes(),
]);
}
$this->app[Kernel::class]->setArtisan(null);
RefreshDatabaseState::$migrated = true;
}
$connectionsNotToTransact = ['sqlite', 'pgsql', 'sqlsrv'];
$this->connectionsToTransact = array_keys(
array_diff_key(config('database.connections'), array_flip($connectionsNotToTransact))
);
$this->beginDatabaseTransaction();
}
}
}