Skip to content
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

[2.x] Prepare package for foundational usage. #62

Merged
merged 4 commits into from
Apr 19, 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
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"autoload": {
"psr-4": {
"Payavel\\Orchestration\\": "src/",
"Payavel\\Orchestration\\Database\\Factories\\": "database/factories/",
"Payavel\\Orchestration\\Tests\\Traits\\": "tests/Traits"
"Payavel\\Orchestration\\Database\\Factories\\": "database/factories/"
}
},
"autoload-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateBaseOrchestrationTables extends Migration
{
return new class () extends Migration {
/**
* Run the migrations.
*
Expand Down Expand Up @@ -54,4 +53,4 @@ public function down()
Schema::dropIfExists('accounts');
Schema::dropIfExists('providers');
}
}
};
7 changes: 4 additions & 3 deletions src/Console/Commands/OrchestrateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ class OrchestrateProvider extends Command
* @var string
*/
protected $signature = 'orchestrate:provider
{provider? : The provider}
{--service= : The service}
{provider? : The provider name}
{--id= : The provider ID}
{--service= : The service ID}
{--fake : Generates a gateway to be used for testing purposes}';

/**
Expand Down Expand Up @@ -89,7 +90,7 @@ protected function setProperties()

$this->name = trim($this->argument('provider') ?? $this->askName('provider'));

$this->id = $this->askId('provider', $this->name);
$this->id = $this->option('id') ?? $this->askId('provider', $this->name);

return true;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Console/Commands/OrchestrateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ class OrchestrateService extends Command
* @var string
*/
protected $signature = 'orchestrate:service
{service? : The service}';
{service? : The service name}
{--id= : The service ID }';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Install a new service within the application.';
protected $description = 'Install a new service into the application.';

/**
* The serviceable to be saved.
Expand Down Expand Up @@ -163,7 +164,7 @@ protected function setService()
{
$this->service = new Service([
'name' => $name = trim($this->argument('service') ?? $this->askName('service')),
'id' => $this->askId('service', $name),
'id' => $this->option('id') ?? $this->askId('service', $name),
]);
}

Expand Down
2 changes: 0 additions & 2 deletions src/ServiceResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Payavel\Orchestration\Traits\SimulatesAttributes;
use Payavel\Orchestration\Traits\ThrowsRuntimeException;

use function PHPUnit\Framework\isEmpty;

abstract class ServiceResponse
{
use SimulatesAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public function orchestrate_provider_command_completes_without_asking_questions_
$gateway = $this->gatewayPath($provider);

$this->artisan('orchestrate:provider', [
'provider' => $provider->getId(),
'provider' => $provider->getName(),
'--id' => $provider->getId(),
'--service' => $provider->getService()->getId(),
])
->expectsOutputToContain("Gateway [app/{$gateway->request}] created successfully.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Payavel\Orchestration\Tests\Feature\Console\Commands;

use Illuminate\Support\Facades\Config;
use Illuminate\Support\Str;
use Payavel\Orchestration\Contracts\Accountable;
use Payavel\Orchestration\Contracts\Providable;
use Payavel\Orchestration\Contracts\Serviceable;
Expand All @@ -30,9 +29,10 @@ public function install_command_publishes_migration_and_generates_config_with_si
$fakeGateway = $this->gatewayPath($service);
$providerGateway = $this->gatewayPath($provider);

$this->artisan('orchestrate:service')
->expectsQuestion('How should the service be named?', $service->getName())
->expectsQuestion('How should the service be identified?', $service->getId())
$this->artisan('orchestrate:service', [
'service' => $service->getName(),
'--id' => $service->getId(),
])
->expectsQuestion("Choose a driver for the {$service->getName()} service.", Config::get('orchestration.defaults.driver'))
->expectsQuestion("How should the {$service->getName()} provider be named?", $provider->getName())
->expectsQuestion("How should the {$service->getName()} provider be identified?", $provider->getId())
Expand Down
Loading