3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Class api_v3_PaymentTokenTest
16 class api_v3_PaymentTokenTest
extends CiviUnitTestCase
{
17 protected $_apiversion;
21 public $DBResetRequired = FALSE;
23 public function setUp() {
24 $this->_apiversion
= 3;
25 $this->useTransaction(TRUE);
27 $contactID = $this->individualCreate();
29 'token' => "fancy-token-xxxx",
30 'contact_id' => $contactID,
31 'created_id' => $contactID,
32 'payment_processor_id' => $this->processorCreate(),
36 public function testCreatePaymentToken() {
37 $description = "Create a payment token - Note use of relative dates here:
38 @link http://www.php.net/manual/en/datetime.formats.relative.php.";
39 $result = $this->callAPIAndDocument('payment_token', 'create', $this->params
, __FUNCTION__
, __FILE__
, $description);
40 $this->assertEquals(1, $result['count']);
41 $this->assertNotNull($result['values'][$result['id']]['id']);
42 $this->getAndCheck(array_merge($this->params
, [$this->params
]), $result['id'], 'payment_token', TRUE);
45 public function testGetPaymentToken() {
46 $result = $this->callAPISuccess('payment_token', 'create', $this->params
);
47 $result = $this->callAPIAndDocument('payment_token', 'get', $this->params
, __FUNCTION__
, __FILE__
);
48 $this->assertEquals(1, $result['count']);
49 $this->assertNotNull($result['values'][$result['id']]['id']);
52 public function testDeletePaymentToken() {
53 $this->callAPISuccess('payment_token', 'create', $this->params
);
54 $entity = $this->callAPISuccess('payment_token', 'get', ($this->params
));
55 $delete = ['id' => $entity['id']];
56 $result = $this->callAPIAndDocument('payment_token', 'delete', $delete, __FUNCTION__
, __FILE__
);
58 $checkDeleted = $this->callAPISuccess('payment_token', 'get', []);
59 $this->assertEquals(0, $checkDeleted['count']);