Skip to content

Commit 58715a4

Browse files
committed
Refactor test cases with paymob credentails
1 parent 9b370a5 commit 58715a4

File tree

5 files changed

+85
-27
lines changed

5 files changed

+85
-27
lines changed

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Laravel Payment Methods
2-
[![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger) [![Packagist version](https://img.shields.io/packagist/v/shabayek/laravel-payment)](https://packagist.org/packages/shabayek/laravel-payment) [![mit](https://img.shields.io/apm/l/laravel)](https://packagist.org/packages/shabayek/laravel-payment)
2+
[![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger) [![Packagist version](https://img.shields.io/packagist/v/shabayek/laravel-payment)](https://packagist.org/packages/shabayek/laravel-payment) [![mit](https://img.shields.io/apm/l/laravel)](https://packagist.org/packages/shabayek/laravel-payment) ![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/shabayek/laravel-payment) ![Packagist Downloads](https://img.shields.io/packagist/dt/shabayek/laravel-payment)
33

44
Laravel payment package handle all payment methods.
55

@@ -52,6 +52,19 @@ class User extends Authenticatable implements CustomerContract
5252
}
5353
```
5454

55+
- You can insert user model object that implements **CustomerContract** or array
56+
57+
```php
58+
$payment->customer($user);
59+
// OR array
60+
$payment->customer([
61+
'first_name' => 'John',
62+
'last_name' => 'Doe',
63+
'email' => '[email protected]',
64+
'phone' => '09123456789',
65+
]);
66+
```
67+
5568
- Implement address details contracts on address model
5669

5770
```php
@@ -79,6 +92,32 @@ class Address extends Model implements AddressContract
7992
}
8093
```
8194

95+
- You enter address model object that implements **AddressContract** array of data
96+
```php
97+
$payment->address($address);
98+
// OR array
99+
$payment->address([
100+
"apartment" => "803",
101+
"floor" => "42",
102+
"street" => "Ethan Land",
103+
"building" => "8028",
104+
"postal_code" => "01898",
105+
"city" => "Jaskolskiburgh",
106+
"country" => "CR",
107+
"state" => "Utah"
108+
]);
109+
```
110+
111+
- Add items with loop array of data items
112+
```php
113+
$payment->items([
114+
"name" => "ASC1515",
115+
"amount_cents" => "500000",
116+
"description" => "Smart Watch",
117+
"quantity" => "1"
118+
]);
119+
```
120+
82121
- Check the payment is online to get pay url
83122

84123
```php

tests/Feature/Paymob/PaymobMethodFeature.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@
1616
*/
1717
class PaymobMethodFeature extends TestCase
1818
{
19+
/**
20+
* Setup test cases
21+
*
22+
* @return void
23+
*/
24+
public function setUp(): void
25+
{
26+
parent::setUp();
27+
// additional setup
28+
config()->set('payment.stores.2.credentials.api_key', 'test');
29+
config()->set('payment.stores.2.credentials.hmac_hash', 'test');
30+
config()->set('payment.stores.2.credentials.merchant_id', 'test');
31+
config()->set('payment.stores.2.credentials.iframe_id', 'test');
32+
config()->set('payment.stores.2.credentials.integration_id', 'test');
33+
}
1934
/** @test*/
2035
public function test_payment_token_in_return_purchase_url_with_paymob()
2136
{
@@ -136,7 +151,6 @@ public function test_installment_payment_pay_fail_return_from_post_request_with_
136151

137152
$this->assertFalse($paymentCallback['success']);
138153
$this->assertEquals('Get order data failed in paymob # incorrect credentials', $paymentCallback['message']);
139-
140154
}
141155
/** @test*/
142156
public function test_installment_payment_pay_success_return_from_post_request_with_paymob()

tests/Unit/PaymentManagerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414
*/
1515
class PaymentManagerTest extends TestCase
1616
{
17+
/**
18+
* Setup test cases
19+
*
20+
* @return void
21+
*/
22+
public function setUp(): void
23+
{
24+
parent::setUp();
25+
// additional setup
26+
config()->set('payment.stores.2.credentials.api_key', 'test');
27+
config()->set('payment.stores.2.credentials.hmac_hash', 'test');
28+
config()->set('payment.stores.2.credentials.merchant_id', 'test');
29+
config()->set('payment.stores.2.credentials.iframe_id', 'test');
30+
config()->set('payment.stores.2.credentials.integration_id', 'test');
31+
}
1732
/** @test */
1833
public function a_payment_facade_is_register(): void
1934
{

tests/Unit/Paymob/PaymobRequestTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414
*/
1515
class PaymobRequestTest extends TestCase
1616
{
17+
/**
18+
* Setup test cases
19+
*
20+
* @return void
21+
*/
22+
public function setUp(): void
23+
{
24+
parent::setUp();
25+
// additional setup
26+
config()->set('payment.stores.2.credentials.api_key', 'test');
27+
config()->set('payment.stores.2.credentials.hmac_hash', 'test');
28+
config()->set('payment.stores.2.credentials.merchant_id', 'test');
29+
config()->set('payment.stores.2.credentials.iframe_id', 'test');
30+
config()->set('payment.stores.2.credentials.integration_id', 'test');
31+
}
1732
/** @test*/
1833
public function test_authication_token()
1934
{

tests/Unit/PaymobMethodTest.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)