From 25ff063e91c9e483823768e9d35efe4de80d7692 Mon Sep 17 00:00:00 2001 From: Andrenzo17 <83454487+Andrenzo17@users.noreply.github.com> Date: Mon, 23 Aug 2021 14:22:49 +0700 Subject: [PATCH] Update CoreApiIntegrationTest.php re-arrange unit test --- tests/integration/CoreApiIntegrationTest.php | 146 +++++++++---------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/tests/integration/CoreApiIntegrationTest.php b/tests/integration/CoreApiIntegrationTest.php index 1b936da..d4bf376 100644 --- a/tests/integration/CoreApiIntegrationTest.php +++ b/tests/integration/CoreApiIntegrationTest.php @@ -113,51 +113,6 @@ public function testChargeGopay() $this->assertEquals('pending', $this->charge_response->transaction_status); } - public function testCreatePayAccount() - { - $params = array( - "payment_type" => "gopay", - "gopay_partner" => array( - "phone_number" => 874567446788, - "redirect_url" => "https://www.google.com" - ) - ); - $this->charge_response = CoreApi::linkPaymentAccount($params); - $this->assertEquals('201', $this->charge_response->status_code); - $this->assertEquals('PENDING', $this->charge_response->account_status); - $account_id = $this->charge_response->account_id; - return $account_id; - } - - /** - * @depends testCreatePayAccount - */ - public function testGetPaymentAccount($account_id) - { - $this->charge_response = CoreApi::getPaymentAccount($account_id); - $this->assertEquals('201', $this->charge_response->status_code); - $this->assertEquals('PENDING', $this->charge_response->account_status); - } - - - public function testGetPaymentAccountWithNonExistAccount() - { - try { - $this->charge_response = CoreApi::getPaymentAccount("dummy"); - } catch (\Exception $e) { - $this->assertContains("Midtrans API is returning API error.", $e->getMessage()); - } - } - - public function testUnlinkPaymentAccountWithNonExistAccount() - { - try { - $this->charge_response = CoreApi::unlinkPaymentAccount("dummy"); - } catch (\Exception $e) { - $this->assertContains("Account doesn't exist.", $e->getMessage()); - } - } - public function testCreateSubscription() { $param = array( @@ -197,15 +152,6 @@ public function testGetSubscription($subscription_id) $this->assertEquals('active', $this->charge_response->status); } - public function testGetSubscriptionWithNonExistAccount() - { - try { - $this->charge_response = CoreApi::getSubscription("dummy"); - } catch (\Exception $e) { - $this->assertContains("Subscription doesn't exist.", $e->getMessage()); - } - } - /** * @depends testCreateSubscription */ @@ -215,15 +161,6 @@ public function testDisableSubscription($subscription_id) $this->assertContains('Subscription is updated.', $this->charge_response->status_message); } - public function testDisableSubscriptionWithNonExistAccount() - { - try { - $this->charge_response = CoreApi::disableSubscription("dummy"); - } catch (\Exception $e) { - $this->assertContains("Subscription doesn't exist.", $e->getMessage()); - } - } - /** * @depends testCreateSubscription */ @@ -233,15 +170,6 @@ public function testEnableSubscription($subscription_id) $this->assertContains('Subscription is updated.', $this->charge_response->status_message); } - public function testEnableSubscriptionWithNonExistAccount() - { - try { - $this->charge_response = CoreApi::enableSubscription("dummy"); - } catch (\Exception $e) { - $this->assertContains("Subscription doesn't exist.", $e->getMessage()); - } - } - /** * @depends testCreateSubscription */ @@ -261,6 +189,33 @@ public function testUpdateSubscription($subscription_id) $this->assertContains('Subscription is updated.', $this->charge_response->status_message); } + public function testGetSubscriptionWithNonExistAccount() + { + try { + $this->charge_response = CoreApi::getSubscription("dummy"); + } catch (\Exception $e) { + $this->assertContains("Midtrans API is returning API error.", $e->getMessage()); + } + } + + public function testDisableSubscriptionWithNonExistAccount() + { + try { + $this->charge_response = CoreApi::disableSubscription("dummy"); + } catch (\Exception $e) { + $this->assertContains("Midtrans API is returning API error.", $e->getMessage()); + } + } + + public function testEnableSubscriptionWithNonExistAccount() + { + try { + $this->charge_response = CoreApi::enableSubscription("dummy"); + } catch (\Exception $e) { + $this->assertContains("Midtrans API is returning API error.", $e->getMessage()); + } + } + public function testUpdateSubscriptionWithNonExistAccount() { $param = array( @@ -276,7 +231,52 @@ public function testUpdateSubscriptionWithNonExistAccount() try { $this->charge_response = CoreApi::updateSubscription("dummy", $param); } catch (\Exception $e) { - $this->assertContains("Subscription doesn't exist.", $e->getMessage()); + $this->assertContains("Midtrans API is returning API error.", $e->getMessage()); + } + } + + public function testCreatePayAccount() + { + $params = array( + "payment_type" => "gopay", + "gopay_partner" => array( + "phone_number" => 874567446788, + "redirect_url" => "https://www.google.com" + ) + ); + $this->charge_response = CoreApi::linkPaymentAccount($params); + $this->assertEquals('201', $this->charge_response->status_code); + $this->assertEquals('PENDING', $this->charge_response->account_status); + $account_id = $this->charge_response->account_id; + return $account_id; + } + + /** + * @depends testCreatePayAccount + */ + public function testGetPaymentAccount($account_id) + { + $this->charge_response = CoreApi::getPaymentAccount($account_id); + $this->assertEquals('201', $this->charge_response->status_code); + $this->assertEquals('PENDING', $this->charge_response->account_status); + } + + + public function testGetPaymentAccountWithNonExistAccount() + { + try { + $this->charge_response = CoreApi::getPaymentAccount("dummy"); + } catch (\Exception $e) { + $this->assertContains("Midtrans API is returning API error.", $e->getMessage()); + } + } + + public function testUnlinkPaymentAccountWithNonExistAccount() + { + try { + $this->charge_response = CoreApi::unlinkPaymentAccount("dummy"); + } catch (\Exception $e) { + $this->assertContains("Account doesn't exist.", $e->getMessage()); } } } \ No newline at end of file