Skip to content

Commit

Permalink
Rename $checkoutService to $checkoutConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
r-kujawa committed Jun 27, 2024
1 parent aec82bd commit c78f78c
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ class ConfigCheckoutInstallCommandTest extends TestCheckoutInstallCommand

protected function makeSureProviderExists(Providable $provider)
{
$config = require(config_path(Str::slug($this->checkoutService->id) . '.php'));
$config = require(config_path(Str::slug($this->checkoutConfig->id) . '.php'));

$this->assertIsArray($config['providers']);
$this->assertIsArray($config['providers'][$provider->getId()]);
$this->assertEquals(
'App\\Services\\' . Str::studly($this->checkoutService->id) . '\\' . Str::studly($provider->getId()) . Str::studly($this->checkoutService->id) . 'Request',
'App\\Services\\' . Str::studly($this->checkoutConfig->id) . '\\' . Str::studly($provider->getId()) . Str::studly($this->checkoutConfig->id) . 'Request',
$config['providers'][$provider->getId()]['gateway']
);
}

protected function makeSureAccountExists(Accountable $account)
{
$config = require(config_path(Str::slug($this->checkoutService->id) . '.php'));
$config = require(config_path(Str::slug($this->checkoutConfig->id) . '.php'));

$this->assertIsArray($config['accounts']);
$this->assertIsArray($config['accounts'][$account->getId()]);
Expand All @@ -37,7 +37,7 @@ protected function makeSureAccountExists(Accountable $account)

protected function makeSureProviderIsLinkedToAccount(Providable $provider, Accountable $account)
{
$config = require(config_path(Str::slug($this->checkoutService->id) . '.php'));
$config = require(config_path(Str::slug($this->checkoutConfig->id) . '.php'));

$this->assertIsArray($config['accounts'][$account->getId()]['providers'][$provider->getId()]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function makeSureProviderExists(Providable $provider)

$this->assertNotNull($provider);
$this->assertEquals(
'App\\Services\\' . Str::studly($this->checkoutService->id) . '\\' . Str::studly($provider->getId()) . Str::studly($this->checkoutService->id) . 'Request',
'App\\Services\\' . Str::studly($this->checkoutConfig->id) . '\\' . Str::studly($provider->getId()) . Str::studly($this->checkoutConfig->id) . 'Request',
$provider->gateway
);
}
Expand Down Expand Up @@ -62,8 +62,8 @@ private function migrate()
return;
}

Account::where('service_id', $this->checkoutService->id)->delete();
Provider::where('service_id', $this->checkoutService->id)->delete();
Account::where('service_id', $this->checkoutConfig->id)->delete();
Provider::where('service_id', $this->checkoutConfig->id)->delete();

$this->artisan('migrate');

Expand Down
32 changes: 16 additions & 16 deletions tests/Feature/Console/Commands/TestCheckoutInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ abstract class TestCheckoutInstallCommand extends TestCase implements CreatesSer
#[Test]
public function checkout_install_command_injects_checkout_service_into_orchestrate_service_command()
{
$provider = $this->createProvider($this->checkoutService);
$account = $this->createAccount($this->checkoutService);
$provider = $this->createProvider($this->checkoutConfig);
$account = $this->createAccount($this->checkoutConfig);

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

$ds = DIRECTORY_SEPARATOR;
$this->artisan('checkout:install')
->expectsQuestion("Choose a driver for the {$this->checkoutService->name} service.", Config::get('orchestration.defaults.driver'))
->expectsQuestion("How should the {$this->checkoutService->name} provider be named?", $provider->getName())
->expectsQuestion("How should the {$this->checkoutService->name} provider be identified?", $provider->getId())
->expectsConfirmation("Would you like to add another {$this->checkoutService->name} provider?", 'no')
->expectsQuestion("How should the {$this->checkoutService->name} account be named?", $account->getName())
->expectsQuestion("How should the {$this->checkoutService->name} account be identified?", $account->getId())
->expectsConfirmation("Would you like to add another {$this->checkoutService->name} account?", 'no')
->expectsQuestion("Choose a driver for the {$this->checkoutConfig->name} service.", Config::get('orchestration.defaults.driver'))
->expectsQuestion("How should the {$this->checkoutConfig->name} provider be named?", $provider->getName())
->expectsQuestion("How should the {$this->checkoutConfig->name} provider be identified?", $provider->getId())
->expectsConfirmation("Would you like to add another {$this->checkoutConfig->name} provider?", 'no')
->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.")
Expand All @@ -46,9 +46,9 @@ public function checkout_install_command_injects_checkout_service_into_orchestra

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

$this->assertContractExists($this->checkoutService);
$this->assertGatewayExists($this->checkoutService);
$this->assertGatewayExists($this->checkoutService, $provider);
$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']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ abstract class TestCheckoutProviderCommand extends TestCase implements CreatesSe
#[Test]
public function checkout_provider_command_injects_checkout_service_into_orchestrate_provider_command()
{
$provider = $this->createProvider($this->checkoutService);
$provider = $this->createProvider($this->checkoutConfig);

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

$ds = DIRECTORY_SEPARATOR;
$this->artisan('checkout:provider', [
Expand All @@ -27,6 +27,6 @@ public function checkout_provider_command_injects_checkout_service_into_orchestr
->expectsOutputToContain("Gateway [app{$ds}{$gateway->response}] created successfully.")
->assertSuccessful();

$this->assertGatewayExists($this->checkoutService, $provider);
$this->assertGatewayExists($this->checkoutConfig, $provider);
}
}
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TestCase extends \Payavel\Orchestration\Tests\TestCase
{
use CreatesServices;

protected ServiceConfig $checkoutService;
protected ServiceConfig $checkoutConfig;

protected function getPackageProviders($app)
{
Expand Down Expand Up @@ -42,7 +42,7 @@ protected function setUp(): void
{
parent::setUp();

$this->checkoutService = $this->createServiceConfig([
$this->checkoutConfig = $this->createServiceConfig([
'name' => 'Checkout',
'id' => 'checkout',
]);
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Database/PaymentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class PaymentModelTest extends TestPaymentModel
public function retrieve_payment_provider()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
];

$paymentWithProvider = Payment::factory()->create($usingServiceables);
Expand All @@ -38,8 +38,8 @@ public function retrieve_payment_provider()
public function retrieve_payment_account()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
];

$paymentWithAccount = Payment::factory()->create($usingServiceables);
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Database/WalletModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class WalletModelTest extends TestWalletModel
public function retrieve_wallet_provider()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
];

$walletWithProvider = Wallet::factory()->create($usingServiceables);
Expand All @@ -38,8 +38,8 @@ public function retrieve_wallet_provider()
public function retrieve_wallet_account()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
];

$walletWithAccount = Wallet::factory()->create($usingServiceables);
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/TestBillableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ public function retrieve_billable_wallets()
$this->assertEmpty($billable->wallets);

$billableWith2Wallets = User::factory()->has(Wallet::factory()->count(2)->sequence(fn () => [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
]))->create();
$this->assertCount(2, $billableWith2Wallets->wallets);
$this->assertContainsOnlyInstancesOf(Wallet::class, $billableWith2Wallets->wallets);

ServiceConfig::find('checkout')->set('models.'.Wallet::class, TestWallet::class);
$billableWith3OverriddenWallets = User::factory()->has(Wallet::factory()->count(3)->sequence(fn () => [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
]))->create();
$this->assertCount(3, $billableWith3OverriddenWallets->wallets);
$this->assertContainsOnlyInstancesOf(TestWallet::class, $billableWith3OverriddenWallets->wallets);
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/TestCheckoutGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ protected function setUp(): void
{
parent::setUp();

$provider = $this->createProvider($this->checkoutService, [
$provider = $this->createProvider($this->checkoutConfig, [
'gateway' => TestCheckoutRequest::class,
]);

$account = $this->createAccount($this->checkoutService);
$account = $this->createAccount($this->checkoutConfig);

$this->linkAccountToProvider($account, $provider);

$this->setDefaultsForService($this->checkoutService, $account, $provider);
$this->setDefaultsForService($this->checkoutConfig, $account, $provider);
}

#[Test]
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/TestDisputeModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ abstract class TestDisputeModel extends TestCase implements CreatesServiceables
public function retrieve_dispute_payment()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getID(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getID(),
];

$disputeWithPayment = Dispute::factory()->for(Payment::factory()->create($usingServiceables))->create();
Expand All @@ -34,8 +34,8 @@ public function retrieve_dispute_payment()
public function retrieve_dispute_transaction_events()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getID(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getID(),
];

$dispute = Dispute::factory()->for(Payment::factory()->create($usingServiceables))->create();
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/TestPaymentInstrumentModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ abstract class TestPaymentInstrumentModel extends TestCase implements CreatesSer
public function retrieve_payment_instrument_wallet()
{
$wallet = Wallet::factory()->create([
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
]);

$paymentInstrumentWithWallet = PaymentInstrument::factory()->for($wallet)->create();
Expand All @@ -36,8 +36,8 @@ public function retrieve_payment_instrument_wallet()
public function retrieve_payment_instrument_type()
{
$wallet = Wallet::factory()->create([
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
]);

$paymentInstrumentWithType = PaymentInstrument::factory()->for($wallet)->create();
Expand All @@ -52,8 +52,8 @@ public function retrieve_payment_instrument_type()
public function retrieve_payment_instrument_payments()
{
$wallet = Wallet::factory()->create([
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
]);

$paymentInstrument = PaymentInstrument::factory()->for($wallet)->create();
Expand Down
24 changes: 12 additions & 12 deletions tests/Unit/TestPaymentModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ abstract class TestPaymentModel extends TestCase implements CreatesServiceables
public function retrieve_payment_rail()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
];

$paymentWithRail = Payment::factory()->create($usingServiceables);
Expand All @@ -40,8 +40,8 @@ public function retrieve_payment_rail()
public function retrieve_payment_instrument()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
];

$payment = Payment::factory()->create($usingServiceables);
Expand All @@ -59,8 +59,8 @@ public function retrieve_payment_instrument()
public function retrieve_payment_events()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
];

$payment = Payment::factory()->create($usingServiceables);
Expand All @@ -80,8 +80,8 @@ public function retrieve_payment_events()
public function retrieve_payment_transaction_events()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
];

$payment = Payment::factory()->create($usingServiceables);
Expand All @@ -101,8 +101,8 @@ public function retrieve_payment_transaction_events()
public function retrieve_payment_providable()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
];

$payment = Payment::factory()->create($usingServiceables);
Expand All @@ -113,8 +113,8 @@ public function retrieve_payment_providable()
public function retrieve_payment_accountable()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
];

$payment = Payment::factory()->create($usingServiceables);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/TestPaymentRailModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public function retrieve_payment_rail_type()
public function retrieve_payment_rail_payments()
{
$usingServiceables = [
'provider_id' => $this->createProvider($this->checkoutService)->getId(),
'account_id' => $this->createAccount($this->checkoutService)->getId(),
'provider_id' => $this->createProvider($this->checkoutConfig)->getId(),
'account_id' => $this->createAccount($this->checkoutConfig)->getId(),
];

$paymentRail = PaymentRail::factory()->create();
Expand Down
Loading

0 comments on commit c78f78c

Please sign in to comment.