Subiendo proyecto completo sin restricciones de git ignore
This commit is contained in:
5
vendor/sebacarrasco93/laravel-payku/tests/ExampleTest.php
vendored
Normal file
5
vendor/sebacarrasco93/laravel-payku/tests/ExampleTest.php
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
test('example', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
35
vendor/sebacarrasco93/laravel-payku/tests/Feature/CanGetRoutesTest.php
vendored
Normal file
35
vendor/sebacarrasco93/laravel-payku/tests/Feature/CanGetRoutesTest.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace SebaCarrasco93\LaravelPayku\Tests\Feature;
|
||||
|
||||
use SebaCarrasco93\LaravelPayku\Tests\TestCase;
|
||||
|
||||
class CanGetRoutesTest extends TestCase
|
||||
{
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->fillApiKeys();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_create_an_order() {
|
||||
$this->markTestIncomplete();
|
||||
$this->withoutExceptionHanpdling();
|
||||
|
||||
$order = [
|
||||
'email' => 'seba@sextanet.cl',
|
||||
'order' => 'AAA',
|
||||
'subject' => 'Test',
|
||||
'amount' => '1000',
|
||||
'payment' => '1',
|
||||
'urlreturn' => route('payku.return', 'AAA'),
|
||||
'urlnotify' => route('payku.notify', 'AAA'),
|
||||
];
|
||||
|
||||
$this->post(route('payku.create', $order))->getContent();
|
||||
|
||||
$this->post(route('payku.create', $order))->assertSuccessful();
|
||||
}
|
||||
}
|
||||
61
vendor/sebacarrasco93/laravel-payku/tests/Feature/CanHandleAPIResponsesTest.php
vendored
Normal file
61
vendor/sebacarrasco93/laravel-payku/tests/Feature/CanHandleAPIResponsesTest.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace SebaCarrasco93\LaravelPayku\Tests\Feature;
|
||||
|
||||
use SebaCarrasco93\LaravelPayku\LaravelPayku;
|
||||
use SebaCarrasco93\LaravelPayku\Tests\SimulateResponses;
|
||||
use SebaCarrasco93\LaravelPayku\Tests\TestCase;
|
||||
|
||||
class CanHandleAPIResponsesTest extends TestCase
|
||||
{
|
||||
use SimulateResponses;
|
||||
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->fillApiKeys();
|
||||
|
||||
$this->laravelPayku = new LaravelPayku();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_handle_when_it_has_register_status() {
|
||||
$response = $this->registerResponse();
|
||||
|
||||
$this->laravelPayku->handleAPIResponse($response);
|
||||
$this->assertEquals('register', $this->laravelPayku->status);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_handle_when_it_has_pending_status() {
|
||||
$response = $this->pendingResponse();
|
||||
|
||||
$this->laravelPayku->handleAPIResponse($response);
|
||||
$this->assertEquals('pending', $this->laravelPayku->status);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_handle_when_it_has_failed_status() {
|
||||
$response = $this->failedResponse();
|
||||
|
||||
$this->laravelPayku->handleAPIResponse($response);
|
||||
$this->assertEquals('failed', $this->laravelPayku->status);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_handle_when_it_has_success_status() {
|
||||
$response = $this->successResponse();
|
||||
|
||||
$this->laravelPayku->handleAPIResponse($response);
|
||||
$this->assertEquals('success', $this->laravelPayku->status);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_handle_an_error_when_it_has_an_invalid_status() {
|
||||
$this->expectException(\Exception::class);
|
||||
$response = $this->invalidResponse();
|
||||
|
||||
$this->laravelPayku->handleAPIResponse($response);
|
||||
}
|
||||
}
|
||||
59
vendor/sebacarrasco93/laravel-payku/tests/Feature/CanSaveAPIResponsesTest.php
vendored
Normal file
59
vendor/sebacarrasco93/laravel-payku/tests/Feature/CanSaveAPIResponsesTest.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace SebaCarrasco93\LaravelPayku\Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use SebaCarrasco93\LaravelPayku\LaravelPayku;
|
||||
use SebaCarrasco93\LaravelPayku\Models\PaykuTransaction;
|
||||
use SebaCarrasco93\LaravelPayku\Tests\SimulateResponses;
|
||||
use SebaCarrasco93\LaravelPayku\Tests\TestCase;
|
||||
|
||||
class CanSaveAPIResponsesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
use SimulateResponses;
|
||||
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->fillApiKeys();
|
||||
|
||||
$this->laravelPayku = new LaravelPayku();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_save_when_it_has_register_status() {
|
||||
$this->laravelPayku->saveAPIResponse($this->registerResponse());
|
||||
|
||||
$registerStatusTransaction = PaykuTransaction::first();
|
||||
|
||||
$this->assertNotNull($registerStatusTransaction->id);
|
||||
$this->assertNotNull($registerStatusTransaction->status);
|
||||
$this->assertNotNull($registerStatusTransaction->url);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_save_when_it_has_register_status_and_passes_to_success_status() {
|
||||
$this->laravelPayku->saveAPIResponse($this->registerResponse());
|
||||
$registerStatusTransaction = PaykuTransaction::first();
|
||||
|
||||
$this->assertNull($registerStatusTransaction->order);
|
||||
$this->assertNull($registerStatusTransaction->email);
|
||||
$this->assertNull($registerStatusTransaction->subject);
|
||||
$this->assertNull($registerStatusTransaction->amount);
|
||||
|
||||
$this->laravelPayku->saveAPIResponse($this->successResponse());
|
||||
$registerStatusTransaction = PaykuTransaction::first();
|
||||
|
||||
$this->assertCount(1, PaykuTransaction::get());
|
||||
|
||||
$this->assertNotNull($registerStatusTransaction->id);
|
||||
$this->assertNotNull($registerStatusTransaction->status);
|
||||
$this->assertNotNull($registerStatusTransaction->order);
|
||||
$this->assertNotNull($registerStatusTransaction->email);
|
||||
$this->assertNotNull($registerStatusTransaction->subject);
|
||||
$this->assertNotNull($registerStatusTransaction->url);
|
||||
$this->assertNotNull($registerStatusTransaction->amount);
|
||||
}
|
||||
}
|
||||
85
vendor/sebacarrasco93/laravel-payku/tests/Feature/WorkWithValidOrInvalidResponsesTest.php
vendored
Normal file
85
vendor/sebacarrasco93/laravel-payku/tests/Feature/WorkWithValidOrInvalidResponsesTest.php
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace SebaCarrasco93\LaravelPayku\Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use SebaCarrasco93\LaravelPayku\LaravelPayku;
|
||||
use SebaCarrasco93\LaravelPayku\Models\PaykuPayment;
|
||||
use SebaCarrasco93\LaravelPayku\Models\PaykuTransaction;
|
||||
use SebaCarrasco93\LaravelPayku\Tests\SimulateResponses;
|
||||
use SebaCarrasco93\LaravelPayku\Tests\TestCase;
|
||||
|
||||
class WorkWithValidOrInvalidResponsesTest extends TestCase
|
||||
{
|
||||
use SimulateResponses;
|
||||
use RefreshDatabase;
|
||||
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->fillApiKeys();
|
||||
|
||||
$this->laravelPayku = new LaravelPayku();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_knows_when_it_has_an_valid_api_response() {
|
||||
$response = $this->successResponse();
|
||||
|
||||
$this->laravelPayku->handleAPIResponse($response);
|
||||
$this->assertTrue($this->laravelPayku->hasValidResponse);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_knows_when_it_does_not_have_an_valid_api_response() {
|
||||
$this->expectException(\Exception::class);
|
||||
|
||||
$response = $this->invalidResponse();
|
||||
|
||||
$this->laravelPayku->handleAPIResponse($response);
|
||||
$this->assertFalse($this->laravelPayku->hasValidResponse);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_create_the_pending_response_in_transactions() {
|
||||
$response = $this->pendingResponse();
|
||||
|
||||
$this->laravelPayku->saveAPIResponse($response);
|
||||
|
||||
$this->assertCount(1, PaykuTransaction::get());
|
||||
$this->assertCount(0, PaykuPayment::get());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_cannot_create_the_failed_response_in_transactions() {
|
||||
$this->expectException(\Exception::class);
|
||||
|
||||
$response = $this->failedResponse();
|
||||
|
||||
$this->laravelPayku->saveAPIResponse($response);
|
||||
|
||||
$this->assertCount(0, PaykuTransaction::get());
|
||||
$this->assertCount(0, PaykuPayment::get());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_create_the_register_response_in_transactions() {
|
||||
$response = $this->registerResponse();
|
||||
|
||||
$this->laravelPayku->saveAPIResponse($response);
|
||||
|
||||
$this->assertCount(1, PaykuTransaction::get());
|
||||
$this->assertCount(0, PaykuPayment::get());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_create_the_success_response_in_transactions() {
|
||||
$response = $this->successResponse();
|
||||
|
||||
$this->laravelPayku->saveAPIResponse($response);
|
||||
|
||||
$this->assertCount(1, PaykuTransaction::get());
|
||||
$this->assertCount(1, PaykuPayment::get());
|
||||
}
|
||||
}
|
||||
45
vendor/sebacarrasco93/laravel-payku/tests/Pest.php
vendored
Normal file
45
vendor/sebacarrasco93/laravel-payku/tests/Pest.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Test Case
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The closure you provide to your test functions is always bound to a specific PHPUnit test
|
||||
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
|
||||
| need to change it using the "uses()" function to bind a different classes or traits.
|
||||
|
|
||||
*/
|
||||
|
||||
// uses(Tests\TestCase::class)->in('Feature');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expectations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When you're writing tests, you often need to check that values meet certain conditions. The
|
||||
| "expect()" function gives you access to a set of "expectations" methods that you can use
|
||||
| to assert different things. Of course, you may extend the Expectation API at any time.
|
||||
|
|
||||
*/
|
||||
|
||||
expect()->extend('toBeOne', function () {
|
||||
return $this->toBe(1);
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Functions
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
|
||||
| project that you don't want to repeat in every file. Here you can also expose helpers as
|
||||
| global functions to help you to reduce the number of lines of code in your test files.
|
||||
|
|
||||
*/
|
||||
|
||||
function something()
|
||||
{
|
||||
// ..
|
||||
}
|
||||
95
vendor/sebacarrasco93/laravel-payku/tests/SimulateResponses.php
vendored
Normal file
95
vendor/sebacarrasco93/laravel-payku/tests/SimulateResponses.php
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace SebaCarrasco93\LaravelPayku\Tests;
|
||||
|
||||
trait SimulateResponses
|
||||
{
|
||||
public function registerResponse()
|
||||
{
|
||||
$response = [
|
||||
'status' => 'register',
|
||||
'id' => 'trx...',
|
||||
'url' => 'https://des.payku.cl/gateway/cobro?id=trx3adbf8e836510de62&valid=4e31d8c7c9',
|
||||
];
|
||||
|
||||
return collect($response);
|
||||
}
|
||||
|
||||
public function pendingResponse()
|
||||
{
|
||||
$response = [
|
||||
'status' => 'pending',
|
||||
'id' => 'trx...',
|
||||
'created_at' => now(),
|
||||
'order' => 1,
|
||||
'email' => 'example@domain.com',
|
||||
'subject' => 'Pending transaction',
|
||||
'amount' => '1000',
|
||||
'payment' => collect([]),
|
||||
'gateway_response' => collect([
|
||||
'status' => 'pending',
|
||||
'message' => 'waiting response',
|
||||
]),
|
||||
];
|
||||
|
||||
return collect($response);
|
||||
}
|
||||
|
||||
public function failedResponse()
|
||||
{
|
||||
$response = [
|
||||
'status' => 'failed',
|
||||
'type' => 'Unprocessable Entity',
|
||||
'message_error' => collect([
|
||||
'order' => 'invalid, max [20] characters',
|
||||
]),
|
||||
];
|
||||
|
||||
return collect($response);
|
||||
}
|
||||
|
||||
public function successResponse()
|
||||
{
|
||||
$response = [
|
||||
'status' => 'success',
|
||||
'id' => 'trx...',
|
||||
'created_at' => now(),
|
||||
'order' => 1,
|
||||
'email' => 'example@domain.com',
|
||||
'subject' => 'Successful transaction',
|
||||
'amount' => '1000',
|
||||
'payment' => collect([
|
||||
'start' => now(),
|
||||
'end' => now()->addMinute(),
|
||||
'media' => 'Webpay',
|
||||
'transaction_id' => 'trx...',
|
||||
'authorization_code' => '1213',
|
||||
'verification_key' => '12345abcdef...',
|
||||
'last_4_digits' => '6623',
|
||||
'installments' => 0,
|
||||
'card_type' => 'VN',
|
||||
'additional_parameters' => '',
|
||||
'currency' => 'CLP',
|
||||
]),
|
||||
'gateway_response' => collect([
|
||||
'status' => 'success',
|
||||
'message' => 'successful transaction',
|
||||
]),
|
||||
];
|
||||
|
||||
return collect($response);
|
||||
}
|
||||
|
||||
public function invalidResponse()
|
||||
{
|
||||
$response = [
|
||||
'status' => 'invalid',
|
||||
'type' => '...',
|
||||
'another_invalid_values' => [
|
||||
'nope' => 'error',
|
||||
],
|
||||
];
|
||||
|
||||
return collect($response);
|
||||
}
|
||||
}
|
||||
60
vendor/sebacarrasco93/laravel-payku/tests/TestCase.php
vendored
Normal file
60
vendor/sebacarrasco93/laravel-payku/tests/TestCase.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace SebaCarrasco93\LaravelPayku\Tests;
|
||||
|
||||
use Orchestra\Testbench\TestCase as BaseTestCase;
|
||||
use SebaCarrasco93\LaravelPayKu\LaravelPayKu as LaravelPayKuClass;
|
||||
use SebaCarrasco93\LaravelPayku\LaravelPaykuServiceProvider;
|
||||
use SebaCarrasco93\LaravelPayku\RouteServiceProvider;
|
||||
|
||||
class TestCase extends BaseTestCase
|
||||
{
|
||||
protected function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function fillApiKeys()
|
||||
{
|
||||
config(['laravel-payku.public_token' => 'somepublictoken']);
|
||||
config(['laravel-payku.private_token' => 'someprivatetoken']);
|
||||
// config(['laravel-payku.base_url' => 'somebaseurlvalue']);
|
||||
}
|
||||
|
||||
public function unfillApiKeys()
|
||||
{
|
||||
config(['laravel-payku.public_token' => null]);
|
||||
config(['laravel-payku.private_token' => null]);
|
||||
// config(['laravel-payku.base_url' => null]);
|
||||
}
|
||||
|
||||
protected function getEnvironmentSetup($app)
|
||||
{
|
||||
$app['config']->set('database.default', 'testing');
|
||||
$app['config']->set('database.conection.testing', [
|
||||
'driver' => 'sqlite',
|
||||
'database' => ':memory:',
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [
|
||||
LaravelPaykuServiceProvider::class,
|
||||
RouteServiceProvider::class,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getPackageAliases($app)
|
||||
{
|
||||
return [
|
||||
'LaravelPayKu' => '\SebaCarrasco93\LaravelPayku\Facades\LaravelPayku::class'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function nowIs($datetime)
|
||||
{
|
||||
\Carbon\Carbon::setTestNow($datetime);
|
||||
}
|
||||
}
|
||||
20
vendor/sebacarrasco93/laravel-payku/tests/Unit/LaravelPaykuDatabaseTest.php
vendored
Normal file
20
vendor/sebacarrasco93/laravel-payku/tests/Unit/LaravelPaykuDatabaseTest.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace SebaCarrasco93\LaravelPayku\Tests\Unit;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use SebaCarrasco93\LaravelPayku\Models\PaykuPayment;
|
||||
use SebaCarrasco93\LaravelPayku\Models\PaykuTransaction;
|
||||
use SebaCarrasco93\LaravelPayku\Tests\TestCase;
|
||||
|
||||
class LaravelPaykuDatabaseTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->transaction = new PaykuTransaction();
|
||||
}
|
||||
}
|
||||
101
vendor/sebacarrasco93/laravel-payku/tests/Unit/LaravelPaykuFacadeTest.php
vendored
Normal file
101
vendor/sebacarrasco93/laravel-payku/tests/Unit/LaravelPaykuFacadeTest.php
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace SebaCarrasco93\LaravelPayku\Tests\Unit;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use SebaCarrasco93\LaravelPayku\Facades\LaravelPayku;
|
||||
use SebaCarrasco93\LaravelPayku\Models\PaykuPayment;
|
||||
use SebaCarrasco93\LaravelPayku\Models\PaykuTransaction;
|
||||
use SebaCarrasco93\LaravelPayku\Tests\TestCase;
|
||||
|
||||
class LaravelPaykuFacadeTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->fillApiKeys();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_knows_which_base_url_in_production_environment() {
|
||||
config(['app.env' => 'production']);
|
||||
$this->assertEquals('https://app.payku.cl/api', LaravelPayku::apiRoute());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_knows_which_base_url_in_local_and_testing_environment() {
|
||||
config(['app.env' => 'local']);
|
||||
$this->assertEquals('https://des.payku.cl/api', LaravelPayku::apiRoute());
|
||||
|
||||
config(['app.env' => 'testing']);
|
||||
$this->assertEquals('https://des.payku.cl/api', LaravelPayku::apiRoute());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_override_the_base_url() {
|
||||
config(['app.env' => 'production']);
|
||||
config(['laravel-payku.base_url' => 'https://des.payku.cl/api']);
|
||||
|
||||
$this->assertEquals('https://des.payku.cl/api', LaravelPayku::apiRoute());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_knows_only_its_filled_keys() {
|
||||
$this->assertEquals([
|
||||
'private_token' => 'someprivatetoken',
|
||||
'public_token' => 'somepublictoken',
|
||||
], LaravelPayku::findApiKeys());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_knows_when_does_has_the_required_keys() {
|
||||
$this->assertTrue(LaravelPayku::hasValidConfig());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_knows_when_does_not_have_the_required_keys() {
|
||||
$this->expectException(\Exception::class);
|
||||
|
||||
$this->unfillApiKeys();
|
||||
LaravelPayku::hasValidConfig();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_prepare_an_order() {
|
||||
$this->assertEquals([
|
||||
'email' => 'seba@sextanet.cl',
|
||||
'order' => 'AAA',
|
||||
'subject' => 'Test',
|
||||
'amount' => '1000',
|
||||
'payment' => '1',
|
||||
'urlreturn' => route('payku.return', 'AAA'),
|
||||
'urlnotify' => route('payku.notify', 'AAA'),
|
||||
], LaravelPayku::prepareOrder('AAA', 'Test', 1000, 'seba@sextanet.cl'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_knows_its_details() {
|
||||
$payment = PaykuTransaction::create(['id' => 'trx...']);
|
||||
|
||||
$this->assertInstanceOf(PaykuTransaction::class, LaravelPayku::findById('trx...'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_knows_when_it_has_status_success() {
|
||||
$payment = PaykuTransaction::create(['id' => 'trx...', 'status' => 'success']);
|
||||
|
||||
$this->assertTrue(LaravelPayku::hasStatusSuccess('trx...'));
|
||||
$this->assertFalse(LaravelPayku::hasStatusPending('trx...'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_knows_when_it_has_status_pending() {
|
||||
$payment = PaykuTransaction::create(['id' => 'trx...', 'status' => 'pending']);
|
||||
|
||||
$this->assertTrue(LaravelPayku::hasStatusPending('trx...'));
|
||||
$this->assertFalse(LaravelPayku::hasStatusSuccess('trx...'));
|
||||
}
|
||||
}
|
||||
68
vendor/sebacarrasco93/laravel-payku/tests/Unit/PaykuTransactionTest.php
vendored
Normal file
68
vendor/sebacarrasco93/laravel-payku/tests/Unit/PaykuTransactionTest.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace SebaCarrasco93\LaravelPayku\Tests\Unit;
|
||||
|
||||
use SebaCarrasco93\LaravelPayku\Tests\TestCase;
|
||||
use SebaCarrasco93\LaravelPayku\Models\PaykuTransaction;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class PaykuTransactionTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
function it_can_see_their_id() {
|
||||
$transaction = PaykuTransaction::create(['id' => 'trx...']);
|
||||
|
||||
$this->assertEquals('trx...', $transaction->id);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_get_only_transactions_with_status_register() {
|
||||
$transaction = PaykuTransaction::create(['id' => 'trx...', 'status' => 'register']);
|
||||
|
||||
$this->assertCount(1, PaykuTransaction::register()->get());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_get_only_transactions_with_status_success() {
|
||||
$transaction = PaykuTransaction::create(['id' => 'trx...', 'status' => 'success']);
|
||||
|
||||
$this->assertCount(1, PaykuTransaction::success()->get());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_get_only_transactions_with_status_pending() {
|
||||
$transaction = PaykuTransaction::create(['id' => 'trx...', 'status' => 'pending']);
|
||||
|
||||
$this->assertCount(1, PaykuTransaction::pending()->get());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_knows_when_it_was_marked_as_notified() {
|
||||
$transaction = PaykuTransaction::create(['id' => 'trx...', 'notified_at' => null]);
|
||||
|
||||
$transaction->markAsNotified();
|
||||
|
||||
$this->assertNotNull($transaction->notified_at);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function it_can_notify_for_first_time() {
|
||||
$transaction = PaykuTransaction::create(['id' => 'trx...', 'notified_at' => null]);
|
||||
|
||||
$this->nowIs('2021-07-26');
|
||||
|
||||
$now = now();
|
||||
|
||||
$transaction->notifyForFirstTime();
|
||||
|
||||
$this->assertEquals($now->format('Y-m-d'), $transaction->notified_at->format('Y-m-d'));
|
||||
|
||||
$transaction->notifyForFirstTime();
|
||||
|
||||
$this->nowIs('2021-07-30');
|
||||
|
||||
$this->assertNotEquals('2021-07-30', $transaction->notified_at->format('Y-m-d'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user