Skip to content

Commit

Permalink
Update CoreApiIntegrationTest.php
Browse files Browse the repository at this point in the history
re-arrange unit test
  • Loading branch information
Andrenzo17 committed Aug 23, 2021
1 parent 62b6f7a commit 25ff063
Showing 1 changed file with 73 additions and 73 deletions.
146 changes: 73 additions & 73 deletions tests/integration/CoreApiIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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(
Expand All @@ -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());
}
}
}

0 comments on commit 25ff063

Please sign in to comment.