-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Payavel\Checkout\Tests\Feature\Console\Commands; | ||
|
||
use Illuminate\Support\Str; | ||
use Payavel\Checkout\Tests\TestCase; | ||
use Payavel\Serviceable\Service; | ||
use Payavel\Serviceable\Tests\Traits\AssertGatewayExists; | ||
use Payavel\Serviceable\Tests\Traits\CreateServiceables; | ||
|
||
class InstallCommandTest extends TestCase | ||
{ | ||
use AssertGatewayExists, | ||
CreateServiceables; | ||
|
||
/** @test */ | ||
public function install_command_defaults_to_checkout_service() | ||
{ | ||
$service = Service::find('checkout'); | ||
$lowerCaseService = Str::lower($service->getName()); | ||
|
||
$provider = $this->createProvider($service); | ||
|
||
$merchant = $this->createMerchant($service); | ||
|
||
$this->artisan('checkout:install') | ||
->expectsQuestion('What ' . $lowerCaseService . ' provider would you like to add?', $provider->getName()) | ||
->expectsQuestion('How would you like to identify the ' . $provider->getName() . ' ' . $lowerCaseService . ' provider?', $provider->getId()) | ||
->expectsConfirmation('Would you like to add another ' . $lowerCaseService . ' provider?', 'no') | ||
->expectsQuestion('What ' . $lowerCaseService . ' merchant would you like to add?', $merchant->getName()) | ||
->expectsQuestion('How would you like to identify the ' . $merchant->getName() . ' ' . $lowerCaseService . ' merchant?', $merchant->getId()) | ||
->expectsConfirmation('Would you like to add another ' . $lowerCaseService . ' merchant?', 'no') | ||
->expectsOutput('The ' . $lowerCaseService . ' config has been successfully generated.') | ||
->expectsOutput('Fake ' . $lowerCaseService . ' gateway generated successfully!') | ||
->expectsOutput($provider->getName() . ' ' . $lowerCaseService . ' gateway generated successfully!') | ||
->assertExitCode(0); | ||
|
||
$configFile = Str::slug($service->getName()) . '.php'; | ||
|
||
$this->assertFileExists(config_path($configFile)); | ||
$config = require(config_path($configFile)); | ||
|
||
$this->assertGatewayExists($service); | ||
|
||
$this->assertEquals($provider->getId(), $config['defaults']['provider']); | ||
$this->assertEquals($merchant->getId(), $config['defaults']['merchant']); | ||
$this->assertEquals($provider->getName(), $config['providers'][$provider->getId()]['name']); | ||
$this->assertEquals($merchant->getName(), $config['merchants'][$merchant->getId()]['name']); | ||
$this->assertNotNull($config['merchants'][$merchant->getId()]['providers'][$provider->getId()]); | ||
|
||
$this->assertGatewayExists($provider); | ||
|
||
$this->assertTrue(unlink(config_path($configFile))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters