From bc12169938a4f4b9467e9512d91780b6b3b98e58 Mon Sep 17 00:00:00 2001 From: Kim Speer <93331309+Kim-the-Diamond@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:17:29 +0200 Subject: [PATCH] Feature/builder test2 (#712) * install pest and workbench * Update User.php * install pest * Fix styling * Update Pest.php * wip testing builder * Fix styling * wip tests * Fix styling * wip database connection for tests * wip testing * Update Pest.php * Fix styling * Fix styling * Update pest.yml * Update pest.yml * Update phpstan.neon.dist * Update phpstan.neon.dist * Update phpstan.neon.dist * Update pest.yml * Update pest.yml * Update pest.yml * wip workflows * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * Update pest.yml * wip testing * wip Implement arch test use App\Http\Controllers\Controller; -> use Illuminate\Routing\Controller; * let the workflow goooo * Fix styling * added brace possition * Fix styling * Update pest.yml * Update pest.yml --------- Co-authored-by: Kim-the-Diamond --- .github/workflows/pest.yml | 32 ++++++---- .phpunit.cache/test-results | 2 +- LocalValetDriver.mac.php | 2 - LocalValetDriver.win.php | 2 - composer.json | 4 -- ...2023_12_10_224905_create_breezy_tables.php | 1 - ..._12_10_233216_create_permission_tables.php | 1 - database/seeders/DatabaseSeeder.php | 2 - database/seeders/PermissionsSeeder.php | 2 - database/seeders/RolesSeeder.php | 2 - database/seeders/UsersSeeder.php | 1 - .../audit/src/Commands/InstallCommand.php | 3 - packages/builder/.github/pest.yml | 50 +++++++++++++++ packages/builder/composer.json | 46 ++++++++++++- .../database/factories/ItemFactory.php | 27 ++++++++ .../builder/src/Commands/InstallCommand.php | 3 - packages/builder/src/Models/Item.php | 9 ++- .../builder/src/Resources/ItemResource.php | 34 +++++----- .../Pages/{CreatePage.php => CreateItem.php} | 2 +- .../Pages/{EditPage.php => EditItem.php} | 2 +- .../Pages/{ListPage.php => ListItem.php} | 2 +- .../Pages/{ViewPage.php => ViewItem.php} | 2 +- packages/builder/tests/ArchTest.php | 15 +++++ .../builder/tests/Feature/ExampleTest.php | 5 ++ .../builder/tests/Feature/Item/ItemTest.php | 27 ++++++++ .../tests/Feature/Item/ListItemTest.php | 20 ++++++ packages/builder/tests/Pest.php | 47 ++++++++++++++ packages/builder/tests/TestCase.php | 21 ++++++ packages/builder/tests/Unit/ExampleTest.php | 5 ++ .../builder/workbench/app/Models/.gitkeep | 0 .../builder/workbench/app/Models/User.php | 64 +++++++++++++++++++ .../app/Providers/AdminPanelProvider.php | 63 ++++++++++++++++++ .../Providers/WorkbenchServiceProvider.php | 24 +++++++ packages/builder/workbench/bootstrap/.gitkeep | 0 .../workbench/database/factories/.gitkeep | 0 .../database/factories/UserFactory.php | 54 ++++++++++++++++ .../workbench/database/migrations/.gitkeep | 0 .../database/seeders/DatabaseSeeder.php | 23 +++++++ .../workbench/resources/views/.gitkeep | 0 packages/builder/workbench/routes/web.php | 7 ++ packages/core/src/CoreServiceProvider.php | 1 - .../Http/Controllers/Api/CoreController.php | 2 +- .../Http/Controllers/Api/ModelController.php | 2 +- .../core/src/Http/SharedHosting/Scheduler.php | 2 +- .../expiry/src/Actions/CustomExpiryAction.php | 1 - .../expiry/src/Commands/InstallCommand.php | 3 - .../Http/Controllers/Api/ExpiryController.php | 2 +- .../expiry/src/Resources/ExpiryResource.php | 1 - .../src/Http/SharedHosting/QueueWorker.php | 3 +- packages/jobs/src/Traits/FormatSeconds.php | 1 - .../src/Commands/InstallCommand.php | 2 - .../Http/Controllers/LoginLinkController.php | 2 +- .../src/Commands/InstallCommand.php | 3 - .../Controllers/NotificationController.php | 2 +- packages/page/src/Commands/InstallCommand.php | 3 - .../passkey/src/Commands/InstallCommand.php | 3 - .../src/Commands/InstallCommand.php | 3 - .../WpCommentRelationManager.php | 1 - .../WpTrainingMetaRelationManager.php | 1 - .../WpCommentRelationManager.php | 1 - .../WpPostMetaRelationManager.php | 1 - .../WpCommentRelationManager.php | 1 - .../WpPostMetaRelationManager.php | 1 - packages/press/routes/web.php | 1 - .../press/src/Commands/InstallCommand.php | 2 - .../press/src/Commands/InstallWordPress.php | 37 +++++++---- packages/press/src/Models/WpTerm.php | 2 - .../WpCommentMetaRelationManager.php | 1 - .../WpPostMetaRelationManager.php | 1 - .../WpPostMetaRelationManager.php | 1 - .../WpCommentRelationManager.php | 1 - .../WpPostMetaRelationManager.php | 1 - .../WpUserResource/Pages/CreateWpUser.php | 3 - .../WpUserMetaRelationManager.php | 1 - packages/press/src/Services/Login.php | 2 - packages/redis-model/src/Model.php | 1 - .../Passwords/DatabaseTokenRepository.php | 1 - .../security/src/Commands/InstallCommand.php | 2 - .../Passwords/PasswordResetNotification.php | 1 - .../src/Services/RequestPasswordReset.php | 1 - packages/sync/src/Commands/InstallCommand.php | 2 - .../Controllers/Api/PlatformController.php | 2 +- .../Api/PlatformSyncController.php | 3 +- .../Http/Controllers/Api/SyncController.php | 2 +- .../Http/Controllers/FileSyncController.php | 2 +- .../Controllers/SyncResponseController.php | 2 +- .../Controllers/SyncWebhookController.php | 2 +- packages/sync/src/Jobs/FileSyncJob.php | 1 - packages/sync/src/Jobs/SyncPlatformJob.php | 1 - packages/sync/src/Resources/SyncResource.php | 1 - packages/sync/src/SyncServiceProvider.php | 3 - .../trainings/src/Commands/InstallCommand.php | 2 - .../src/Jobs/SendInvitationRequests.php | 1 - .../src/Commands/InstallCommand.php | 2 - .../src/Commands/InstallCommand.php | 2 - packages/user/src/Commands/InstallCommand.php | 4 +- packages/user/src/Services/Login.php | 1 - phpstan.neon.dist | 1 + phpunit.xml | 6 ++ pint.json | 8 +++ tests/ArchTest.php | 24 +++++++ tests/Feature/MooxLoginTest.php | 27 -------- tests/Feature/PressLoginTest.php | 8 --- tests/Pest.php | 16 ++++- tests/TestCase.php | 5 ++ 105 files changed, 643 insertions(+), 192 deletions(-) create mode 100644 packages/builder/.github/pest.yml create mode 100644 packages/builder/database/factories/ItemFactory.php rename packages/builder/src/Resources/ItemResource/Pages/{CreatePage.php => CreateItem.php} (84%) rename packages/builder/src/Resources/ItemResource/Pages/{EditPage.php => EditItem.php} (91%) rename packages/builder/src/Resources/ItemResource/Pages/{ListPage.php => ListItem.php} (98%) rename packages/builder/src/Resources/ItemResource/Pages/{ViewPage.php => ViewItem.php} (96%) create mode 100644 packages/builder/tests/ArchTest.php create mode 100644 packages/builder/tests/Feature/ExampleTest.php create mode 100644 packages/builder/tests/Feature/Item/ItemTest.php create mode 100644 packages/builder/tests/Feature/Item/ListItemTest.php create mode 100644 packages/builder/tests/Pest.php create mode 100644 packages/builder/tests/TestCase.php create mode 100644 packages/builder/tests/Unit/ExampleTest.php create mode 100644 packages/builder/workbench/app/Models/.gitkeep create mode 100644 packages/builder/workbench/app/Models/User.php create mode 100644 packages/builder/workbench/app/Providers/AdminPanelProvider.php create mode 100644 packages/builder/workbench/app/Providers/WorkbenchServiceProvider.php create mode 100644 packages/builder/workbench/bootstrap/.gitkeep create mode 100644 packages/builder/workbench/database/factories/.gitkeep create mode 100644 packages/builder/workbench/database/factories/UserFactory.php create mode 100644 packages/builder/workbench/database/migrations/.gitkeep create mode 100644 packages/builder/workbench/database/seeders/DatabaseSeeder.php create mode 100644 packages/builder/workbench/resources/views/.gitkeep create mode 100644 packages/builder/workbench/routes/web.php create mode 100644 pint.json create mode 100644 tests/ArchTest.php delete mode 100644 tests/Feature/MooxLoginTest.php diff --git a/.github/workflows/pest.yml b/.github/workflows/pest.yml index dd5c89c66..67ce002ca 100644 --- a/.github/workflows/pest.yml +++ b/.github/workflows/pest.yml @@ -13,20 +13,18 @@ jobs: test: runs-on: ${{ matrix.os }} env: - DB_DATABASE: moox-test - DB_USER: user - DB_PASSWORD: secret + DB_DATABASE: testing + DB_ROOT_PASSWORD: secretroot + DB_HOST: 127.0.0.1 APP_KEY: base64:1NxfrNErQ0vo1ZnPcLeVhnE7tOZdKlKiFORzPA92krM= strategy: fail-fast: true matrix: - os: [ubuntu-latest] + os: [ubuntu-latest] php: [8.2] - laravel: [10.*, 11.*] + laravel: [11.*] stability: [prefer-lowest, prefer-stable] include: - - laravel: 10.* - testbench: 8.* - laravel: 11.* testbench: 9.* @@ -36,21 +34,22 @@ jobs: mysql: image: mysql:latest env: - MYSQL_USER: user - MYSQL_PASSWORD: secret - MYSQL_DATABASE: laravel_test + MYSQL_DATABASE: testing + MYSQL_HOST: 127.0.0.1 MYSQL_ROOT_PASSWORD: secretroot ports: - 3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 --name=mysql steps: + - name: Show Docker containers + run: docker ps -a - - name: Verfify MySQL connection + - name: Verifiy MySQL connection run: | mysql --version sudo apt-get install -y mysql-client - mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uuser -psecret -e "SHOW DATABASES" + mysql --host 127.0.0.1 --port 32768 -uroot -psecretroot -e "SHOW DATABASES" - name: Checkout code uses: actions/checkout@v4 @@ -67,7 +66,6 @@ jobs: echo "::add-matcher::${{ runner.tool_cache }}/php.json" echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Remove PHP-PSR Extension run: | sudo apt remove php8.2-psr @@ -81,3 +79,9 @@ jobs: - name: Execute tests run: vendor/bin/pest --coverage-clover clover.xml + env: + DB_PORT: ${{ job.services.mysql.ports[3306] }} + DB_HOST: 127.0.0.1 + DB_USER: root + + DB_PASSWORD: secretroot diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results index f0065e606..366e968f6 100644 --- a/.phpunit.cache/test-results +++ b/.phpunit.cache/test-results @@ -1 +1 @@ -{"version":"pest_3.0.0","defects":{"P\\Tests\\Feature\\RedirectTest::__pest_evaluable_it_will_lock_Wp":7},"times":{"P\\Tests\\Feature\\RedirectTest::__pest_evaluable_Lock_WP_config_is_true":0.001,"P\\Tests\\Feature\\RedirectTest::__pest_evaluable_it_will_lock_Wp":1.185,"Tests\\Unit\\ExampleTest::testThatTrueIsTrue":0.022,"P\\Packages\\core\\tests\\Unit\\ExampleTest::__pest_evaluable_core_example_unit":0.025,"Tests\\Feature\\LandingPageTest::testHealthyResponse":3.543,"Tests\\Feature\\LandingPageTest::testContainsWelcome":2.756,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_healthy_response":3.627,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_it_redirects_to_login":2.247,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_it_contains_Sign_in":2.539,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_healthy_response":1.604,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_it_redirects_to_login":1.734,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_it_contains_Sign_in":1.688,"P\\Packages\\core\\tests\\Feature\\ExampleTest::__pest_evaluable_core_example_feature":0}} \ No newline at end of file +{"version":"pest_3.2.4","defects":{"P\\Packages\\builder\\tests\\Feature\\Item\\ItemTest::__pest_evaluable_items_Table_exists_with_correct_columns":8,"P\\Packages\\builder\\tests\\Feature\\Item\\ItemTest::__pest_evaluable_item_can_be_manually_created":8,"P\\Packages\\builder\\tests\\Feature\\Item\\ItemTest::__pest_evaluable_item_can_be_create_with_factory":8,"P\\Packages\\builder\\tests\\Feature\\Item\\ListItemTest::__pest_evaluable_it_can_render_ItemResource":8,"P\\Packages\\builder\\tests\\Feature\\Item\\ListItemTest::__pest_evaluable_it_can_list_Items":8,"Tests\\Feature\\LandingPageTest::testHealthyResponse":8,"Tests\\Feature\\LandingPageTest::testContainsWelcome":8,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_healthy_response":8,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_it_redirects_to_login":7,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_it_contains_Sign_in":7,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_healthy_response":8,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_it_redirects_to_login":8,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_it_contains_Sign_in":8,"P\\Packages\\builder\\tests\\Feature\\ExampleTest::__pest_evaluable_example":8,"P\\Packages\\core\\tests\\Feature\\ExampleTest::__pest_evaluable_core_example_feature":8,"P\\Tests\\ArchTest::__pest_evaluable_expect__App__\u2192_toUseStrictTypes__\u2192_not_\u2192_toUse___die____dd____dump__":7,"P\\Tests\\ArchTest::__pest_evaluable_expect__App_Http__\u2192_toOnlyBeUsedIn__App_Http_":7,"P\\Tests\\ArchTest::__pest_evaluable_preset__\u2192_php_":7,"P\\Tests\\ArchTest::__pest_evaluable_preset__\u2192_security__\u2192_ignoring__md5_":7,"P\\Tests\\ArchTest::__pest_evaluable_expect__App__\u2192_toOnlyBeUsedIn__App_":7},"times":{"Tests\\Unit\\ExampleTest::testThatTrueIsTrue":0.091,"P\\Packages\\core\\tests\\Unit\\ExampleTest::__pest_evaluable_core_example_unit":0.001,"Tests\\Feature\\LandingPageTest::testHealthyResponse":0.454,"Tests\\Feature\\LandingPageTest::testContainsWelcome":0.015,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_healthy_response":0.554,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_it_redirects_to_login":1.823,"P\\Tests\\Feature\\MooxLoginTest::__pest_evaluable_it_contains_Sign_in":0.772,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_healthy_response":0.585,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_it_redirects_to_login":0.6,"P\\Tests\\Feature\\PressLoginTest::__pest_evaluable_it_contains_Sign_in":1.132,"P\\Packages\\core\\tests\\Feature\\ExampleTest::__pest_evaluable_core_example_feature":0.677,"P\\Packages\\builder\\tests\\Unit\\ExampleTest::__pest_evaluable_example":0.166,"P\\Packages\\builder\\tests\\Feature\\ExampleTest::__pest_evaluable_example":0.528,"P\\Packages\\builder\\tests\\Feature\\Item\\ItemTest::__pest_evaluable_items_Table_exists_with_correct_columns":0.551,"P\\Packages\\builder\\tests\\Feature\\Item\\ItemTest::__pest_evaluable_item_can_be_manually_created":0.596,"P\\Packages\\builder\\tests\\Feature\\Item\\ItemTest::__pest_evaluable_item_can_be_create_with_factory":0.679,"P\\Packages\\builder\\tests\\Feature\\Item\\ListItemTest::__pest_evaluable_it_can_render_ItemResource":2.094,"P\\Packages\\builder\\tests\\Feature\\Item\\ListItemTest::__pest_evaluable_it_can_list_Items":2.112,"P\\Tests\\ArchTest::__pest_evaluable_expect__App__\u2192_toUseStrictTypes__\u2192_not_\u2192_toUse___die____dd____dump__":0.699,"P\\Tests\\ArchTest::__pest_evaluable_expect__App_Models__\u2192_toBeClasses__\u2192_toExtend__Illuminate_Database_Eloquent_Model__\u2192_toOnlyBeUsedIn__App_Repositories__\u2192_ignoring__App_Models_User_":0.04,"P\\Tests\\ArchTest::__pest_evaluable_expect__App_Http__\u2192_toOnlyBeUsedIn__App_Http_":0.05,"P\\Tests\\ArchTest::__pest_evaluable_preset__\u2192_php_":0.038,"P\\Tests\\ArchTest::__pest_evaluable_preset__\u2192_security__\u2192_ignoring__md5_":0.058,"P\\Tests\\ArchTest::__pest_evaluable_expect__App__\u2192_not_\u2192_toUse___die____dd____dump__":0.641,"P\\Tests\\ArchTest::__pest_evaluable_expect__App__\u2192_toOnlyBeUsedIn__App_":0.141,"P\\Tests\\ArchTest::__pest_evaluable_expect__App__\u2192_toOnlyBeUsedIn__App__\u2192_ignoring__App_Models_User_":2.984}} \ No newline at end of file diff --git a/LocalValetDriver.mac.php b/LocalValetDriver.mac.php index 9b7e3932b..c9fefca76 100644 --- a/LocalValetDriver.mac.php +++ b/LocalValetDriver.mac.php @@ -21,9 +21,7 @@ public function frontControllerPath(string $sitePath, string $siteName, string $ $wpslug = '/wp'; if (str_contains($uri, $wpslug.'/') || str_ends_with($uri, $wpslug)) { - if (str_contains($uri, '/wp-admin')) { - if (str_ends_with($uri, '/wp-admin/') || str_ends_with($uri, '/wp-admin') || str_ends_with($uri, '/wp-admin/index.php')) { return $sitePath.$public.$wpslug.'/wp-admin/index.php'; } diff --git a/LocalValetDriver.win.php b/LocalValetDriver.win.php index 8916cebd4..4ae2f0f1e 100644 --- a/LocalValetDriver.win.php +++ b/LocalValetDriver.win.php @@ -21,9 +21,7 @@ public function frontControllerPath(string $sitePath, string $siteName, string $ $wpslug = '/wp'; if (str_contains($uri, $wpslug.'/') || str_ends_with($uri, $wpslug)) { - if (str_contains($uri, '/wp-admin')) { - if (str_ends_with($uri, '/wp-admin/') || str_ends_with($uri, '/wp-admin') || str_ends_with($uri, '/wp-admin/index.php')) { return $this->convertForWindows($sitePath.$public.$wpslug.'/wp-admin/index.php'); } diff --git a/composer.json b/composer.json index c2723215c..6b46220d7 100644 --- a/composer.json +++ b/composer.json @@ -54,15 +54,11 @@ "mockery/mockery": "^1.6.6", "nunomaduro/collision": "^8.0", "larastan/larastan": "^2.6", - "orchestra/testbench": "^9.0", "pestphp/pest": "^3.0", "pestphp/pest-plugin-laravel": "^3.0", "pestphp/pest-plugin-livewire": "^3.0", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.10", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^11.3.4", "spatie/laravel-ignition": "^2.3", "spatie/laravel-ray": "^1.33" }, diff --git a/database/migrations/2023_12_10_224905_create_breezy_tables.php b/database/migrations/2023_12_10_224905_create_breezy_tables.php index 823549537..790780e90 100644 --- a/database/migrations/2023_12_10_224905_create_breezy_tables.php +++ b/database/migrations/2023_12_10_224905_create_breezy_tables.php @@ -27,7 +27,6 @@ public function up() ->nullable(); $table->timestamps(); }); - } public function down() diff --git a/database/migrations/2023_12_10_233216_create_permission_tables.php b/database/migrations/2023_12_10_233216_create_permission_tables.php index 588ac19e3..945db38de 100644 --- a/database/migrations/2023_12_10_233216_create_permission_tables.php +++ b/database/migrations/2023_12_10_233216_create_permission_tables.php @@ -70,7 +70,6 @@ public function up(): void $table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_permission_model_type_primary'); } - }); Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) { diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 365cdd6ae..be0c245b9 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -13,7 +13,6 @@ class DatabaseSeeder extends Seeder */ public function run() { - // From the permission package, emtpy $this->call(ModelHasPermissionsSeeder::class); @@ -31,6 +30,5 @@ public function run() // From the permission package, demo data $this->call(UsersSeeder::class); - } } diff --git a/database/seeders/PermissionsSeeder.php b/database/seeders/PermissionsSeeder.php index fdedebb4e..487cfd2aa 100644 --- a/database/seeders/PermissionsSeeder.php +++ b/database/seeders/PermissionsSeeder.php @@ -14,7 +14,6 @@ class PermissionsSeeder extends Seeder */ public function run() { - Permission::create([ 'id' => 1, 'name' => 'view_blog', @@ -1222,6 +1221,5 @@ public function run() 'created_at' => '2023-12-10 23:32:42', 'updated_at' => '2023-12-10 23:32:42', ]); - } } diff --git a/database/seeders/RolesSeeder.php b/database/seeders/RolesSeeder.php index 997be350d..426c9dae6 100644 --- a/database/seeders/RolesSeeder.php +++ b/database/seeders/RolesSeeder.php @@ -14,7 +14,6 @@ class RolesSeeder extends Seeder */ public function run() { - Role::create([ 'id' => 1, 'name' => 'super_admin', @@ -30,6 +29,5 @@ public function run() 'created_at' => '2023-12-10 23:32:43', 'updated_at' => '2023-12-10 23:32:43', ]); - } } diff --git a/database/seeders/UsersSeeder.php b/database/seeders/UsersSeeder.php index c59f0024f..8f1f172ad 100644 --- a/database/seeders/UsersSeeder.php +++ b/database/seeders/UsersSeeder.php @@ -117,6 +117,5 @@ public function run() 'created_at' => '2023-12-14 08:44:35', 'updated_at' => '2023-12-14 08:44:35', ]); - } } diff --git a/packages/audit/src/Commands/InstallCommand.php b/packages/audit/src/Commands/InstallCommand.php index b60310f41..0d807cb19 100644 --- a/packages/audit/src/Commands/InstallCommand.php +++ b/packages/audit/src/Commands/InstallCommand.php @@ -163,7 +163,6 @@ public function registerPlugins(string $providerPath): void } } else { alert('There are no new plugins detected.'); - } } @@ -181,14 +180,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/builder/.github/pest.yml b/packages/builder/.github/pest.yml new file mode 100644 index 000000000..6eb376547 --- /dev/null +++ b/packages/builder/.github/pest.yml @@ -0,0 +1,50 @@ + +on: + pull_request: + branches: + - main + push: + branches: + - main + - "feature/**" + +jobs: + test: + runs-on: ${{ matrix.os }} + env: + DB_CONNECTION: sqlite + DB_DATABASE: :memory: + APP_KEY: base64:1NxfrNErQ0vo1ZnPcLeVhnE7tOZdKlKiFORzPA92krM= + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + php: [8.2] + laravel: [10.*, 11.*] + stability: [prefer-lowest, prefer-stable] + include: + - laravel: 10.* + testbench: 8.* + - laravel: 11.* + testbench: 9.* + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} + + + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.2" + coverage: none + + - name: Install dependencies + run: | + composer update + + - name: Run Pest + run: ./vendor/bin/pest diff --git a/packages/builder/composer.json b/packages/builder/composer.json index 0ceb3a9f9..41c51151c 100644 --- a/packages/builder/composer.json +++ b/packages/builder/composer.json @@ -21,7 +21,8 @@ }, "autoload": { "psr-4": { - "Moox\\Builder\\": "src" + "Moox\\Builder\\": "src", + "Moox\\Builder\\Database\\Factories\\": "database/factories" } }, "extra": { @@ -32,5 +33,46 @@ } }, "minimum-stability": "stable", - "prefer-stable": true + "prefer-stable": true, + "require-dev": { + "orchestra/testbench": "^9.5", + "pestphp/pest": "^3.2", + "pestphp/pest-plugin-livewire": "^3.0", + "pestphp/pest-plugin-laravel": "^3.0", + "ryangjchandler/blade-capture-directive": "^1.0" + }, + "autoload-dev": { + "psr-4": { + "Moox\\Builder\\Tests\\": "tests", + "Moox\\Builder\\Database\\Factories\\": "database/factories", + "Workbench\\App\\": "workbench/app/", + "Workbench\\Database\\Factories\\": "workbench/database/factories/", + "Workbench\\Database\\Seeders\\": "workbench/database/seeders/" + } + }, + "scripts": { + "post-autoload-dump": [ + "@clear", + "@prepare" + ], + "clear": "@php vendor/bin/testbench package:purge-skeleton --ansi", + "prepare": "@php vendor/bin/testbench package:discover --ansi", + "build": "@php vendor/bin/testbench workbench:build --ansi", + "serve": [ + "Composer\\Config::disableProcessTimeout", + "@build", + "@php vendor/bin/testbench serve --ansi" + ], + "lint": [ + "@php vendor/bin/phpstan analyse --verbose --ansi" + ], + "test": [ + "@php vendor/bin/phpunit" + ] + }, + "config": { + "allow-plugins": { + "pestphp/pest-plugin": true + } + } } \ No newline at end of file diff --git a/packages/builder/database/factories/ItemFactory.php b/packages/builder/database/factories/ItemFactory.php new file mode 100644 index 000000000..4f38d27b7 --- /dev/null +++ b/packages/builder/database/factories/ItemFactory.php @@ -0,0 +1,27 @@ + + */ + public function definition() + { + return [ + 'title' => $this->faker->sentence, + 'slug' => $this->faker->slug, + 'content' => $this->faker->paragraph, + 'status' => 'published', + 'type' => 'post', + ]; + } +} diff --git a/packages/builder/src/Commands/InstallCommand.php b/packages/builder/src/Commands/InstallCommand.php index 67a04d7cc..14094e55d 100644 --- a/packages/builder/src/Commands/InstallCommand.php +++ b/packages/builder/src/Commands/InstallCommand.php @@ -163,7 +163,6 @@ public function registerPlugins(string $providerPath): void } } else { alert('There are no new plugins detected.'); - } } @@ -181,14 +180,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/builder/src/Models/Item.php b/packages/builder/src/Models/Item.php index 12b21b944..685693c07 100644 --- a/packages/builder/src/Models/Item.php +++ b/packages/builder/src/Models/Item.php @@ -2,14 +2,16 @@ namespace Moox\Builder\Models; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; +use Moox\Builder\Database\Factories\ItemFactory; use Moox\Core\Traits\HasSlug; class Item extends Model { - use HasSlug, SoftDeletes; + use HasFactory, HasSlug, SoftDeletes; protected $table = 'items'; @@ -56,4 +58,9 @@ public function author(): ?BelongsTo return null; } + + protected static function newFactory() + { + return ItemFactory::new(); + } } diff --git a/packages/builder/src/Resources/ItemResource.php b/packages/builder/src/Resources/ItemResource.php index 61b8e16b0..29d7aa0ef 100644 --- a/packages/builder/src/Resources/ItemResource.php +++ b/packages/builder/src/Resources/ItemResource.php @@ -24,10 +24,10 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\SoftDeletes; use Moox\Builder\Models\Item; -use Moox\Builder\Resources\ItemResource\Pages\CreatePage; -use Moox\Builder\Resources\ItemResource\Pages\EditPage; -use Moox\Builder\Resources\ItemResource\Pages\ListPage; -use Moox\Builder\Resources\ItemResource\Pages\ViewPage; +use Moox\Builder\Resources\ItemResource\Pages\CreateItem; +use Moox\Builder\Resources\ItemResource\Pages\EditItem; +use Moox\Builder\Resources\ItemResource\Pages\ListItem; +use Moox\Builder\Resources\ItemResource\Pages\ViewItem; use Moox\Builder\Resources\ItemResource\Widgets\ItemWidgets; //use Moox\Core\Forms\Components\TitleWithSlugInput; @@ -100,16 +100,16 @@ public static function form(Form $form): Form ->button() ->extraAttributes(['class' => 'w-full']) ->action(fn ($record) => $record->restore()) - ->visible(fn ($livewire, $record) => $record && $record->trashed() && $livewire instanceof ViewPage), + ->visible(fn ($livewire, $record) => $record && $record->trashed() && $livewire instanceof ViewItem), Actions\Action::make('save') ->label(__('core::core.save')) ->color('primary') ->button() ->extraAttributes(['class' => 'w-full']) ->action(function ($livewire) { - $livewire instanceof CreatePage ? $livewire->create() : $livewire->save(); + $livewire instanceof CreateItem ? $livewire->create() : $livewire->save(); }) - ->visible(fn ($livewire) => $livewire instanceof CreatePage || $livewire instanceof EditPage), + ->visible(fn ($livewire) => $livewire instanceof CreateItem || $livewire instanceof EditItem), Actions\Action::make('publish') ->label(__('core::core.publish')) ->color('success') @@ -121,7 +121,7 @@ public static function form(Form $form): Form $data['published_at'] = now(); } $livewire->form->fill($data); - $livewire instanceof CreatePage ? $livewire->create() : $livewire->save(); + $livewire instanceof CreateItem ? $livewire->create() : $livewire->save(); }) ->hidden(fn ($livewire, $record) => $record && $record->trashed()), Actions\Action::make('saveAndCreateAnother') @@ -132,35 +132,35 @@ public static function form(Form $form): Form ->action(function ($livewire) { $livewire->saveAndCreateAnother(); }) - ->visible(fn ($livewire) => $livewire instanceof CreatePage), + ->visible(fn ($livewire) => $livewire instanceof CreateItem), Actions\Action::make('cancel') ->label(__('core::core.cancel')) ->color('secondary') ->outlined() ->extraAttributes(['class' => 'w-full']) ->url(fn () => static::getUrl('index')) - ->visible(fn ($livewire) => $livewire instanceof CreatePage), + ->visible(fn ($livewire) => $livewire instanceof CreateItem), Actions\Action::make('edit') ->label(__('core::core.edit')) ->color('primary') ->button() ->extraAttributes(['class' => 'w-full']) ->url(fn ($record) => static::getUrl('edit', ['record' => $record])) - ->visible(fn ($livewire, $record) => $livewire instanceof ViewPage && ! $record->trashed()), + ->visible(fn ($livewire, $record) => $livewire instanceof ViewItem && ! $record->trashed()), Actions\Action::make('restore') ->label(__('core::core.restore')) ->color('success') ->button() ->extraAttributes(['class' => 'w-full']) ->action(fn ($record) => $record->restore()) - ->visible(fn ($livewire, $record) => $record && $record->trashed() && $livewire instanceof EditPage), + ->visible(fn ($livewire, $record) => $record && $record->trashed() && $livewire instanceof EditItem), Actions\Action::make('delete') ->label(__('core::core.delete')) ->color('danger') ->link() ->extraAttributes(['class' => 'w-full']) ->action(fn ($record) => $record->delete()) - ->visible(fn ($livewire, $record) => $record && ! $record->trashed() && $livewire instanceof EditPage), + ->visible(fn ($livewire, $record) => $record && ! $record->trashed() && $livewire instanceof EditItem), ]), Select::make('type') ->options(static::getModel()::getTypeOptions()) @@ -279,10 +279,10 @@ public static function getRelations(): array public static function getPages(): array { return [ - 'index' => ListPage::route('/'), - 'edit' => EditPage::route('/{record}/edit'), - 'create' => CreatePage::route('/create'), - 'view' => ViewPage::route('/{record}'), + 'index' => ListItem::route('/'), + 'edit' => EditItem::route('/{record}/edit'), + 'create' => CreateItem::route('/create'), + 'view' => ViewItem::route('/{record}'), ]; } diff --git a/packages/builder/src/Resources/ItemResource/Pages/CreatePage.php b/packages/builder/src/Resources/ItemResource/Pages/CreateItem.php similarity index 84% rename from packages/builder/src/Resources/ItemResource/Pages/CreatePage.php rename to packages/builder/src/Resources/ItemResource/Pages/CreateItem.php index c1dcff92d..263ee2df8 100644 --- a/packages/builder/src/Resources/ItemResource/Pages/CreatePage.php +++ b/packages/builder/src/Resources/ItemResource/Pages/CreateItem.php @@ -5,7 +5,7 @@ use Filament\Resources\Pages\CreateRecord; use Moox\Builder\Resources\ItemResource; -class CreatePage extends CreateRecord +class CreateItem extends CreateRecord { protected static string $resource = ItemResource::class; } diff --git a/packages/builder/src/Resources/ItemResource/Pages/EditPage.php b/packages/builder/src/Resources/ItemResource/Pages/EditItem.php similarity index 91% rename from packages/builder/src/Resources/ItemResource/Pages/EditPage.php rename to packages/builder/src/Resources/ItemResource/Pages/EditItem.php index 82a27c22f..427d0f67e 100644 --- a/packages/builder/src/Resources/ItemResource/Pages/EditPage.php +++ b/packages/builder/src/Resources/ItemResource/Pages/EditItem.php @@ -6,7 +6,7 @@ use Filament\Resources\Pages\EditRecord; use Moox\Builder\Resources\ItemResource; -class EditPage extends EditRecord +class EditItem extends EditRecord { protected static string $resource = ItemResource::class; diff --git a/packages/builder/src/Resources/ItemResource/Pages/ListPage.php b/packages/builder/src/Resources/ItemResource/Pages/ListItem.php similarity index 98% rename from packages/builder/src/Resources/ItemResource/Pages/ListPage.php rename to packages/builder/src/Resources/ItemResource/Pages/ListItem.php index 3fa9cc1d2..70905d4a6 100644 --- a/packages/builder/src/Resources/ItemResource/Pages/ListPage.php +++ b/packages/builder/src/Resources/ItemResource/Pages/ListItem.php @@ -12,7 +12,7 @@ use Moox\Builder\Resources\ItemResource\Widgets\ItemWidgets; use Moox\Core\Traits\HasDynamicTabs; -class ListPage extends ListRecords +class ListItem extends ListRecords { use HasDynamicTabs; diff --git a/packages/builder/src/Resources/ItemResource/Pages/ViewPage.php b/packages/builder/src/Resources/ItemResource/Pages/ViewItem.php similarity index 96% rename from packages/builder/src/Resources/ItemResource/Pages/ViewPage.php rename to packages/builder/src/Resources/ItemResource/Pages/ViewItem.php index 2a56cba1c..e59a1ca98 100644 --- a/packages/builder/src/Resources/ItemResource/Pages/ViewPage.php +++ b/packages/builder/src/Resources/ItemResource/Pages/ViewItem.php @@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\Model; use Moox\Builder\Resources\ItemResource; -class ViewPage extends ViewRecord +class ViewItem extends ViewRecord { protected static string $resource = ItemResource::class; diff --git a/packages/builder/tests/ArchTest.php b/packages/builder/tests/ArchTest.php new file mode 100644 index 000000000..f76321f56 --- /dev/null +++ b/packages/builder/tests/ArchTest.php @@ -0,0 +1,15 @@ +expect('Moox\Builder') + ->toUseStrictTypes() + ->not->toUse(['die', 'dd', 'dump']); + +arch() + ->expect('Moox\Builder\Models') + ->toBeClasses() + ->toExtend('Illuminate\Database\Eloquent\Model') + ->toOnlyBeUsedIn('Moox\Builder'); + +arch()->preset()->php(); +arch()->preset()->security()->ignoring('md5'); diff --git a/packages/builder/tests/Feature/ExampleTest.php b/packages/builder/tests/Feature/ExampleTest.php new file mode 100644 index 000000000..61cd84c32 --- /dev/null +++ b/packages/builder/tests/Feature/ExampleTest.php @@ -0,0 +1,5 @@ +toBeTrue(); +}); diff --git a/packages/builder/tests/Feature/Item/ItemTest.php b/packages/builder/tests/Feature/Item/ItemTest.php new file mode 100644 index 000000000..7944c57fa --- /dev/null +++ b/packages/builder/tests/Feature/Item/ItemTest.php @@ -0,0 +1,27 @@ +toBeTrue(); + expect(Schema::hasColumns('items', ['id', 'title', 'slug', 'content', 'status', 'type', 'deleted_at', 'created_at', 'updated_at']))->toBeTrue(); +}); + +test('item can be manually created', function () { + $item = new Item; + $item->title = 'Test Title'; + $item->slug = 'test-title'; + $item->content = 'Test Content'; + $item->status = 'published'; + $item->type = 'default'; + $item->save(); + + expect($item->id)->not->toBeNull(); + expect($item->title)->toBe('Test Title'); +}); + +test('item can be create with factory', function () { + $items = Item::factory()->count(10)->create(); + expect($items->count())->toBe(10); +}); diff --git a/packages/builder/tests/Feature/Item/ListItemTest.php b/packages/builder/tests/Feature/Item/ListItemTest.php new file mode 100644 index 000000000..cb89fb51b --- /dev/null +++ b/packages/builder/tests/Feature/Item/ListItemTest.php @@ -0,0 +1,20 @@ +get(ItemResource::getUrl('index')) + ->assertSuccessful(); +}); + +it('can list Items', function () { + $posts = Item::factory()->count(10)->create(); + + livewire(ListItem::class) + ->assertCanSeeTableRecords($posts); +}); diff --git a/packages/builder/tests/Pest.php b/packages/builder/tests/Pest.php new file mode 100644 index 000000000..7c1359001 --- /dev/null +++ b/packages/builder/tests/Pest.php @@ -0,0 +1,47 @@ +extends(TestCase::class) + ->beforeEach(function () { + $this->artisan('migrate'); + $user = User::factory()->create(); + $this->actingAs($user); + })->afterEach(function () { + $this->artisan('db:wipe'); + $this->artisan('optimize:clear'); + })->in('Feature'); + +/* +|-------------------------------------------------------------------------- +| Expectations +|-------------------------------------------------------------------------- +| +| When you're writing tests, you often need to check that values meet certain conditions. The +| "expect()" function gives you access to a set of "expectations" methods that you can use +| to assert different things. Of course, you may extend the Expectation API at any time. +| +*/ + +/* +|-------------------------------------------------------------------------- +| Functions +|-------------------------------------------------------------------------- +| +| While Pest is very powerful out-of-the-box, you may have some testing code specific to your +| project that you don't want to repeat in every file. Here you can also expose helpers as +| global functions to help you to reduce the number of lines of code in your test files. +| +*/ diff --git a/packages/builder/tests/TestCase.php b/packages/builder/tests/TestCase.php new file mode 100644 index 000000000..976d7cda1 --- /dev/null +++ b/packages/builder/tests/TestCase.php @@ -0,0 +1,21 @@ +artisan('migrate'); + $this->actingAs(User::factory()->create()); + } + + protected function getEnvironmentSetUp($app) {} +} diff --git a/packages/builder/tests/Unit/ExampleTest.php b/packages/builder/tests/Unit/ExampleTest.php new file mode 100644 index 000000000..61cd84c32 --- /dev/null +++ b/packages/builder/tests/Unit/ExampleTest.php @@ -0,0 +1,5 @@ +toBeTrue(); +}); diff --git a/packages/builder/workbench/app/Models/.gitkeep b/packages/builder/workbench/app/Models/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/packages/builder/workbench/app/Models/User.php b/packages/builder/workbench/app/Models/User.php new file mode 100644 index 000000000..f241576b9 --- /dev/null +++ b/packages/builder/workbench/app/Models/User.php @@ -0,0 +1,64 @@ + + */ + protected $fillable = [ + 'name', + 'email', + 'password', + ]; + + /** + * The attributes that should be hidden for serialization. + * + * @var array + */ + protected $hidden = [ + 'password', + 'remember_token', + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'email_verified_at' => 'datetime', + 'password' => 'hashed', + ]; + + /** + * Determine if the user can access the Filament panel. + */ + public function canAccessPanel(Panel $panel): bool + { + return true; + } + + /** + * This method determines if the user can access the Filament panel. + * It always returns true, indicating that all users have access to the panel. + */ + protected static function newFactory() + { + return \Workbench\Database\Factories\UserFactory::new(); + } +} diff --git a/packages/builder/workbench/app/Providers/AdminPanelProvider.php b/packages/builder/workbench/app/Providers/AdminPanelProvider.php new file mode 100644 index 000000000..3a91b7496 --- /dev/null +++ b/packages/builder/workbench/app/Providers/AdminPanelProvider.php @@ -0,0 +1,63 @@ +default() + ->id('admin') + ->path('admin') + ->passwordReset() + ->login() + ->colors([ + 'primary' => Color::Amber, + ]) + ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources') + ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages') + ->pages([ + Pages\Dashboard::class, + ]) + ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets') + ->widgets([ + Widgets\AccountWidget::class, + Widgets\FilamentInfoWidget::class, + ]) + ->middleware([ + EncryptCookies::class, + AddQueuedCookiesToResponse::class, + StartSession::class, + AuthenticateSession::class, + ShareErrorsFromSession::class, + VerifyCsrfToken::class, + SubstituteBindings::class, + DisableBladeIconComponents::class, + DispatchServingFilamentEvent::class, + ]) + ->authMiddleware([ + Authenticate::class, + ]) + ->spa() + ->plugins([ + \Moox\Builder\ItemPlugin::make(), + ]); + } +} diff --git a/packages/builder/workbench/app/Providers/WorkbenchServiceProvider.php b/packages/builder/workbench/app/Providers/WorkbenchServiceProvider.php new file mode 100644 index 000000000..e8cec9c2a --- /dev/null +++ b/packages/builder/workbench/app/Providers/WorkbenchServiceProvider.php @@ -0,0 +1,24 @@ + + */ +class UserFactory extends Factory +{ + /** + * The current password being used by the factory. + */ + protected static ?string $password; + + /** + * The name of the factory's corresponding model. + * + * @var class-string + */ + protected $model = User::class; + + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'name' => fake()->name(), + 'email' => fake()->unique()->safeEmail(), + 'email_verified_at' => now(), + 'password' => static::$password ??= Hash::make('password'), + 'remember_token' => Str::random(10), + ]; + } + + /** + * Indicate that the model's email address should be unverified. + */ + public function unverified(): static + { + return $this->state(fn (array $attributes) => [ + 'email_verified_at' => null, + ]); + } +} diff --git a/packages/builder/workbench/database/migrations/.gitkeep b/packages/builder/workbench/database/migrations/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/packages/builder/workbench/database/seeders/DatabaseSeeder.php b/packages/builder/workbench/database/seeders/DatabaseSeeder.php new file mode 100644 index 000000000..ce9bd1597 --- /dev/null +++ b/packages/builder/workbench/database/seeders/DatabaseSeeder.php @@ -0,0 +1,23 @@ +create(); + + UserFactory::new()->create([ + 'name' => 'Test User', + 'email' => 'test@example.com', + ]); + } +} diff --git a/packages/builder/workbench/resources/views/.gitkeep b/packages/builder/workbench/resources/views/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/packages/builder/workbench/routes/web.php b/packages/builder/workbench/routes/web.php new file mode 100644 index 000000000..86a06c53e --- /dev/null +++ b/packages/builder/workbench/routes/web.php @@ -0,0 +1,7 @@ +getPackageNames(); foreach ($packages as $package) { diff --git a/packages/core/src/Http/Controllers/Api/CoreController.php b/packages/core/src/Http/Controllers/Api/CoreController.php index 6d21c1f1b..8602382ec 100644 --- a/packages/core/src/Http/Controllers/Api/CoreController.php +++ b/packages/core/src/Http/Controllers/Api/CoreController.php @@ -2,7 +2,7 @@ namespace Moox\Core\Http\Controllers\Api; -use App\Http\Controllers\Controller; +use Illuminate\Routing\Controller; class CoreController extends Controller { diff --git a/packages/core/src/Http/Controllers/Api/ModelController.php b/packages/core/src/Http/Controllers/Api/ModelController.php index b2fb28302..29ca99250 100644 --- a/packages/core/src/Http/Controllers/Api/ModelController.php +++ b/packages/core/src/Http/Controllers/Api/ModelController.php @@ -2,7 +2,7 @@ namespace Moox\Core\Http\Controllers\Api; -use App\Http\Controllers\Controller; +use Illuminate\Routing\Controller; class ModelController extends Controller { diff --git a/packages/core/src/Http/SharedHosting/Scheduler.php b/packages/core/src/Http/SharedHosting/Scheduler.php index 4598e9057..ce97f831e 100644 --- a/packages/core/src/Http/SharedHosting/Scheduler.php +++ b/packages/core/src/Http/SharedHosting/Scheduler.php @@ -2,7 +2,7 @@ namespace Moox\Core\Http\SharedHosting; -use App\Http\Controllers\Controller; +use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Artisan; class Scheduler extends Controller diff --git a/packages/expiry/src/Actions/CustomExpiryAction.php b/packages/expiry/src/Actions/CustomExpiryAction.php index 83249ec99..ff5957235 100644 --- a/packages/expiry/src/Actions/CustomExpiryAction.php +++ b/packages/expiry/src/Actions/CustomExpiryAction.php @@ -40,7 +40,6 @@ protected function setUp(): void } }) ->form(function ($record) { - $cycleOptions = collect(config('expiry.cycle_options'))->mapWithKeys(function ($value, $key) { return [__('core::expiry.'.$key) => $value]; }); diff --git a/packages/expiry/src/Commands/InstallCommand.php b/packages/expiry/src/Commands/InstallCommand.php index ea48d68ca..88fb50da3 100644 --- a/packages/expiry/src/Commands/InstallCommand.php +++ b/packages/expiry/src/Commands/InstallCommand.php @@ -163,7 +163,6 @@ public function registerPlugins(string $providerPath): void } } else { alert('There are no new plugins detected.'); - } } @@ -181,14 +180,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/expiry/src/Http/Controllers/Api/ExpiryController.php b/packages/expiry/src/Http/Controllers/Api/ExpiryController.php index 0ba647b30..347365cbc 100644 --- a/packages/expiry/src/Http/Controllers/Api/ExpiryController.php +++ b/packages/expiry/src/Http/Controllers/Api/ExpiryController.php @@ -2,8 +2,8 @@ namespace Moox\Expiry\Http\Controllers\Api; -use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use Illuminate\Routing\Controller; use Moox\Expiry\Models\Expiry; class ExpiryController extends Controller diff --git a/packages/expiry/src/Resources/ExpiryResource.php b/packages/expiry/src/Resources/ExpiryResource.php index 3131602c2..17de039a6 100644 --- a/packages/expiry/src/Resources/ExpiryResource.php +++ b/packages/expiry/src/Resources/ExpiryResource.php @@ -125,7 +125,6 @@ public static function table(Table $table): Table ]) ->bulkActions([DeleteBulkAction::make()]); - } public static function getRelations(): array diff --git a/packages/jobs/src/Http/SharedHosting/QueueWorker.php b/packages/jobs/src/Http/SharedHosting/QueueWorker.php index b065ac26a..ce998e6ae 100644 --- a/packages/jobs/src/Http/SharedHosting/QueueWorker.php +++ b/packages/jobs/src/Http/SharedHosting/QueueWorker.php @@ -2,7 +2,7 @@ namespace Moox\Jobs\Http\SharedHosting; -use App\Http\Controllers\Controller; +use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Artisan; class QueueWorker extends Controller @@ -37,6 +37,5 @@ public function __invoke() return 'Queue worker ran with output: '.$output; } - } } diff --git a/packages/jobs/src/Traits/FormatSeconds.php b/packages/jobs/src/Traits/FormatSeconds.php index 0ef9adcb1..9dc51d653 100644 --- a/packages/jobs/src/Traits/FormatSeconds.php +++ b/packages/jobs/src/Traits/FormatSeconds.php @@ -7,7 +7,6 @@ trait FormatSeconds { public function formatSeconds(int $seconds): string { - $days = 0; $hours = 0; $minutes = 0; diff --git a/packages/login-link/src/Commands/InstallCommand.php b/packages/login-link/src/Commands/InstallCommand.php index e4fbfe1c6..fe4d48999 100644 --- a/packages/login-link/src/Commands/InstallCommand.php +++ b/packages/login-link/src/Commands/InstallCommand.php @@ -180,14 +180,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/login-link/src/Http/Controllers/LoginLinkController.php b/packages/login-link/src/Http/Controllers/LoginLinkController.php index b68110f4c..98cfc15a1 100644 --- a/packages/login-link/src/Http/Controllers/LoginLinkController.php +++ b/packages/login-link/src/Http/Controllers/LoginLinkController.php @@ -2,10 +2,10 @@ namespace Moox\LoginLink\Http\Controllers; -use App\Http\Controllers\Controller; use App\Models\User; use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Http\Request; +use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Mail; diff --git a/packages/notifications/src/Commands/InstallCommand.php b/packages/notifications/src/Commands/InstallCommand.php index 378a70b3d..c6f9c331f 100644 --- a/packages/notifications/src/Commands/InstallCommand.php +++ b/packages/notifications/src/Commands/InstallCommand.php @@ -163,7 +163,6 @@ public function registerPlugins(string $providerPath): void } } else { alert('There are no new plugins detected.'); - } } @@ -181,14 +180,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/notifications/src/Http/Controllers/NotificationController.php b/packages/notifications/src/Http/Controllers/NotificationController.php index a67d1775c..4971bfb0c 100644 --- a/packages/notifications/src/Http/Controllers/NotificationController.php +++ b/packages/notifications/src/Http/Controllers/NotificationController.php @@ -2,7 +2,7 @@ namespace Moox\Notification\Http\Controllers; -use App\Http\Controllers\Controller; +use Illuminate\Routing\Controller; use Moox\Notification\Models\Notification; class NotificationController extends Controller diff --git a/packages/page/src/Commands/InstallCommand.php b/packages/page/src/Commands/InstallCommand.php index 69ecfcf30..b86cdccfb 100644 --- a/packages/page/src/Commands/InstallCommand.php +++ b/packages/page/src/Commands/InstallCommand.php @@ -162,7 +162,6 @@ public function registerPlugins(string $providerPath): void } } else { alert('There are no new plugins detected.'); - } } @@ -180,14 +179,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/passkey/src/Commands/InstallCommand.php b/packages/passkey/src/Commands/InstallCommand.php index 094655388..35d2553c1 100644 --- a/packages/passkey/src/Commands/InstallCommand.php +++ b/packages/passkey/src/Commands/InstallCommand.php @@ -163,7 +163,6 @@ public function registerPlugins(string $providerPath): void } } else { alert('There are no new plugins detected.'); - } } @@ -181,14 +180,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/permission/src/Commands/InstallCommand.php b/packages/permission/src/Commands/InstallCommand.php index ffa325b7a..47d32daa8 100644 --- a/packages/permission/src/Commands/InstallCommand.php +++ b/packages/permission/src/Commands/InstallCommand.php @@ -163,7 +163,6 @@ public function registerPlugins(string $providerPath): void } } else { alert('There are no new plugins detected.'); - } } @@ -181,14 +180,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/press-trainings/src/Resources/WpTrainingResource/RelationManagers/WpCommentRelationManager.php b/packages/press-trainings/src/Resources/WpTrainingResource/RelationManagers/WpCommentRelationManager.php index fffa1ec5c..a5efce39d 100644 --- a/packages/press-trainings/src/Resources/WpTrainingResource/RelationManagers/WpCommentRelationManager.php +++ b/packages/press-trainings/src/Resources/WpTrainingResource/RelationManagers/WpCommentRelationManager.php @@ -23,7 +23,6 @@ class WpCommentRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press-trainings/src/Resources/WpTrainingResource/RelationManagers/WpTrainingMetaRelationManager.php b/packages/press-trainings/src/Resources/WpTrainingResource/RelationManagers/WpTrainingMetaRelationManager.php index 1f77e1801..14815424a 100644 --- a/packages/press-trainings/src/Resources/WpTrainingResource/RelationManagers/WpTrainingMetaRelationManager.php +++ b/packages/press-trainings/src/Resources/WpTrainingResource/RelationManagers/WpTrainingMetaRelationManager.php @@ -22,7 +22,6 @@ class WpTrainingMetaRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press-trainings/src/Resources/WpTrainingsResource/RelationManagers/WpCommentRelationManager.php b/packages/press-trainings/src/Resources/WpTrainingsResource/RelationManagers/WpCommentRelationManager.php index 9d7eec3c5..beb4ada52 100644 --- a/packages/press-trainings/src/Resources/WpTrainingsResource/RelationManagers/WpCommentRelationManager.php +++ b/packages/press-trainings/src/Resources/WpTrainingsResource/RelationManagers/WpCommentRelationManager.php @@ -23,7 +23,6 @@ class WpCommentRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press-trainings/src/Resources/WpTrainingsResource/RelationManagers/WpPostMetaRelationManager.php b/packages/press-trainings/src/Resources/WpTrainingsResource/RelationManagers/WpPostMetaRelationManager.php index 507718551..f4e4dff36 100644 --- a/packages/press-trainings/src/Resources/WpTrainingsResource/RelationManagers/WpPostMetaRelationManager.php +++ b/packages/press-trainings/src/Resources/WpTrainingsResource/RelationManagers/WpPostMetaRelationManager.php @@ -22,7 +22,6 @@ class WpPostMetaRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press-wiki/src/Resources/WpWikiResource/RelationManagers/WpCommentRelationManager.php b/packages/press-wiki/src/Resources/WpWikiResource/RelationManagers/WpCommentRelationManager.php index 9d7eec3c5..beb4ada52 100644 --- a/packages/press-wiki/src/Resources/WpWikiResource/RelationManagers/WpCommentRelationManager.php +++ b/packages/press-wiki/src/Resources/WpWikiResource/RelationManagers/WpCommentRelationManager.php @@ -23,7 +23,6 @@ class WpCommentRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press-wiki/src/Resources/WpWikiResource/RelationManagers/WpPostMetaRelationManager.php b/packages/press-wiki/src/Resources/WpWikiResource/RelationManagers/WpPostMetaRelationManager.php index 507718551..f4e4dff36 100644 --- a/packages/press-wiki/src/Resources/WpWikiResource/RelationManagers/WpPostMetaRelationManager.php +++ b/packages/press-wiki/src/Resources/WpWikiResource/RelationManagers/WpPostMetaRelationManager.php @@ -22,7 +22,6 @@ class WpPostMetaRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press/routes/web.php b/packages/press/routes/web.php index 7bb67a4ac..3c8cc4bb2 100644 --- a/packages/press/routes/web.php +++ b/packages/press/routes/web.php @@ -5,7 +5,6 @@ use Illuminate\Support\Facades\Route; Route::middleware('web')->group(function () { - if (config('press.redirect_index') === true) { Route::get('/', function () { return Redirect::to('https://'.$_SERVER['SERVER_NAME'].config('press.wordpress_slug')); diff --git a/packages/press/src/Commands/InstallCommand.php b/packages/press/src/Commands/InstallCommand.php index b6692edc0..edeb1c5cd 100644 --- a/packages/press/src/Commands/InstallCommand.php +++ b/packages/press/src/Commands/InstallCommand.php @@ -117,7 +117,6 @@ public function runMigrations(): void public function registerPlugins(string $providerPath): void { - if (File::exists($providerPath)) { $content = File::get($providerPath); @@ -164,7 +163,6 @@ public function registerPlugins(string $providerPath): void } } else { alert('There are no new plugins detected.'); - } } diff --git a/packages/press/src/Commands/InstallWordPress.php b/packages/press/src/Commands/InstallWordPress.php index e61f2da2f..3e02f4f5f 100644 --- a/packages/press/src/Commands/InstallWordPress.php +++ b/packages/press/src/Commands/InstallWordPress.php @@ -249,7 +249,9 @@ public function useOrInstallWpCli(): void $this->info('Downloading wp-cli.phar...'); $downloadProcess = new \Symfony\Component\Process\Process([ - 'curl', '-O', 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar', + 'curl', + '-O', + 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar', ], base_path()); $downloadProcess->setTimeout(null); $downloadProcess->run(); @@ -264,7 +266,9 @@ public function useOrInstallWpCli(): void if (PHP_OS_FAMILY !== 'Windows') { $this->info('Making wp-cli.phar executable...'); $chmodProcess = new \Symfony\Component\Process\Process([ - 'chmod', '+x', base_path('wp-cli.phar'), + 'chmod', + '+x', + base_path('wp-cli.phar'), ]); $chmodProcess->run(); @@ -299,7 +303,9 @@ public function useOrInstallWpCli(): void } else { $this->info('Moving wp-cli.phar to /usr/local/bin/wp...'); $moveProcess = new \Symfony\Component\Process\Process([ - 'mv', base_path('wp-cli.phar'), '/usr/local/bin/wp', + 'mv', + base_path('wp-cli.phar'), + '/usr/local/bin/wp', ]); $moveProcess->run(); @@ -337,7 +343,9 @@ public function wpInstall(): void warning('Please make sure to save this password as it will not be shown again.'); $command = [ - 'wp', 'core', 'install', + 'wp', + 'core', + 'install', '--url='.$siteUrl, '--title='.$siteTitle, '--admin_user='.$adminUser, @@ -372,7 +380,10 @@ protected function installAndActivateDefaultTheme(string $fullWpPath): void $this->info('Ensuring a default theme is installed and activated...'); $checkThemeProcess = new \Symfony\Component\Process\Process([ - 'wp', 'theme', 'is-installed', 'twentytwentyfour', + 'wp', + 'theme', + 'is-installed', + 'twentytwentyfour', ], $fullWpPath); $checkThemeProcess->run(); @@ -380,7 +391,11 @@ protected function installAndActivateDefaultTheme(string $fullWpPath): void $this->info('Default theme twentytwentyfour is not installed. Installing it now...'); $installThemeProcess = new \Symfony\Component\Process\Process([ - 'wp', 'theme', 'install', 'twentytwentyfour', '--activate', + 'wp', + 'theme', + 'install', + 'twentytwentyfour', + '--activate', ], $fullWpPath); $installThemeProcess->setTimeout(null); $installThemeProcess->run(); @@ -462,13 +477,13 @@ protected function generateSecurePassword(): string $all = $lowercase.$uppercase.$numbers.$special; $password = ''; - $password .= $lowercase[rand(0, strlen($lowercase) - 1)]; - $password .= $uppercase[rand(0, strlen($uppercase) - 1)]; - $password .= $numbers[rand(0, strlen($numbers) - 1)]; - $password .= $special[rand(0, strlen($special) - 1)]; + $password .= $lowercase[random_int(0, strlen($lowercase) - 1)]; + $password .= $uppercase[random_int(0, strlen($uppercase) - 1)]; + $password .= $numbers[random_int(0, strlen($numbers) - 1)]; + $password .= $special[random_int(0, strlen($special) - 1)]; for ($i = 0; $i < $length - 4; $i++) { - $password .= $all[rand(0, strlen($all) - 1)]; + $password .= $all[random_int(0, strlen($all) - 1)]; } return str_shuffle($password); diff --git a/packages/press/src/Models/WpTerm.php b/packages/press/src/Models/WpTerm.php index 4c3083d2a..5e6cbd9b2 100644 --- a/packages/press/src/Models/WpTerm.php +++ b/packages/press/src/Models/WpTerm.php @@ -51,7 +51,6 @@ public static function boot() parent::boot(); static::created(function ($wpTerm) { - $taxonomy = $wpTerm->taxonomy; $description = $wpTerm->getRequestData('description') ?? ''; $parent = $wpTerm->getRequestData('parent') ?? 0; @@ -66,7 +65,6 @@ public static function boot() }); static::updated(function ($wpTerm) { - $taxonomy = $wpTerm->taxonomy; $description = $wpTerm->getRequestData('description') ?? $wpTerm->getOriginal('description') ?? ''; $parent = $wpTerm->getRequestData('parent') ?? $wpTerm->getOriginal('parent') ?? 0; diff --git a/packages/press/src/Resources/WpCommentResource/RelationManagers/WpCommentMetaRelationManager.php b/packages/press/src/Resources/WpCommentResource/RelationManagers/WpCommentMetaRelationManager.php index 2b985d1e5..26f98fce7 100644 --- a/packages/press/src/Resources/WpCommentResource/RelationManagers/WpCommentMetaRelationManager.php +++ b/packages/press/src/Resources/WpCommentResource/RelationManagers/WpCommentMetaRelationManager.php @@ -22,7 +22,6 @@ class WpCommentMetaRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press/src/Resources/WpMediaResource/RelationManagers/WpPostMetaRelationManager.php b/packages/press/src/Resources/WpMediaResource/RelationManagers/WpPostMetaRelationManager.php index 2799fc610..77cc31837 100644 --- a/packages/press/src/Resources/WpMediaResource/RelationManagers/WpPostMetaRelationManager.php +++ b/packages/press/src/Resources/WpMediaResource/RelationManagers/WpPostMetaRelationManager.php @@ -22,7 +22,6 @@ class WpPostMetaRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press/src/Resources/WpPageResource/RelationManagers/WpPostMetaRelationManager.php b/packages/press/src/Resources/WpPageResource/RelationManagers/WpPostMetaRelationManager.php index 2d18b4cd8..1a952fa7e 100644 --- a/packages/press/src/Resources/WpPageResource/RelationManagers/WpPostMetaRelationManager.php +++ b/packages/press/src/Resources/WpPageResource/RelationManagers/WpPostMetaRelationManager.php @@ -22,7 +22,6 @@ class WpPostMetaRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press/src/Resources/WpPostResource/RelationManagers/WpCommentRelationManager.php b/packages/press/src/Resources/WpPostResource/RelationManagers/WpCommentRelationManager.php index e38a042da..87394e4e6 100644 --- a/packages/press/src/Resources/WpPostResource/RelationManagers/WpCommentRelationManager.php +++ b/packages/press/src/Resources/WpPostResource/RelationManagers/WpCommentRelationManager.php @@ -23,7 +23,6 @@ class WpCommentRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press/src/Resources/WpPostResource/RelationManagers/WpPostMetaRelationManager.php b/packages/press/src/Resources/WpPostResource/RelationManagers/WpPostMetaRelationManager.php index 536159341..e17722873 100644 --- a/packages/press/src/Resources/WpPostResource/RelationManagers/WpPostMetaRelationManager.php +++ b/packages/press/src/Resources/WpPostResource/RelationManagers/WpPostMetaRelationManager.php @@ -22,7 +22,6 @@ class WpPostMetaRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press/src/Resources/WpUserResource/Pages/CreateWpUser.php b/packages/press/src/Resources/WpUserResource/Pages/CreateWpUser.php index 19ab8ff01..bde4648fd 100644 --- a/packages/press/src/Resources/WpUserResource/Pages/CreateWpUser.php +++ b/packages/press/src/Resources/WpUserResource/Pages/CreateWpUser.php @@ -23,7 +23,6 @@ public function afterCreate(): void $attachmentId = null; if ($temporaryFilePath) { - $mimeTypes = new MimeTypes; $mimeType = $mimeTypes->guessMimeType(storage_path('app/'.$temporaryFilePath)); @@ -84,7 +83,6 @@ public function afterCreate(): void $attachmentId = $postId; Storage::delete($temporaryFilePath); - } $metaDataConfig = config('press.default_user_meta'); @@ -107,6 +105,5 @@ public function afterCreate(): void ); } } - } } diff --git a/packages/press/src/Resources/WpUserResource/RelationManagers/WpUserMetaRelationManager.php b/packages/press/src/Resources/WpUserResource/RelationManagers/WpUserMetaRelationManager.php index f467199da..04673e5cc 100644 --- a/packages/press/src/Resources/WpUserResource/RelationManagers/WpUserMetaRelationManager.php +++ b/packages/press/src/Resources/WpUserResource/RelationManagers/WpUserMetaRelationManager.php @@ -22,7 +22,6 @@ class WpUserMetaRelationManager extends RelationManager public function form(Form $form): Form { - return $form->schema([ Section::make()->schema([ Grid::make(['default' => 0])->schema([ diff --git a/packages/press/src/Services/Login.php b/packages/press/src/Services/Login.php index d4d8f8bfe..d5c726400 100644 --- a/packages/press/src/Services/Login.php +++ b/packages/press/src/Services/Login.php @@ -174,7 +174,6 @@ public function authenticate(): Redirector|RedirectResponse|LoginResponse|null } else { return redirect('https://'.$_SERVER['SERVER_NAME'].config('press.wordpress_slug').'/wp-login.php?auth_token='.$token.$redirectParam); } - } else { return app(LoginResponse::class); } @@ -282,7 +281,6 @@ private function isWhitelisted(): bool $ipWhiteList = config('press.ip_whitelist'); if (isset($ipWhiteList) && ! empty($ipWhiteList)) { - if (is_array($ipWhiteList) && in_array($ipAddress, $ipWhiteList)) { return true; } diff --git a/packages/redis-model/src/Model.php b/packages/redis-model/src/Model.php index a824cb279..db2fce477 100644 --- a/packages/redis-model/src/Model.php +++ b/packages/redis-model/src/Model.php @@ -405,7 +405,6 @@ public function fill(array $attributes) if ($this->isFillable($key)) { $this->setAttribute($key, $value); } elseif ($totallyGuarded) { - throw new MassAssignmentException(sprintf( 'Add [%s] to fillable property to allow mass assignment on [%s].', $key, get_class($this) diff --git a/packages/security/src/Auth/Passwords/DatabaseTokenRepository.php b/packages/security/src/Auth/Passwords/DatabaseTokenRepository.php index 0f8905941..d960e62fd 100644 --- a/packages/security/src/Auth/Passwords/DatabaseTokenRepository.php +++ b/packages/security/src/Auth/Passwords/DatabaseTokenRepository.php @@ -63,7 +63,6 @@ public function delete(CanResetPasswordContract $user) ->where('email', $email) ->where('user_type', $userType) ->delete(); - } /** diff --git a/packages/security/src/Commands/InstallCommand.php b/packages/security/src/Commands/InstallCommand.php index f0a3ee860..6e9d13a32 100644 --- a/packages/security/src/Commands/InstallCommand.php +++ b/packages/security/src/Commands/InstallCommand.php @@ -180,14 +180,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/security/src/Notifications/Passwords/PasswordResetNotification.php b/packages/security/src/Notifications/Passwords/PasswordResetNotification.php index 21e96496e..2d6bdc307 100644 --- a/packages/security/src/Notifications/Passwords/PasswordResetNotification.php +++ b/packages/security/src/Notifications/Passwords/PasswordResetNotification.php @@ -30,7 +30,6 @@ public function __construct($token) public function via($notifiable): array { - return ['mail']; } diff --git a/packages/security/src/Services/RequestPasswordReset.php b/packages/security/src/Services/RequestPasswordReset.php index b8561d93d..700836b2c 100644 --- a/packages/security/src/Services/RequestPasswordReset.php +++ b/packages/security/src/Services/RequestPasswordReset.php @@ -81,7 +81,6 @@ function (CanResetPassword $user, string $token): void { $notification = new PasswordResetNotification($token); $user->notify($notification); - }, ); diff --git a/packages/sync/src/Commands/InstallCommand.php b/packages/sync/src/Commands/InstallCommand.php index 27a2c2ec9..7cc7881da 100644 --- a/packages/sync/src/Commands/InstallCommand.php +++ b/packages/sync/src/Commands/InstallCommand.php @@ -179,14 +179,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/sync/src/Http/Controllers/Api/PlatformController.php b/packages/sync/src/Http/Controllers/Api/PlatformController.php index da10a8c5b..ba1f1ff0f 100644 --- a/packages/sync/src/Http/Controllers/Api/PlatformController.php +++ b/packages/sync/src/Http/Controllers/Api/PlatformController.php @@ -2,8 +2,8 @@ namespace Moox\Sync\Http\Controllers\Api; -use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use Illuminate\Routing\Controller; use Moox\Sync\Http\Resources\PlatformResource; use Moox\Sync\Http\Resources\SyncResource; use Moox\Sync\Models\Platform; diff --git a/packages/sync/src/Http/Controllers/Api/PlatformSyncController.php b/packages/sync/src/Http/Controllers/Api/PlatformSyncController.php index 66864706b..41bb9a31d 100644 --- a/packages/sync/src/Http/Controllers/Api/PlatformSyncController.php +++ b/packages/sync/src/Http/Controllers/Api/PlatformSyncController.php @@ -2,7 +2,7 @@ namespace Moox\Sync\Http\Controllers\Api; -use App\Http\Controllers\Controller; +use Illuminate\Routing\Controller; use Moox\Sync\Http\Resources\SyncResource; use Moox\Sync\Models\Sync; @@ -10,7 +10,6 @@ class PlatformSyncController extends Controller { public function index($platformId) { - $syncs = Sync::whereHas('sourcePlatform', function ($query) use ($platformId) { $query->where('id', $platformId); })->with(['sourcePlatform', 'targetPlatform'])->get(); diff --git a/packages/sync/src/Http/Controllers/Api/SyncController.php b/packages/sync/src/Http/Controllers/Api/SyncController.php index 393021d22..d780dc89f 100644 --- a/packages/sync/src/Http/Controllers/Api/SyncController.php +++ b/packages/sync/src/Http/Controllers/Api/SyncController.php @@ -2,8 +2,8 @@ namespace Moox\Sync\Http\Controllers\Api; -use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use Illuminate\Routing\Controller; use Moox\Sync\Http\Resources\SyncResource; use Moox\Sync\Models\Sync; diff --git a/packages/sync/src/Http/Controllers/FileSyncController.php b/packages/sync/src/Http/Controllers/FileSyncController.php index b49636de1..7a010a79b 100644 --- a/packages/sync/src/Http/Controllers/FileSyncController.php +++ b/packages/sync/src/Http/Controllers/FileSyncController.php @@ -2,8 +2,8 @@ namespace Moox\Sync\Http\Controllers; -use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Validator; use Moox\Core\Traits\LogLevel; diff --git a/packages/sync/src/Http/Controllers/SyncResponseController.php b/packages/sync/src/Http/Controllers/SyncResponseController.php index aba8f7742..fcd54169f 100644 --- a/packages/sync/src/Http/Controllers/SyncResponseController.php +++ b/packages/sync/src/Http/Controllers/SyncResponseController.php @@ -2,8 +2,8 @@ namespace Moox\Sync\Http\Controllers; -use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use Illuminate\Routing\Controller; use Moox\Core\Traits\LogLevel; use Moox\Sync\Jobs\FileSyncJob; use Moox\Sync\Models\Platform; diff --git a/packages/sync/src/Http/Controllers/SyncWebhookController.php b/packages/sync/src/Http/Controllers/SyncWebhookController.php index 911bbca40..37d830df6 100644 --- a/packages/sync/src/Http/Controllers/SyncWebhookController.php +++ b/packages/sync/src/Http/Controllers/SyncWebhookController.php @@ -2,8 +2,8 @@ namespace Moox\Sync\Http\Controllers; -use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Storage; use Moox\Core\Traits\LogLevel; diff --git a/packages/sync/src/Jobs/FileSyncJob.php b/packages/sync/src/Jobs/FileSyncJob.php index 20d62e689..b180e0e90 100644 --- a/packages/sync/src/Jobs/FileSyncJob.php +++ b/packages/sync/src/Jobs/FileSyncJob.php @@ -56,7 +56,6 @@ public function handle() } $this->syncFile(); - } catch (\Exception $e) { Log::error('File sync failed', [ 'model_class' => $this->modelClass, diff --git a/packages/sync/src/Jobs/SyncPlatformJob.php b/packages/sync/src/Jobs/SyncPlatformJob.php index f4bb99425..aea38c862 100644 --- a/packages/sync/src/Jobs/SyncPlatformJob.php +++ b/packages/sync/src/Jobs/SyncPlatformJob.php @@ -54,7 +54,6 @@ protected function syncPlatform(Platform $platform) ]); $this->sendWebhook($platform, $targetPlatform); - } catch (\Exception $e) { $this->logDebug('Error syncing platform', [ 'source' => $this->currentPlatform->id, diff --git a/packages/sync/src/Resources/SyncResource.php b/packages/sync/src/Resources/SyncResource.php index 460b2447b..e2ff94637 100644 --- a/packages/sync/src/Resources/SyncResource.php +++ b/packages/sync/src/Resources/SyncResource.php @@ -97,7 +97,6 @@ private static function fetchModelsFromApi(string $apiUrl, Platform $platform): } return array_filter(array_flip($options)); // Remove any null values - } catch (\Exception $e) { Notification::make() ->title('API Error') diff --git a/packages/sync/src/SyncServiceProvider.php b/packages/sync/src/SyncServiceProvider.php index 6ebbe0d59..518793f57 100644 --- a/packages/sync/src/SyncServiceProvider.php +++ b/packages/sync/src/SyncServiceProvider.php @@ -57,7 +57,6 @@ protected function registerSyncPlatformJob(): void if ($syncPlatformJobConfig['enabled']) { $this->app->booted(function () use ($syncPlatformJobConfig) { - $this->logDebug('Moox Sync: Registering sync platform job'); $schedule = $this->app->make(Schedule::class); @@ -72,7 +71,6 @@ protected function registerSyncBackupJob(): void if ($syncBackupJobConfig['enabled']) { $this->app->booted(function () use ($syncBackupJobConfig) { - $this->logDebug('Moox Sync: Registering sync backup job'); $schedule = $this->app->make(Schedule::class); @@ -86,7 +84,6 @@ protected function registerSyncEloquentListener(): void $syncEloquentListenerConfig = Config::get('sync.sync_eloquent_listener'); if ($syncEloquentListenerConfig['enabled']) { - $this->logInfo('Moox Sync: Registering sync eloquent listener'); $syncListener = $this->app->make(SyncListener::class); diff --git a/packages/trainings/src/Commands/InstallCommand.php b/packages/trainings/src/Commands/InstallCommand.php index 8623b5f85..38820d62c 100644 --- a/packages/trainings/src/Commands/InstallCommand.php +++ b/packages/trainings/src/Commands/InstallCommand.php @@ -180,14 +180,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/trainings/src/Jobs/SendInvitationRequests.php b/packages/trainings/src/Jobs/SendInvitationRequests.php index ad2a07bde..bf219a3c2 100644 --- a/packages/trainings/src/Jobs/SendInvitationRequests.php +++ b/packages/trainings/src/Jobs/SendInvitationRequests.php @@ -56,7 +56,6 @@ public function handle() $this->setProgress(10); foreach ($invitationRequests as $invitationRequest) { - $training = Training::find($invitationRequest->training_id); $cycle = $training->cycle; diff --git a/packages/user-device/src/Commands/InstallCommand.php b/packages/user-device/src/Commands/InstallCommand.php index 9561cb99b..dbc2d8254 100644 --- a/packages/user-device/src/Commands/InstallCommand.php +++ b/packages/user-device/src/Commands/InstallCommand.php @@ -180,14 +180,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/user-session/src/Commands/InstallCommand.php b/packages/user-session/src/Commands/InstallCommand.php index 45bc3d34e..17606f0e8 100644 --- a/packages/user-session/src/Commands/InstallCommand.php +++ b/packages/user-session/src/Commands/InstallCommand.php @@ -184,14 +184,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/user/src/Commands/InstallCommand.php b/packages/user/src/Commands/InstallCommand.php index 7bc61fd5f..34b2b70cb 100644 --- a/packages/user/src/Commands/InstallCommand.php +++ b/packages/user/src/Commands/InstallCommand.php @@ -140,7 +140,7 @@ public function customizeFilament(): void if (isset($translations['nav']['group'])) { $translations['nav']['group'] = 'Moox User'; $outputPath = $file->getPathname(); - $content = "info("Updated {$file->getFilename()} in {$localePath}"); } @@ -215,14 +215,12 @@ public function getPanelProviderPath(): string|array options: [...$providerNames], default: [$providerNames[0]], ); - } if (count($providers) == 1) { $providerPath .= '/'.$providers[0]->getBasename(); } return $providerPath; - } public function sayGoodbye(): void diff --git a/packages/user/src/Services/Login.php b/packages/user/src/Services/Login.php index 82d011846..0046b3bb1 100644 --- a/packages/user/src/Services/Login.php +++ b/packages/user/src/Services/Login.php @@ -249,7 +249,6 @@ private function isWhitelisted(): bool $ipWhiteList = config('user.ip_whitelist'); if (isset($ipWhiteList) && ! empty($ipWhiteList)) { - if (is_array($ipWhiteList) && in_array($ipAddress, $ipWhiteList)) { return true; } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c5b49d597..8fcd466be 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -11,4 +11,5 @@ parameters: - 'packages/*/vendor/*' - 'packages/press/wordpress/*' - 'packages/redis-model' + - 'packages/*/tests/*' tmpDir: build/phpstan diff --git a/phpunit.xml b/phpunit.xml index 021c5c6f4..5dfadaa7d 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,12 +9,18 @@ ./tests/Feature ./packages/*/tests/Feature + + ./tests + + + + diff --git a/pint.json b/pint.json new file mode 100644 index 000000000..e22c13a07 --- /dev/null +++ b/pint.json @@ -0,0 +1,8 @@ +{ + "preset": "laravel", + "rules": { + "braces": { + "position_after_functions_and_oop_constructs": "next" + } + } +} \ No newline at end of file diff --git a/tests/ArchTest.php b/tests/ArchTest.php new file mode 100644 index 000000000..50889278c --- /dev/null +++ b/tests/ArchTest.php @@ -0,0 +1,24 @@ +expect('App') + ->not->toUse(['die', 'dd', 'dump']); + +arch() + ->expect('App') + ->toOnlyBeUsedIn('App') + ->ignoring('App\Models\User'); + +arch() + ->expect('App\Models') + ->toBeClasses() + ->toExtend('Illuminate\Database\Eloquent\Model') + ->toOnlyBeUsedIn('App\Repositories') + ->ignoring('App\Models\User'); + +arch() + ->expect('App\Http') + ->toOnlyBeUsedIn('App\Http'); + +//arch()->preset()->php(); +//arch()->preset()->security()->ignoring('md5'); diff --git a/tests/Feature/MooxLoginTest.php b/tests/Feature/MooxLoginTest.php deleted file mode 100644 index 622e2eb6f..000000000 --- a/tests/Feature/MooxLoginTest.php +++ /dev/null @@ -1,27 +0,0 @@ -get('/'); - - $response->assertStatus(200); -}); - -it('redirects to login', function () { - $response = $this->get('/moox'); - - $response->assertRedirect('moox/login'); -}); - -it('contains Sign in', function () { - $response = $this->get('/moox/login'); - - $response->assertSee('Sign in'); -}); diff --git a/tests/Feature/PressLoginTest.php b/tests/Feature/PressLoginTest.php index 45333db0c..fa40da5fb 100644 --- a/tests/Feature/PressLoginTest.php +++ b/tests/Feature/PressLoginTest.php @@ -1,14 +1,6 @@ get('/'); $response->assertStatus(200); diff --git a/tests/Pest.php b/tests/Pest.php index 5d3a73b9d..4e4d0b325 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,5 +1,7 @@ in('Feature'); +uses(Tests\TestCase::class) + ->beforeEach(function () { + $this->artisan('migrate'); + $user = new User; + $user->name = 'Test User'; + $user->email = 'test@example.com'; + $user->password = bcrypt('password'); + $user->save(); + $this->actingAs($user); + })->afterEach(function () { + $this->artisan('db:wipe'); + $this->artisan('optimize:clear'); + })->in('Feature', '../packages/*/tests/Feature'); /* |-------------------------------------------------------------------------- diff --git a/tests/TestCase.php b/tests/TestCase.php index 2932d4a69..e75380461 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,4 +7,9 @@ abstract class TestCase extends BaseTestCase { use CreatesApplication; + + protected function setUp(): void + { + parent::setUp(); + } }