Skip to content

Commit

Permalink
Improve consistency among payavel packages
Browse files Browse the repository at this point in the history
  • Loading branch information
r-kujawa committed Jun 27, 2024
1 parent 865cc6c commit a50797c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
32 changes: 16 additions & 16 deletions tests/Feature/Console/TestCheckoutInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public function checkout_install_command_injects_checkout_service_into_orchestra
$provider = $this->createProvider($this->checkoutConfig);
$account = $this->createAccount($this->checkoutConfig);

$checkoutServiceConfig = $this->configPath($this->checkoutConfig);
$checkoutServiceContract = $this->contractPath($this->checkoutConfig);
$fakeGateway = $this->gatewayPath($this->checkoutConfig);
$providerGateway = $this->gatewayPath($this->checkoutConfig, $provider);
$configPath = $this->configPath($this->checkoutConfig);
$contractPath = $this->contractPath($this->checkoutConfig);
$fakeGatewayPath = $this->gatewayPath($this->checkoutConfig);
$providerGatewayPath = $this->gatewayPath($this->checkoutConfig, $provider);

$ds = DIRECTORY_SEPARATOR;
$this->artisan('checkout:install')
Expand All @@ -34,30 +34,30 @@ public function checkout_install_command_injects_checkout_service_into_orchestra
->expectsQuestion("How should the {$this->checkoutConfig->name} account be named?", $account->getName())
->expectsQuestion("How should the {$this->checkoutConfig->name} account be identified?", $account->getId())
->expectsConfirmation("Would you like to add another {$this->checkoutConfig->name} account?", 'no')
->expectsOutputToContain("Config [config{$ds}{$checkoutServiceConfig->orchestration}] created successfully.")
->expectsOutputToContain("Config [config{$ds}{$checkoutServiceConfig->service}] created successfully.")
->expectsOutputToContain("Contract [app{$ds}{$checkoutServiceContract->requester}] created successfully.")
->expectsOutputToContain("Contract [app{$ds}{$checkoutServiceContract->responder}] created successfully.")
->expectsOutputToContain("Gateway [app{$ds}{$fakeGateway->request}] created successfully.")
->expectsOutputToContain("Gateway [app{$ds}{$fakeGateway->response}] created successfully.")
->expectsOutputToContain("Gateway [app{$ds}{$providerGateway->request}] created successfully.")
->expectsOutputToContain("Gateway [app{$ds}{$providerGateway->response}] created successfully.")
->expectsOutputToContain("Config [config{$ds}{$configPath->orchestration}] created successfully.")
->expectsOutputToContain("Config [config{$ds}{$configPath->service}] created successfully.")
->expectsOutputToContain("Contract [app{$ds}{$contractPath->requester}] created successfully.")
->expectsOutputToContain("Contract [app{$ds}{$contractPath->responder}] created successfully.")
->expectsOutputToContain("Gateway [app{$ds}{$fakeGatewayPath->request}] created successfully.")
->expectsOutputToContain("Gateway [app{$ds}{$fakeGatewayPath->response}] created successfully.")
->expectsOutputToContain("Gateway [app{$ds}{$providerGatewayPath->request}] created successfully.")
->expectsOutputToContain("Gateway [app{$ds}{$providerGatewayPath->response}] created successfully.")
->assertSuccessful();

$config = require(config_path($checkoutServiceConfig->service));
$serviceConfig = require(config_path($configPath->service));

$this->assertContractExists($this->checkoutConfig);
$this->assertGatewayExists($this->checkoutConfig);
$this->assertGatewayExists($this->checkoutConfig, $provider);

$this->assertEquals($provider->getId(), $config['defaults']['provider']);
$this->assertEquals($account->getId(), $config['defaults']['account']);
$this->assertEquals($provider->getId(), $serviceConfig['defaults']['provider']);
$this->assertEquals($account->getId(), $serviceConfig['defaults']['account']);

$this->makeSureProviderExists($provider);
$this->makeSureAccountExists($account);
$this->makeSureProviderIsLinkedToAccount($provider, $account);

$this->assertTrue(unlink(config_path($checkoutServiceConfig->service)));
$this->assertTrue(unlink(config_path($configPath->service)));
}

protected function makeSureProviderExists(Providable $provider)
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/Console/TestCheckoutProviderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public function checkout_provider_command_injects_checkout_service_into_orchestr
{
$provider = $this->createProvider($this->checkoutConfig);

$gateway = $this->gatewayPath($this->checkoutConfig, $provider);
$providerGatewayPath = $this->gatewayPath($this->checkoutConfig, $provider);

$ds = DIRECTORY_SEPARATOR;
$this->artisan('checkout:provider', [
'provider' => $provider->getName(),
'--id' => $provider->getId(),
])
->expectsOutputToContain("Gateway [app{$ds}{$gateway->request}] created successfully.")
->expectsOutputToContain("Gateway [app{$ds}{$gateway->response}] created successfully.")
->expectsOutputToContain("Gateway [app{$ds}{$providerGatewayPath->request}] created successfully.")
->expectsOutputToContain("Gateway [app{$ds}{$providerGatewayPath->response}] created successfully.")
->assertSuccessful();

$this->assertGatewayExists($this->checkoutConfig, $provider);
Expand Down
4 changes: 0 additions & 4 deletions tests/Unit/TestWalletModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
use Payavel\Checkout\Contracts\Billable;
use Payavel\Checkout\Models\PaymentInstrument;
use Payavel\Checkout\Models\Wallet;
use Payavel\Checkout\Tests\Models\TestAccount;
use Payavel\Checkout\Tests\Models\TestPaymentInstrument;
use Payavel\Checkout\Tests\Models\TestProvider;
use Payavel\Checkout\Tests\TestCase;
use Payavel\Checkout\Tests\User;
use Payavel\Orchestration\Contracts\Accountable;
use Payavel\Orchestration\Contracts\Providable;
use Payavel\Orchestration\Models\Account;
use Payavel\Orchestration\Models\Provider;
use Payavel\Orchestration\Fluent\ServiceConfig;
use Payavel\Orchestration\Tests\Contracts\CreatesServiceables;
use PHPUnit\Framework\Attributes\Test;
Expand Down

0 comments on commit a50797c

Please sign in to comment.