Subiendo proyecto completo sin restricciones de git ignore
This commit is contained in:
60
vendor/mercadopago/dx-php/tests/DummyEntity.php
vendored
Normal file
60
vendor/mercadopago/dx-php/tests/DummyEntity.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
namespace MercadoPago;
|
||||
use MercadoPago\Annotation\RestMethod;
|
||||
use MercadoPago\Annotation\RequestParam;
|
||||
use MercadoPago\Annotation\Attribute;
|
||||
/**
|
||||
* @RestMethod(resource="/dummies", method="list")
|
||||
* @RestMethod(resource="/dummy/:id", method="read")
|
||||
* @RestMethod(resource="/dummy/:id", method="update")
|
||||
* @RestMethod(resource="/v1/payments", method="create")
|
||||
* @RestMethod(resource="/v1/dummies/search", method="search")
|
||||
* @RequestParam(param="access_token")
|
||||
*/
|
||||
class DummyEntity extends Entity
|
||||
{
|
||||
/**
|
||||
* @Attribute(primaryKey = true, type="string", idempotency=true)
|
||||
*/
|
||||
protected $id;
|
||||
/**
|
||||
* @Attribute(type = "string")
|
||||
*/
|
||||
protected $title;
|
||||
/**
|
||||
* @Attribute(type = "string")
|
||||
*/
|
||||
protected $email;
|
||||
/**
|
||||
* @Attribute(type = "string")
|
||||
*/
|
||||
protected $desc;
|
||||
/**
|
||||
* @Attribute(type = "float")
|
||||
*/
|
||||
protected $price;
|
||||
/**
|
||||
* @Attribute(type = "int")
|
||||
*/
|
||||
protected $quantity;
|
||||
/**
|
||||
* @Attribute(type = "date")
|
||||
*/
|
||||
protected $registered_at;
|
||||
/**
|
||||
* @Attribute(type = "stdClass")
|
||||
*/
|
||||
protected $object;
|
||||
/**
|
||||
* @Attribute()
|
||||
*/
|
||||
protected $other;
|
||||
/**
|
||||
* @Attribute(readOnly="true")
|
||||
*/
|
||||
protected $readOnlyAttribute;
|
||||
/**
|
||||
* @Attribute(maxLength=20)
|
||||
*/
|
||||
protected $maxLengthAttribute;
|
||||
}
|
||||
32
vendor/mercadopago/dx-php/tests/FakeApiHub.php
vendored
Normal file
32
vendor/mercadopago/dx-php/tests/FakeApiHub.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace MercadoPago;
|
||||
class FakeApiHub
|
||||
{
|
||||
private $_files = [
|
||||
'/oauth/token' => 'authorization.json',
|
||||
'/v1/payment_methods' => 'payment_methods.json',
|
||||
'/v1/payments' => 'payment.json',
|
||||
'/dummies' => 'dummies.json',
|
||||
'/v1/dummies/search' => 'customer_search.json',
|
||||
'/dummy/:id' => 'dummy.json'
|
||||
];
|
||||
public function getJson($method, $endPoint)
|
||||
{
|
||||
switch ($method) {
|
||||
case 'GET': {
|
||||
return $this->getFile($endPoint);
|
||||
break;
|
||||
}
|
||||
case 'POST': {
|
||||
return $this->getFile($endPoint);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
private function getFile($endpoint)
|
||||
{
|
||||
return file_get_contents(dirname(__FILE__) . '/json_files/' . $this->_files[$endpoint]);
|
||||
}
|
||||
}
|
||||
46
vendor/mercadopago/dx-php/tests/MercadoPagoSdkTest.php
vendored
Normal file
46
vendor/mercadopago/dx-php/tests/MercadoPagoSdkTest.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace MercadoPago;
|
||||
|
||||
/**
|
||||
* EntityTest Class Doc Comment
|
||||
*
|
||||
* @package MercadoPago
|
||||
*/
|
||||
class MercadopagoSdkTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
Entity::unSetManager();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage Please initialize SDK first
|
||||
*/
|
||||
public function testWrongInitialization()
|
||||
{
|
||||
$entity = new DummyEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testInitialization()
|
||||
{
|
||||
SDK::initialize();
|
||||
$entity = new DummyEntity();
|
||||
$this->assertInstanceOf(DummyEntity::class, $entity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
58
vendor/mercadopago/dx-php/tests/SDKTest.php
vendored
Normal file
58
vendor/mercadopago/dx-php/tests/SDKTest.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* EntityTest Class Doc Comment
|
||||
*
|
||||
* @package MercadoPago
|
||||
*/
|
||||
class ConfigTest extends TestCase
|
||||
{
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
|
||||
MercadoPago\SDK::cleanCredentials();
|
||||
|
||||
if (file_exists(__DIR__ . '/../.env')) {
|
||||
$dotenv = new Dotenv\Dotenv(__DIR__, '/../.env');
|
||||
$dotenv->load();
|
||||
}
|
||||
|
||||
MercadoPago\SDK::setClientId(getenv('CLIENT_ID'));
|
||||
MercadoPago\SDK::setClientSecret(getenv('CLIENT_SECRET'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers MercadoPago\SDK
|
||||
*/
|
||||
public function testSettings()
|
||||
{
|
||||
$this->assertEquals(getenv('CLIENT_ID'), MercadoPago\SDK::getClientId());
|
||||
$this->assertEquals(getenv('CLIENT_SECRET'), MercadoPago\SDK::getClientSecret());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers MercadoPago\SDK
|
||||
*/
|
||||
public function testDoGetToken()
|
||||
{
|
||||
$this->assertNotNull(MercadoPago\SDK::getAccessToken());
|
||||
}
|
||||
|
||||
public function testSetMultipleAT(){
|
||||
MercadoPago\SDK::setMultipleCredentials(
|
||||
array(
|
||||
"mla" => "MLA_AT",
|
||||
"mlb" => "MLB_AT"
|
||||
)
|
||||
);
|
||||
$this->assertNotNull(MercadoPago\SDK::config()->getData()['mla']);
|
||||
$this->assertNotNull(MercadoPago\SDK::config()->getData()['mlb']);
|
||||
}
|
||||
|
||||
}
|
||||
3
vendor/mercadopago/dx-php/tests/config_files/settings.ini
vendored
Normal file
3
vendor/mercadopago/dx-php/tests/config_files/settings.ini
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
CLIENT_ID: "CLIENT_ID_YAML"
|
||||
CLIENT_SECRET: "CLIENT_SECRET_YAML"
|
||||
ACCESS_TOKEN: "CLIENT_ACCESS_TOKEN_YAML"
|
||||
5
vendor/mercadopago/dx-php/tests/config_files/settings.json
vendored
Normal file
5
vendor/mercadopago/dx-php/tests/config_files/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"CLIENT_ID": "CLIENT_ID_JSON",
|
||||
"CLIENT_SECRET": "CLIENT_SECRET_JSON",
|
||||
"ACCESS_TOKEN": "CLIENT_ACCESS_TOKEN_JSON"
|
||||
}
|
||||
4
vendor/mercadopago/dx-php/tests/config_files/settings.yml
vendored
Normal file
4
vendor/mercadopago/dx-php/tests/config_files/settings.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
CLIENT_ID: "CLIENT_ID_YAML"
|
||||
CLIENT_SECRET: "CLIENT_SECRET_YAML"
|
||||
ACCESS_TOKEN: "CLIENT_ACCESS_TOKEN_YAML"
|
||||
APP_ID: "CLIENT_APP_ID_YAML"
|
||||
5
vendor/mercadopago/dx-php/tests/config_files/settings_broken.json
vendored
Normal file
5
vendor/mercadopago/dx-php/tests/config_files/settings_broken.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"CLIENT_ID": "CLIENT_ID_JSON",
|
||||
"CLIENT_SECRET" "CLIENT_SECRET_JSON",
|
||||
"ACCESS_TOKEN": "CLIENT_ACCESS_TOKEN_JSON"
|
||||
}
|
||||
3
vendor/mercadopago/dx-php/tests/config_files/settings_broken.yml
vendored
Normal file
3
vendor/mercadopago/dx-php/tests/config_files/settings_broken.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
CLIENT_ID: "CLIENT_ID_YAML"
|
||||
CLIENT_SECRET "CLIENT_SECRET_YAML"
|
||||
ACCESS_TOKEN: "CLIENT_ACCESS_TOKEN_YAML"
|
||||
3
vendor/mercadopago/dx-php/tests/json_files/authorization.json
vendored
Normal file
3
vendor/mercadopago/dx-php/tests/json_files/authorization.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"ACCESS_TOKEN": "ACCESS_TOKEN"
|
||||
}
|
||||
1
vendor/mercadopago/dx-php/tests/json_files/customer_search.json
vendored
Normal file
1
vendor/mercadopago/dx-php/tests/json_files/customer_search.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"paging":{"offset":0,"limit":10,"total":1},"results":[{"id":"227166260-QeyHHDJ8TZ4L3R","email":"test_user_99529216@testuser.com","first_name":null,"last_name":null,"phone":{"area_code":null,"number":null},"identification":{"number":null,"type":null},"addresses":null,"address":{"id":null,"zip_code":null,"street_name":null,"street_number":null},"date_registered":null,"description":null,"date_created":"2016-09-09T14:08:58.603-04:00","date_last_updated":"2016-09-09T14:08:58.609-04:00","default_card":null,"default_address":null,"cards":[],"metadata":{},"live_mode":true}]}
|
||||
19
vendor/mercadopago/dx-php/tests/json_files/dummies.json
vendored
Normal file
19
vendor/mercadopago/dx-php/tests/json_files/dummies.json
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"paging": {
|
||||
"limit": 30,
|
||||
"offset": 0,
|
||||
"total": 1
|
||||
},
|
||||
"results": [
|
||||
{
|
||||
"id": 1340404,
|
||||
"title": "Title of what you are paying for. It will be displayed in the payment process.",
|
||||
"description": "Item description",
|
||||
"category_id": "art",
|
||||
"picture_url": "https://www.mercadopago.com/org-img/MP3/home/logomp3.gif",
|
||||
"currency_id": "ARS",
|
||||
"quantity": 1,
|
||||
"unit_price": 100
|
||||
}
|
||||
]
|
||||
}
|
||||
10
vendor/mercadopago/dx-php/tests/json_files/dummy.json
vendored
Normal file
10
vendor/mercadopago/dx-php/tests/json_files/dummy.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": 1340404,
|
||||
"title": "Title of what you are paying for. It will be displayed in the payment process.",
|
||||
"description": "Item description",
|
||||
"category_id": "art",
|
||||
"picture_url": "https://www.mercadopago.com/org-img/MP3/home/logomp3.gif",
|
||||
"currency_id": "ARS",
|
||||
"quantity": 1,
|
||||
"unit_price": 100
|
||||
}
|
||||
88
vendor/mercadopago/dx-php/tests/json_files/payment.json
vendored
Normal file
88
vendor/mercadopago/dx-php/tests/json_files/payment.json
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"id":1340404,
|
||||
"date_created":"2016-08-19T13:50:17.000-04:00",
|
||||
"date_approved":"2016-08-19T13:50:17.000-04:00",
|
||||
"date_last_updated":"2016-08-19T13:50:17.000-04:00",
|
||||
"money_release_date":null,
|
||||
"operation_type":"regular_payment",
|
||||
"issuer_id":"1",
|
||||
"payment_method_id":"visa",
|
||||
"payment_type_id":"credit_card",
|
||||
"status":"approved",
|
||||
"status_detail":"accredited",
|
||||
"currency_id":"ARS",
|
||||
"description":null,
|
||||
"live_mode":false,
|
||||
"sponsor_id":null,
|
||||
"authorization_code":null,
|
||||
"collector_id":192627424,
|
||||
"payer":{
|
||||
"type":"customer",
|
||||
"id":"204943005-G4n3trGt71WZEb",
|
||||
"email":"test_user_58666377@testuser.com",
|
||||
"identification":{
|
||||
"type":"DNI",
|
||||
"number":"1111111"
|
||||
},
|
||||
"phone":{
|
||||
"area_code":"01",
|
||||
"number":"1111-1111",
|
||||
"extension":""
|
||||
},
|
||||
"first_name":"Test",
|
||||
"last_name":"Test"
|
||||
},
|
||||
"metadata":[
|
||||
|
||||
],
|
||||
"order":[
|
||||
|
||||
],
|
||||
"external_reference":null,
|
||||
"transaction_amount":100,
|
||||
"transaction_amount_refunded":0,
|
||||
"coupon_amount":0,
|
||||
"differential_pricing_id":null,
|
||||
"deduction_schema":null,
|
||||
"transaction_details":{
|
||||
"net_received_amount":80.41,
|
||||
"total_paid_amount":100,
|
||||
"overpaid_amount":0,
|
||||
"external_resource_url":null,
|
||||
"installment_amount":100,
|
||||
"financial_institution":null,
|
||||
"payment_method_reference_id":null
|
||||
},
|
||||
"fee_details":[
|
||||
{
|
||||
"type":"mercadopago_fee",
|
||||
"amount":19.59,
|
||||
"fee_payer":"collector"
|
||||
}
|
||||
],
|
||||
"captured":true,
|
||||
"binary_mode":false,
|
||||
"call_for_authorize_id":null,
|
||||
"statement_descriptor":"WWW.MERCADOPAGO.COM",
|
||||
"installments":1,
|
||||
"card":{
|
||||
"id":"1461592544092",
|
||||
"first_six_digits":"407559",
|
||||
"last_four_digits":"3764",
|
||||
"expiration_month":3,
|
||||
"expiration_year":2018,
|
||||
"date_created":"2016-04-25T09:55:00.000-04:00",
|
||||
"date_last_updated":"2016-04-25T09:55:34.000-04:00",
|
||||
"cardholder":{
|
||||
"name":"nam",
|
||||
"identification":{
|
||||
"number":"12345678",
|
||||
"type":"DNI"
|
||||
}
|
||||
}
|
||||
},
|
||||
"notification_url":null,
|
||||
"refunds":[
|
||||
|
||||
]
|
||||
}
|
||||
233
vendor/mercadopago/dx-php/tests/resources/PaymentTest.php
vendored
Normal file
233
vendor/mercadopago/dx-php/tests/resources/PaymentTest.php
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* EntityTest Class Doc Comment
|
||||
*
|
||||
* @package MercadoPago
|
||||
*/
|
||||
class PaymentTest extends TestCase
|
||||
{
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
MercadoPago\SDK::cleanCredentials();
|
||||
|
||||
if (file_exists(__DIR__ . '/../../.env')) {
|
||||
$dotenv = new Dotenv\Dotenv(__DIR__, '../../.env');
|
||||
$dotenv->load();
|
||||
}
|
||||
|
||||
MercadoPago\SDK::setAccessToken(getenv('ACCESS_TOKEN'));
|
||||
MercadoPago\SDK::setMultipleCredentials(
|
||||
array(
|
||||
"MLA" => "MLA_ACCESS_TOKEN"
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function testCreateApprovedPayment()
|
||||
{
|
||||
|
||||
$payment = new MercadoPago\Payment();
|
||||
$payment->transaction_amount = 141;
|
||||
$payment->token = $this->SingleUseCardToken('approved');
|
||||
$payment->description = "Ergonomic Silk Shirt";
|
||||
$payment->installments = 1;
|
||||
$payment->payment_method_id = "master";
|
||||
$payment->payer = array(
|
||||
"email" => getenv('USER_EMAIL')
|
||||
);
|
||||
$payment->external_reference = "reftest";
|
||||
$payment->save();
|
||||
|
||||
$this->assertEquals($payment->status, 'approved');
|
||||
|
||||
return $payment;
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @depends testCreateApprovedPayment
|
||||
// */
|
||||
// public function testRefundPayment(MercadoPago\Payment $payment_created_previously)
|
||||
// {
|
||||
|
||||
// $id = $payment_created_previously->id;
|
||||
|
||||
// $refund = new MercadoPago\Refund();
|
||||
// $refund->payment_id = $id;
|
||||
// $refund->save();
|
||||
|
||||
// sleep(15);
|
||||
|
||||
// $payment = MercadoPago\Payment::find_by_id($id);
|
||||
|
||||
// $this->assertEquals("refunded", $payment->status);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
public function testCreateAnInvalidPayment()
|
||||
{
|
||||
|
||||
$payment = new MercadoPago\Payment();
|
||||
$payment->transaction_amount = -200;
|
||||
|
||||
$payment_status = $payment->save();
|
||||
|
||||
$this->assertFalse($payment_status);
|
||||
$this->assertEquals($payment->error->causes[0]->description, "transaction_amount must be positive");
|
||||
|
||||
}
|
||||
|
||||
public function testSearchWithInvalidQueryFilters()
|
||||
{
|
||||
|
||||
$filters = array(
|
||||
"incorrect_param" => "000"
|
||||
);
|
||||
|
||||
try {
|
||||
$payments = MercadoPago\Payment::search($filters);
|
||||
} catch(Exception $e) {
|
||||
$this->assertEquals($e->getMessage(), "the attribute incorrect_param is not a possible param");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function testCreatePendingPayment()
|
||||
{
|
||||
|
||||
$payment = new MercadoPago\Payment();
|
||||
$payment->transaction_amount = 141;
|
||||
$payment->token = $this->SingleUseCardToken('in_process');
|
||||
$payment->description = "Ergonomic Silk Shirt";
|
||||
$payment->installments = 1;
|
||||
$payment->payment_method_id = "master";
|
||||
$payment->payer = array(
|
||||
"email" => getenv('USER_EMAIL')
|
||||
);
|
||||
$payment->external_reference = "reftest";
|
||||
$payment->save();
|
||||
|
||||
$this->assertEquals($payment->status, 'in_process');
|
||||
|
||||
return $payment;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreatePendingPayment
|
||||
*/
|
||||
public function testFindPaymentById(MercadoPago\Payment $payment_created_previously) {
|
||||
$payment = MercadoPago\Payment::find_by_id($payment_created_previously->id);
|
||||
$this->assertEquals($payment->id, $payment_created_previously->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreatePendingPayment
|
||||
*/
|
||||
public function testFindPaymentByNonExistentId(MercadoPago\Payment $payment_created_previously) {
|
||||
$payment = MercadoPago\Payment::find_by_id("123456");
|
||||
$this->assertEquals($payment, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreatePendingPayment
|
||||
*/
|
||||
public function testPaymentsSearch(MercadoPago\Payment $payment_created_previously) {
|
||||
|
||||
$filters = array(
|
||||
"external_reference" => $payment_created_previously->external_reference
|
||||
);
|
||||
|
||||
$payments = MercadoPago\Payment::search($filters);
|
||||
$payments = $payments->getArrayCopy();
|
||||
$payment = end($payments);
|
||||
|
||||
$this->assertEquals($payment->external_reference, $payment_created_previously->external_reference);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreatePendingPayment
|
||||
*/
|
||||
public function testCancelPayment(MercadoPago\Payment $payment_created_previously) {
|
||||
$payment_created_previously->status = "cancelled";
|
||||
$payment_created_previously->update();
|
||||
|
||||
sleep(15);
|
||||
|
||||
$payment = MercadoPago\Payment::find_by_id($payment_created_previously->id);
|
||||
$this->assertEquals("cancelled", $payment->status);
|
||||
|
||||
}
|
||||
|
||||
public function testPaymentWithCustomAccessToken() {
|
||||
$payment = new MercadoPago\Payment();
|
||||
|
||||
$options = array(
|
||||
"custom_access_token" => "MLA"
|
||||
);
|
||||
|
||||
$payment_status = $payment->save($options);
|
||||
|
||||
$this->assertFalse($payment_status); // Marlformed access token error
|
||||
|
||||
$payment_status = $payment->save();
|
||||
|
||||
$this->assertFalse($payment_status);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function SingleUseCardToken($status){
|
||||
|
||||
$cards_name_for_status = array(
|
||||
"approved" => "APRO",
|
||||
"in_process" => "CONT",
|
||||
"call_for_auth" => "CALL",
|
||||
"not_founds" => "FUND",
|
||||
"expirated" => "EXPI",
|
||||
"form_error" => "FORM",
|
||||
"general_error" => "OTHE",
|
||||
);
|
||||
|
||||
$i_current_month = intval(date('m'));
|
||||
$i_current_year = intval(date('Y'));
|
||||
|
||||
$security_code = rand(111, 999);
|
||||
$expiration_month = rand($i_current_month, 12);
|
||||
$expiration_year = rand($i_current_year + 2, 2999);
|
||||
$dni = rand(11111111, 99999999);
|
||||
|
||||
$payload = array(
|
||||
"json_data" => array(
|
||||
"card_number" => "5031433215406351",
|
||||
"security_code" => (string)$security_code,
|
||||
"expiration_month" => str_pad($expiration_month, 2, '0', STR_PAD_LEFT),
|
||||
"expiration_year" => str_pad($expiration_year, 4, '0', STR_PAD_LEFT),
|
||||
"cardholder" => array(
|
||||
"name" => $cards_name_for_status[$status],
|
||||
"identification" => array(
|
||||
"type" => "DNI",
|
||||
"number" => (string)$dni
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$response = MercadoPago\SDK::post('/v1/card_tokens', $payload);
|
||||
|
||||
return $response['body']['id'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
48
vendor/mercadopago/dx-php/tests/resources/PreferenceTest.php
vendored
Normal file
48
vendor/mercadopago/dx-php/tests/resources/PreferenceTest.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* EntityTest Class Doc Comment
|
||||
*
|
||||
* @package MercadoPago
|
||||
*/
|
||||
class PreferenceTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
private static $last_preference;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
if (file_exists(__DIR__ . '/../../.env')) {
|
||||
$dotenv = new Dotenv\Dotenv(__DIR__, '../../.env');
|
||||
$dotenv->load();
|
||||
}
|
||||
|
||||
MercadoPago\SDK::setAccessToken(getenv('ACCESS_TOKEN'));
|
||||
|
||||
}
|
||||
|
||||
public function testCreatePrefence()
|
||||
{
|
||||
|
||||
$preference = new MercadoPago\Preference();
|
||||
|
||||
# Building an item
|
||||
$item = new MercadoPago\Item();
|
||||
$item->title = "item";
|
||||
$item->quantity = 1;
|
||||
$item->unit_price = 100;
|
||||
|
||||
$preference->items = array($item);
|
||||
$preference->expiration_date_to = new DateTime('tomorrow');
|
||||
$preference->save();
|
||||
|
||||
self::$last_preference = $preference;
|
||||
|
||||
$this->assertTrue($preference->sandbox_init_point != null);
|
||||
}
|
||||
|
||||
public function testFindPreferenceById(){
|
||||
$preference = MercadoPago\Preference::find_by_id(self::$last_preference->id);
|
||||
$this->assertEquals($preference->id, self::$last_preference->id);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user