Skip to content

Commit

Permalink
Feature/builder test2 (#713)
Browse files Browse the repository at this point in the history
* 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

* Delete moox-workflow.json

* Update pest.yml

* Update pest.yml

* Update pest.yml

---------

Co-authored-by: Kim-the-Diamond <Kim-the-Diamond@users.noreply.github.com>
  • Loading branch information
Kim-the-Diamond and Kim-the-Diamond authored Oct 1, 2024
1 parent 16a61ae commit c307e9d
Show file tree
Hide file tree
Showing 106 changed files with 626 additions and 210 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/pest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ jobs:
matrix:
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.*

Expand All @@ -51,7 +49,6 @@ jobs:
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"
- name: Checkout code
uses: actions/checkout@v4

Expand All @@ -66,16 +63,12 @@ jobs:
run: |
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
- name: Install dependencies
run: |
composer update
- name: List Installed Dependencies
run: composer show -D

Expand Down
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -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}}
{"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}}
2 changes: 0 additions & 2 deletions LocalValetDriver.mac.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
2 changes: 0 additions & 2 deletions LocalValetDriver.win.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
4 changes: 0 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function up()
->nullable();
$table->timestamps();
});

}

public function down()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{

// From the permission package, emtpy
$this->call(ModelHasPermissionsSeeder::class);

Expand All @@ -31,6 +30,5 @@ public function run()

// From the permission package, demo data
$this->call(UsersSeeder::class);

}
}
2 changes: 0 additions & 2 deletions database/seeders/PermissionsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class PermissionsSeeder extends Seeder
*/
public function run()
{

Permission::create([
'id' => 1,
'name' => 'view_blog',
Expand Down Expand Up @@ -1222,6 +1221,5 @@ public function run()
'created_at' => '2023-12-10 23:32:42',
'updated_at' => '2023-12-10 23:32:42',
]);

}
}
2 changes: 0 additions & 2 deletions database/seeders/RolesSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class RolesSeeder extends Seeder
*/
public function run()
{

Role::create([
'id' => 1,
'name' => 'super_admin',
Expand All @@ -30,6 +29,5 @@ public function run()
'created_at' => '2023-12-10 23:32:43',
'updated_at' => '2023-12-10 23:32:43',
]);

}
}
1 change: 0 additions & 1 deletion database/seeders/UsersSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,5 @@ public function run()
'created_at' => '2023-12-14 08:44:35',
'updated_at' => '2023-12-14 08:44:35',
]);

}
}
24 changes: 0 additions & 24 deletions moox-workflow.json

This file was deleted.

3 changes: 0 additions & 3 deletions packages/audit/src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public function registerPlugins(string $providerPath): void
}
} else {
alert('There are no new plugins detected.');

}
}

Expand All @@ -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
Expand Down
50 changes: 50 additions & 0 deletions packages/builder/.github/pest.yml
Original file line number Diff line number Diff line change
@@ -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
46 changes: 44 additions & 2 deletions packages/builder/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
},
"autoload": {
"psr-4": {
"Moox\\Builder\\": "src"
"Moox\\Builder\\": "src",
"Moox\\Builder\\Database\\Factories\\": "database/factories"
}
},
"extra": {
Expand All @@ -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
}
}
}
27 changes: 27 additions & 0 deletions packages/builder/database/factories/ItemFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Moox\Builder\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Moox\Builder\Models\Item;

class ItemFactory extends Factory
{
protected $model = Item::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'title' => $this->faker->sentence,
'slug' => $this->faker->slug,
'content' => $this->faker->paragraph,
'status' => 'published',
'type' => 'post',
];
}
}
3 changes: 0 additions & 3 deletions packages/builder/src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public function registerPlugins(string $providerPath): void
}
} else {
alert('There are no new plugins detected.');

}
}

Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion packages/builder/src/Models/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -56,4 +58,9 @@ public function author(): ?BelongsTo

return null;
}

protected static function newFactory()
{
return ItemFactory::new();
}
}
Loading

0 comments on commit c307e9d

Please sign in to comment.