Skip to content

Commit

Permalink
Fix Midtrans namespace for Test class
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaki Ibrahim committed Jul 27, 2021
1 parent 09bf99d commit cf8ee9b
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 36 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
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 cf8ee9b

Please sign in to comment.