Skip to content

Commit

Permalink
Update CoreApiIntegrationTest.php
Browse files Browse the repository at this point in the history
 add more test with positive-scenario
  • Loading branch information
Andrenzo17 committed Aug 20, 2021
1 parent 90b20dc commit dc886bf
Showing 1 changed file with 68 additions and 8 deletions.
76 changes: 68 additions & 8 deletions tests/integration/CoreApiIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,22 @@ public function testCreatePayAccount()
$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;
}

public function testGetPaymentAccount()
/**
* @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");
Expand All @@ -136,7 +149,7 @@ public function testGetPaymentAccount()
}
}

public function testUnlinkPaymentAccount()
public function testUnlinkPaymentAccountWithNonExistAccount()
{
try {
$this->charge_response = CoreApi::unlinkPaymentAccount("dummy");
Expand Down Expand Up @@ -171,10 +184,20 @@ public function testCreateSubscription()
);
$this->charge_response = CoreApi::createSubscription($param);
$this->assertEquals('active', $this->charge_response->status);
$this->subscriptionId = $this->charge_response->id;
$subscription_id = $this->charge_response->id;
return $subscription_id;
}

public function testGetSubscription()
/**
* @depends testCreateSubscription
*/
public function testGetSubscription($subscription_id)
{
$this->charge_response = CoreApi::getSubscription($subscription_id);
$this->assertEquals('active', $this->charge_response->status);
}

public function testGetSubscriptionWithNonExistAccount()
{
try {
$this->charge_response = CoreApi::getSubscription("dummy");
Expand All @@ -183,7 +206,16 @@ public function testGetSubscription()
}
}

public function testDisableSubscription()
/**
* @depends testCreateSubscription
*/
public function testDisableSubscription($subscription_id)
{
$this->charge_response = CoreApi::disableSubscription($subscription_id);
$this->assertContains('Subscription is updated.', $this->charge_response->status_message);
}

public function testDisableSubscriptionWithNonExistAccount()
{
try {
$this->charge_response = CoreApi::disableSubscription("dummy");
Expand All @@ -192,7 +224,16 @@ public function testDisableSubscription()
}
}

public function testEnableSubscription()
/**
* @depends testCreateSubscription
*/
public function testEnableSubscription($subscription_id)
{
$this->charge_response = CoreApi::enableSubscription($subscription_id);
$this->assertContains('Subscription is updated.', $this->charge_response->status_message);
}

public function testEnableSubscriptionWithNonExistAccount()
{
try {
$this->charge_response = CoreApi::enableSubscription("dummy");
Expand All @@ -201,7 +242,26 @@ public function testEnableSubscription()
}
}

public function testUpdateSubscription()
/**
* @depends testCreateSubscription
*/
public function testUpdateSubscription($subscription_id)
{
$param = array(
"name" => "Monthly_2021",
"amount" => "25000",
"currency" => "IDR",
"token" => "dummy",
"schedule" => array(
"interval" => 1
)
);

$this->charge_response = CoreApi::updateSubscription($subscription_id, $param);
$this->assertContains('Subscription is updated.', $this->charge_response->status_message);
}

public function testUpdateSubscriptionWithNonExistAccount()
{
$param = array(
"name" => "Monthly_2021",
Expand All @@ -219,4 +279,4 @@ public function testUpdateSubscription()
$this->assertContains("Subscription doesn't exist.", $e->getMessage());
}
}
}
}

0 comments on commit dc886bf

Please sign in to comment.