Skip to content

Commit

Permalink
Merge pull request #52 from Xaxxis/master
Browse files Browse the repository at this point in the history
v2.4.3 - Fix bug missing namespace in unit test class
  • Loading branch information
Zaki Ibrahim authored Aug 4, 2021
2 parents bc26f9c + cf8ee9b commit 41520bf
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 37 deletions.
3 changes: 1 addition & 2 deletions Midtrans/ApiRequestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Midtrans;

use Exception;
use MT_Tests;
/**
* Send request to Midtrans API
* Better don't use this class directly, please use CoreApi, Snap, and Transaction instead
Expand Down Expand Up @@ -126,7 +125,7 @@ public static function remoteCall($url, $server_key, $data_hash, $post = true)
curl_setopt_array($ch, $curl_options);

// For testing purpose
if (class_exists('MT_Tests') && MT_Tests::$stubHttp) {
if (class_exists('\Midtrans\MT_Tests') && MT_Tests::$stubHttp) {
$result = self::processStubed($curl_options, $url, $server_key, $data_hash, $post);
} else {
$result = curl_exec($ch);
Expand Down
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "midtrans/midtrans-php",
"description": "PHP Wrapper for Midtrans Payment API.",
"homepage": "https://midtrans.com",
"version": "2.4.2",
"version": "2.4.3",
"type": "library",
"license":"MIT",
"authors": [
Expand Down Expand Up @@ -32,5 +32,15 @@
"psr-4": {
"Midtrans\\": "Midtrans/"
}
},
"autoload-dev": {
"psr-4": {
"Midtrans\\":[
"tests/",
"test/integration",
"tests/utility",
"tests/utility/fixture"
]
}
}
}
22 changes: 12 additions & 10 deletions tests/MT_Tests.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Midtrans;

class MT_Tests
{
public static $stubHttp = false;
Expand All @@ -9,21 +11,21 @@ class MT_Tests

public static function reset()
{
MT_Tests::$stubHttp = false;
MT_Tests::$stubHttpResponse = null;
MT_Tests::$lastHttpRequest = null;
MT_Tests::$stubHttp = false;
MT_Tests::$stubHttpResponse = null;
MT_Tests::$lastHttpRequest = null;
}

public static function lastReqOptions()
{
$consts = array(
CURLOPT_URL => "URL",
CURLOPT_HTTPHEADER => "HTTPHEADER",
CURLOPT_RETURNTRANSFER => "RETURNTRANSFER",
CURLOPT_CAINFO => "CAINFO",
CURLOPT_POST => "POST",
CURLOPT_POSTFIELDS => "POSTFIELDS",
CURLOPT_PROXY => "PROXY"
CURLOPT_URL => "URL",
CURLOPT_HTTPHEADER => "HTTPHEADER",
CURLOPT_RETURNTRANSFER => "RETURNTRANSFER",
CURLOPT_CAINFO => "CAINFO",
CURLOPT_POST => "POST",
CURLOPT_POSTFIELDS => "POSTFIELDS",
CURLOPT_PROXY => "PROXY"
);

$options = array();
Expand Down
3 changes: 1 addition & 2 deletions tests/MidtransApiRequestorTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Midtrans\ApiRequestor;
use Midtrans\Config;
namespace Midtrans;

class MidtransApiRequestorTest extends \PHPUnit_Framework_TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/MidtransConfigTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Midtrans\Config;
namespace Midtrans;

class MidtransConfigTest extends \PHPUnit_Framework_TestCase
{
Expand Down
3 changes: 1 addition & 2 deletions tests/MidtransCoreApiTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Midtrans\Config;
use Midtrans\CoreApi;
namespace Midtrans;

class MidtransCoreApiTest extends \PHPUnit_Framework_TestCase
{
Expand Down
3 changes: 1 addition & 2 deletions tests/MidtransNotificationTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Midtrans\Config;
use Midtrans\Notification;
namespace Midtrans;

require_once dirname(__FILE__) . '/../Midtrans.php';

Expand Down
3 changes: 1 addition & 2 deletions tests/MidtransSnapApiRequestorTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Midtrans\ApiRequestor;
use Midtrans\Config;
namespace Midtrans;

class MidtransSnapApiRequestorTest extends \PHPUnit_Framework_TestCase
{
Expand Down
3 changes: 1 addition & 2 deletions tests/MidtransSnapTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Midtrans\Config;
use Midtrans\Snap;
namespace Midtrans;

class MidtransSnapTest extends \PHPUnit_Framework_TestCase
{
Expand Down
4 changes: 1 addition & 3 deletions tests/MidtransTransactionTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

use Midtrans\Config;
use Midtrans\Transaction;
namespace Midtrans;

class MidtransTransactionTest extends \PHPUnit_Framework_TestCase
{
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/CoreApiIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace integration;
namespace Midtrans\integration;

use Midtrans\CoreApi;
use utility\MtChargeFixture;
use Midtrans\utility\MtChargeFixture;

require_once 'IntegrationTest.php';

class CoreApiIntegrationTest extends IntegrationTest
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/IntegrationTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace integration;
namespace Midtrans\integration;

use Midtrans\Config;

Expand Down
5 changes: 3 additions & 2 deletions tests/integration/NotificationIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace integration;
namespace Midtrans\integration;

use Midtrans\CoreApi;
use utility\MtChargeFixture;
use Midtrans\Notification;
use Midtrans\Transaction;
use Midtrans\utility\MtChargeFixture;

require_once 'IntegrationTest.php';


Expand Down
5 changes: 3 additions & 2 deletions tests/integration/SnapIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace integration;
namespace Midtrans\integration;

use Midtrans\Snap;
use utility\MtChargeFixture;
use Midtrans\utility\MtChargeFixture;

require_once 'IntegrationTest.php';

class SnapIntegrationTest extends IntegrationTest
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/TransactionIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

namespace integration;
namespace Midtrans\integration;

use Midtrans\CoreApi;
use Midtrans\Transaction;
use utility\MtChargeFixture;
use Midtrans\utility\MtChargeFixture;

require_once 'IntegrationTest.php';

class TransactionIntegrationTest extends IntegrationTest
Expand Down
2 changes: 1 addition & 1 deletion tests/utility/MtFixture.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace utility;
namespace Midtrans\utility;

class MtFixture
{
Expand Down

0 comments on commit 41520bf

Please sign in to comment.