Skip to content

Commit

Permalink
Fix phpunit deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
r-kujawa committed Mar 26, 2024
1 parent 81f4bac commit 46e6882
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 17 deletions.
60 changes: 60 additions & 0 deletions tests/Feature/Console/Commands/OrchestrateStubsCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace Payavel\Orchestration\Tests\Feature\Console\Commands;

use Payavel\Orchestration\Console\Commands\OrchestrateStubs;
use Payavel\Orchestration\Tests\TestCase;
use PHPUnit\Framework\Attributes\Test;

class OrchestrateStubsCommandTest extends TestCase
{
#[Test]
public function publish_stubs_command_publishes_stubs()
{
$this->artisan('orchestrate:stubs')
->expectsOutput('Successfully published stubs!')
->assertExitCode(0);

foreach(OrchestrateStubs::$baseStubs as $stub) {
$this->assertFileExists(base_path('stubs/orchestration/' . $stub . '.stub'));
}
}

#[Test]
public function publish_stubs_command_publishes_stubs_for_service()
{
$this->artisan('orchestrate:stubs', [
'--service' => 'mock',
])
->expectsOutput('Successfully published stubs!')
->assertExitCode(0);

foreach(OrchestrateStubs::$serviceSpecificStubs as $stub) {
$this->assertFileExists(base_path('stubs/orchestration/mock/' . $stub . '.stub'));
}
}

#[Test]
public function publish_stubs_command_publishes_single_stub_file()
{
$this->artisan('orchestrate:stubs', [
'stub' => $stub = $this->faker->randomElement(OrchestrateStubs::$baseStubs),
])
->expectsOutput('Successfully published stub!')
->assertExitCode(0);

$this->assertFileExists(base_path('stubs/orchestration/' . $stub . '.stub'));
}

#[Test]
public function publish_stubs_command_throws_error_when_single_stub_file_does_not_exist()
{
$this->artisan('orchestrate:stubs', [
'stub' => 'stub',
])
->expectsOutput('The stub file you wish to publish is not available.')
->assertExitCode(0);

$this->assertFileDoesNotExist(base_path('stubs/orchestration/stub.stub'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
use Payavel\Orchestration\Tests\TestCase;
use Payavel\Orchestration\Tests\Traits\AssertsGatewayExists;
use Payavel\Orchestration\Tests\Traits\CreatesServices;
use PHPUnit\Framework\Attributes\Test;

abstract class TestOrchestrateProviderCommand extends TestCase implements CreatesServiceables
{
use AssertsGatewayExists;
use CreatesServices;

/** @test */
#[Test]
public function make_payment_provider_command_will_prompt_for_missing_arguments()
{
$service = $this->createService();
Expand All @@ -32,7 +33,7 @@ public function make_payment_provider_command_will_prompt_for_missing_arguments(
$this->assertGatewayExists($provider);
}

/** @test */
#[Test]
public function make_payment_provider_command_completes_without_asking_questions_when_providing_the_arguments()
{
$provider = $this->createProvider();
Expand All @@ -47,7 +48,7 @@ public function make_payment_provider_command_completes_without_asking_questions
$this->assertGatewayExists($provider);
}

/** @test */
#[Test]
public function make_payment_provider_command_with_fake_argument_generates_fake_gateway()
{
$service = $this->createService();
Expand All @@ -62,7 +63,7 @@ public function make_payment_provider_command_with_fake_argument_generates_fake_
$this->assertGatewayExists($service);
}

/** @test */
#[Test]
public function make_provider_command_using_fake_service()
{
$this->createService();
Expand All @@ -74,7 +75,7 @@ public function make_provider_command_using_fake_service()
->assertExitCode(0);
}

/** @test */
#[Test]
public function make_provider_command_when_no_services_exist()
{
$this->artisan('orchestrate:provider')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
use Payavel\Orchestration\Tests\TestCase;
use Payavel\Orchestration\Tests\Traits\AssertsGatewayExists;
use Payavel\Orchestration\Tests\Traits\CreatesServices;
use PHPUnit\Framework\Attributes\Test;

abstract class TestOrchestrateServiceCommand extends TestCase implements CreatesServiceables
{
use AssertsGatewayExists;
use CreatesServices;

/** @test */
#[Test]
public function install_command_publishes_migration_and_generates_config_with_single_provider_and_merchant()
{
$service = $this->createService();
Expand Down Expand Up @@ -62,7 +63,7 @@ public function install_command_publishes_migration_and_generates_config_with_si
$this->assertTrue(unlink(config_path($configFile)));
}

/** @test */
#[Test]
public function install_command_publishes_migration_and_generates_config_with_multiple_providers_and_merchants()
{
$service = $this->createService();
Expand Down
5 changes: 3 additions & 2 deletions tests/Unit/ServiceConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
use Payavel\Orchestration\Service;
use Payavel\Orchestration\Tests\TestCase;
use Payavel\Orchestration\Support\ServiceConfig;
use PHPUnit\Framework\Attributes\Test;

class ServiceConfigTest extends TestCase
{
/** @test */
#[Test]
public function set_service_config_in_separate_config()
{
Config::set('orchestration.services.mock', 'fake');
Expand All @@ -21,7 +22,7 @@ public function set_service_config_in_separate_config()
$this->assertTrue(Config::get('fake.assert'));
}

/** @test */
#[Test]
public function set_service_config_in_orchestration_config()
{
Config::set('orchestration.services.mock', []);
Expand Down
17 changes: 9 additions & 8 deletions tests/Unit/TestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Payavel\Orchestration\Tests\Services\Mock\TestMockRequest;
use Payavel\Orchestration\Tests\TestCase;
use Payavel\Orchestration\Tests\Traits\CreatesServices;
use PHPUnit\Framework\Attributes\Test;

abstract class TestService extends TestCase implements CreatesServiceables
{
Expand Down Expand Up @@ -61,7 +62,7 @@ public function assertRealIsAlignedWithFake(callable $test)
$test();
}

/** @test */
#[Test]
public function set_provider_and_merchant_fluently()
{
$this->assertRealIsAlignedWithFake(function () {
Expand All @@ -81,7 +82,7 @@ public function set_provider_and_merchant_fluently()
});
}

/** @test */
#[Test]
public function setting_invalid_driver_throws_exception()
{
$this->assertRealIsAlignedWithFake(function () {
Expand All @@ -94,7 +95,7 @@ public function setting_invalid_driver_throws_exception()
});
}

/** @test */
#[Test]
public function setting_invalid_provider_throws_exception()
{
$this->assertRealIsAlignedWithFake(function () {
Expand All @@ -105,7 +106,7 @@ public function setting_invalid_provider_throws_exception()
});
}

/** @test */
#[Test]
public function setting_invalid_merchant_throws_exception()
{
$this->assertRealIsAlignedWithFake(function () {
Expand All @@ -116,7 +117,7 @@ public function setting_invalid_merchant_throws_exception()
});
}

/** @test */
#[Test]
public function setting_incompatible_merchant_provider_throws_exception()
{
$this->assertRealIsAlignedWithFake(function () {
Expand All @@ -129,7 +130,7 @@ public function setting_incompatible_merchant_provider_throws_exception()
});
}

/** @test */
#[Test]
public function resetting_service_to_default_configuration()
{
$this->assertRealIsAlignedWithFake(function () {
Expand All @@ -146,7 +147,7 @@ public function resetting_service_to_default_configuration()
});
}

/** @test */
#[Test]
public function calling_undefined_method_on_service_throws_bad_method_call_exception()
{
$undefinedMethod = 'undefined';
Expand All @@ -159,7 +160,7 @@ public function calling_undefined_method_on_service_throws_bad_method_call_excep
});
}

/** @test */
#[Test]
public function passing_additional_information_to_service_response()
{
$this->assertRealIsAlignedWithFake(function () {
Expand Down

0 comments on commit 46e6882

Please sign in to comment.