-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from OgunsakinDamilola/feat/tests-and-upgrades
wip: PHP 8, Laravel 8&9 support, test environment setup
- Loading branch information
Showing
19 changed files
with
215 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
{"version":1,"defects":{"OgunsakinDamilola\\Interswitch\\Tests\\Unit\\InterswitchPaymentModelTest::model_can_be_initiated_with_factory":4},"times":{"OgunsakinDamilola\\Interswitch\\Tests\\Unit\\InterswitchPaymentModelTest::model_can_be_initiated_with_factory":0.25}} |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
testdox="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
<php> | ||
<env name="DB_CONNECTION" value="testing" force="true"/> | ||
<env name="DB_DATABASE" value=":memory:" force="true"/> | ||
<env name="APP_ENV" value="testing" force="true"/> | ||
</php> | ||
</phpunit> |
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
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
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,34 @@ | ||
PRAGMA journal_mode = MEMORY; | ||
PRAGMA synchronous = OFF; | ||
PRAGMA foreign_keys = OFF; | ||
PRAGMA ignore_check_constraints = OFF; | ||
PRAGMA auto_vacuum = NONE; | ||
PRAGMA secure_delete = OFF; | ||
BEGIN TRANSACTION; | ||
|
||
DROP TABLE IF EXISTS `interswitch_payment`; | ||
|
||
CREATE TABLE `interswitch_payments` ( | ||
`id` INTEGER NOT NULL , | ||
`created_at` timestamp NULL DEFAULT NULL, | ||
`updated_at` timestamp NULL DEFAULT NULL, | ||
`customer_id` INTEGER NOT NULL, | ||
`customer_name` TEXT NOT NULL, | ||
`customer_email` TEXT NOT NULL, | ||
`environment` TEXT NOT NULL, | ||
`gateway` TEXT NOT NULL, | ||
`reference` TEXT NOT NULL, | ||
`amount` TEXT NOT NULL, | ||
`response_code` TEXT NOT NULL, | ||
`response_description` TEXT NULL DEFAULT NULL, | ||
`response_full` TEXT NULL DEFAULT NULL, | ||
`payment_status` TEXT NULL DEFAULT NULL, | ||
PRIMARY KEY (`id`) | ||
); | ||
|
||
|
||
COMMIT; | ||
PRAGMA ignore_check_constraints = ON; | ||
PRAGMA foreign_keys = ON; | ||
PRAGMA journal_mode = WAL; | ||
PRAGMA synchronous = NORMAL; |
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,20 @@ | ||
<?php | ||
|
||
use Faker\Generator as Faker; | ||
use OgunsakinDamilola\Interswitch\Models\InterswitchPayment; | ||
|
||
|
||
$factory->define(InterswitchPayment::class, function (Faker $faker) { | ||
return [ | ||
'customer_id' => $faker->randomNumber(1), | ||
'customer_name' => $faker->name, | ||
'customer_email' => $faker->email, | ||
'environment' => 'TEST', | ||
'gateway' => 'WEBPAY', | ||
'reference' => uniqid(), | ||
'amount' => 20000, | ||
'response_code' => '00', | ||
'response_description' => 'Success' | ||
]; | ||
}); | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class SetupDefaultTables2022 extends Migration | ||
{ | ||
|
||
public function up() | ||
{ | ||
if (!Schema::hasTable('interswitch_payments')) { | ||
DB::unprepared(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'database.sqlite')); | ||
} | ||
} | ||
|
||
public function down() | ||
{ | ||
// | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
namespace OgunsakinDamilola\Interswitch\Tests; | ||
|
||
use Illuminate\Database\Eloquent\Factory as EloquentFactory; | ||
use OgunsakinDamilola\Interswitch\InterswitchServiceProvider; | ||
use Orchestra\Testbench\TestCase as BaseTestCase; | ||
|
||
class TestCase extends BaseTestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->app->make(EloquentFactory::class)->load($this->baseDir().DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'factories'); | ||
|
||
} | ||
|
||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
InterswitchServiceProvider::class, | ||
]; | ||
} | ||
|
||
protected function getEnvironmentSetUp($app) | ||
{ | ||
include_once $this->baseDir().DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'setup_default_tables_2022.php'; | ||
|
||
(new \SetupDefaultTables2022)->up(); | ||
} | ||
|
||
private function baseDir(){ | ||
return str_replace('tests','src',__DIR__); | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
namespace OgunsakinDamilola\Interswitch\Tests\Unit; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use OgunsakinDamilola\Interswitch\Models\InterswitchPayment; | ||
use OgunsakinDamilola\Interswitch\Tests\TestCase; | ||
|
||
class InterswitchPaymentModelTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
/** @test */ | ||
public function model_can_be_initiated_with_factory() | ||
{ | ||
$model = factory(InterswitchPayment::class)->create(); | ||
|
||
$this->assertTrue($model instanceof InterswitchPayment); | ||
} | ||
} |