Skip to content

Develop #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ jobs:
- name: Execute tests
env:
DB_PASSWORD: root
run: vendor/bin/pest --ci
run: vendor/bin/pest
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ coverage
docs
phpunit.xml
phpstan.neon
testbench.yaml
vendor
node_modules
2 changes: 1 addition & 1 deletion canvas.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
preset: package

namespace: Soap\WorkflowStorage
user-auth-model: App\Models\User
user-auth-model:

paths:
src: src
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"autoload-dev": {
"psr-4": {
"Soap\\WorkflowStorage\\Tests\\": "tests/",
"Soap\\WorkflowStorage\\Tests\\Database\\Factories\\": "tests/database/factories/",
"Workbench\\App\\": "workbench/app/"
"Workbench\\App\\": "workbench/app/",
"Workbench\\Database\\Factories\\": "workbench/database/factories/"
}
},
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions src/WorkflowStorageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public function configurePackage(Package $package): void
->name('laravel-workflow-storage')
->hasConfigFile()
->hasMigrations([
'create_workflows_table',
'create_workflow_states_table',
'create_workflow_transitions_table',
'create_workflow_state_transitions_table',
'01_create_workflows_table',
'02_create_workflow_states_table',
'03_create_workflow_transitions_table',
'04_create_workflow_state_transitions_table',
])
->hasCommand(WorkflowStorageListCommand::class);
}
Expand Down
22 changes: 22 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
providers:
# - Workbench\App\Providers\WorkbenchServiceProvider

migrations:
- workbench/database/migrations

seeders:
- Workbench\Database\Seeders\DatabaseSeeder

workbench:
start: '/'
install: true
health: false
discovers:
web: true
api: false
commands: false
components: false
views: false
build: []
assets: []
sync: []
30 changes: 19 additions & 11 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,33 @@
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Str;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase as Orchestra;
use Soap\WorkflowStorage\WorkflowStorageServiceProvider;

use function Orchestra\Testbench\workbench_path;

class TestCase extends Orchestra
{
use RefreshDatabase;
use WithWorkbench;

protected function setUp(): void
{
parent::setUp();

Factory::guessFactoryNamesUsing(function (string $modelName) {
if (Str::startsWith($modelName, 'Soap\\WorkflowStorage\\Tests\\Models\\')) {
if (Str::startsWith($modelName, 'Workbench\\App\\Models\\')) {
// Factories within the tests directory
return 'Soap\\WorkflowStorage\\Tests\\Database\\Factories\\'.class_basename($modelName).'Factory';
return 'Workbench\\Database\\Factories\\'.class_basename($modelName).'Factory';
}

// Factories within the package directory
return 'Soap\\WorkflowStorage\\Database\\Factories\\'.class_basename($modelName).'Factory';

});
$this->artisan('vendor:publish --tag="workflow-storage-migrations"');
$this->loadMigrationsFrom(__DIR__.'/database/migrations'); // load the test migrations
//$this->loadMigrationsFrom(__DIR__.'/../database/migrations'); // load the package migrations

$this->loadMigrationsFrom(__DIR__.'/../database/migrations'); // load the package migrations
}

protected function getPackageProviders($app)
Expand All @@ -38,12 +41,17 @@ protected function getPackageProviders($app)
];
}

public function getEnvironmentSetUp($app)
{
public function getEnvironmentSetUp($app) {}

//include_once __DIR__.'/database/migrations/01_20240912_create_users_table.php';
//(new \CreateUsersTable())->up();
//include_once __DIR__.'/database/migrations/02_20240912_create_orders_table.php';
//(new \CreateOrdersTable())->up();
/**
* Define database migrations.
*
* @return void
*/
protected function defineDatabaseMigrations()
{
$this->loadMigrationsFrom(
workbench_path('database/migrations')
);
}
}
2 changes: 1 addition & 1 deletion tests/Unit/UserTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Soap\WorkflowStorage\Tests\Models\User;
use Workbench\App\Models\User;

beforeEach(function () {});

Expand Down
21 changes: 0 additions & 21 deletions tests/database/migrations/01_20240912_create_users_table.php

This file was deleted.

3 changes: 2 additions & 1 deletion tests/Models/Order.php → workbench/app/Models/Order.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace Soap\WorkflowStorage\Tests\Models;
namespace Workbench\App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Workbench\AppModels\User;
use ZeroDaHero\LaravelWorkflow\Traits\WorkflowTrait;

class Order extends Model
Expand Down
2 changes: 1 addition & 1 deletion tests/Models/User.php → workbench/app/Models/User.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Soap\WorkflowStorage\Tests\Models;
namespace Workbench\App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Soap\WorkflowStorage\Tests\Database\Factories;
namespace Workbench\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Soap\WorkflowStorage\Tests\Models\Order;
use Workbench\App\Models\Order;

class OrderFactory extends Factory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Soap\WorkflowStorage\Tests\Database\Factories;
namespace Workbench\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Foundation\Auth\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Soap\WorkflowStorage\Tests\Models\User;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
Expand Down