Línea 43... |
Línea 43... |
43 |
return false;
|
43 |
return false;
|
44 |
}
|
44 |
}
|
45 |
return true;
|
45 |
return true;
|
46 |
}
|
46 |
}
|
Línea 47... |
Línea 47... |
47 |
|
47 |
|
48 |
public function test_create_account() {
|
48 |
public function test_create_account(): void {
|
49 |
global $DB;
|
49 |
global $DB;
|
Línea 50... |
Línea 50... |
50 |
$this->resetAfterTest();
|
50 |
$this->resetAfterTest();
|
51 |
|
51 |
|
52 |
$account = helper::save_payment_account((object)['name' => 'Test 1', 'idnumber' => '']);
|
52 |
$account = helper::save_payment_account((object)['name' => 'Test 1', 'idnumber' => '']);
|
53 |
$this->assertNotEmpty($account->get('id'));
|
53 |
$this->assertNotEmpty($account->get('id'));
|
Línea 54... |
Línea 54... |
54 |
$this->assertEquals('Test 1', $DB->get_field('payment_accounts', 'name', ['id' => $account->get('id')]));
|
54 |
$this->assertEquals('Test 1', $DB->get_field('payment_accounts', 'name', ['id' => $account->get('id')]));
|
55 |
}
|
55 |
}
|
56 |
|
56 |
|
Línea 57... |
Línea 57... |
57 |
public function test_update_account_details() {
|
57 |
public function test_update_account_details(): void {
|
58 |
global $DB;
|
58 |
global $DB;
|
Línea 64... |
Línea 64... |
64 |
$editedaccount = helper::save_payment_account($record);
|
64 |
$editedaccount = helper::save_payment_account($record);
|
65 |
$this->assertEquals($account->get('id'), $editedaccount->get('id'));
|
65 |
$this->assertEquals($account->get('id'), $editedaccount->get('id'));
|
66 |
$this->assertEquals('Edited name', $DB->get_field('payment_accounts', 'name', ['id' => $account->get('id')]));
|
66 |
$this->assertEquals('Edited name', $DB->get_field('payment_accounts', 'name', ['id' => $account->get('id')]));
|
67 |
}
|
67 |
}
|
Línea 68... |
Línea 68... |
68 |
|
68 |
|
69 |
public function test_update_account_gateways() {
|
69 |
public function test_update_account_gateways(): void {
|
70 |
global $DB;
|
70 |
global $DB;
|
71 |
if (!$this->enable_paypal_gateway()) {
|
71 |
if (!$this->enable_paypal_gateway()) {
|
72 |
$this->markTestSkipped('Paypal payment gateway plugin not found');
|
72 |
$this->markTestSkipped('Paypal payment gateway plugin not found');
|
Línea 91... |
Línea 91... |
91 |
(object)['accountid' => $account->get('id'), 'gateway' => 'paypal', 'config' => 'T3']);
|
91 |
(object)['accountid' => $account->get('id'), 'gateway' => 'paypal', 'config' => 'T3']);
|
92 |
$this->assertEquals($gateway->get('id'), $editedgateway->get('id'));
|
92 |
$this->assertEquals($gateway->get('id'), $editedgateway->get('id'));
|
93 |
$this->assertEquals('T3', $DB->get_field('payment_gateways', 'config', ['id' => $gateway->get('id')]));
|
93 |
$this->assertEquals('T3', $DB->get_field('payment_gateways', 'config', ['id' => $gateway->get('id')]));
|
94 |
}
|
94 |
}
|
Línea 95... |
Línea 95... |
95 |
|
95 |
|
96 |
public function test_delete_account() {
|
96 |
public function test_delete_account(): void {
|
97 |
global $DB;
|
97 |
global $DB;
|
98 |
if (!$this->enable_paypal_gateway()) {
|
98 |
if (!$this->enable_paypal_gateway()) {
|
99 |
$this->markTestSkipped('Paypal payment gateway plugin not found');
|
99 |
$this->markTestSkipped('Paypal payment gateway plugin not found');
|
100 |
}
|
100 |
}
|
Línea 108... |
Línea 108... |
108 |
helper::delete_payment_account(account::get_record(['id' => $account->get('id')]));
|
108 |
helper::delete_payment_account(account::get_record(['id' => $account->get('id')]));
|
109 |
$this->assertEmpty($DB->get_records('payment_accounts', ['id' => $account->get('id')]));
|
109 |
$this->assertEmpty($DB->get_records('payment_accounts', ['id' => $account->get('id')]));
|
110 |
$this->assertEmpty($DB->get_records('payment_gateways', ['id' => $gateway->get('id')]));
|
110 |
$this->assertEmpty($DB->get_records('payment_gateways', ['id' => $gateway->get('id')]));
|
111 |
}
|
111 |
}
|
Línea 112... |
Línea 112... |
112 |
|
112 |
|
113 |
public function test_archive_restore_account() {
|
113 |
public function test_archive_restore_account(): void {
|
114 |
global $DB, $USER;
|
114 |
global $DB, $USER;
|
Línea 115... |
Línea 115... |
115 |
$this->resetAfterTest();
|
115 |
$this->resetAfterTest();
|
116 |
|
116 |
|
Línea 167... |
Línea 167... |
167 |
* @param float $amount
|
167 |
* @param float $amount
|
168 |
* @param string $currency
|
168 |
* @param string $currency
|
169 |
* @param float $surcharge
|
169 |
* @param float $surcharge
|
170 |
* @param string $expected
|
170 |
* @param string $expected
|
171 |
*/
|
171 |
*/
|
172 |
public function test_get_rounded_cost(float $amount, string $currency, float $surcharge, float $expected) {
|
172 |
public function test_get_rounded_cost(float $amount, string $currency, float $surcharge, float $expected): void {
|
173 |
$this->assertEquals($expected, helper::get_rounded_cost($amount, $currency, $surcharge));
|
173 |
$this->assertEquals($expected, helper::get_rounded_cost($amount, $currency, $surcharge));
|
174 |
}
|
174 |
}
|
Línea 175... |
Línea 175... |
175 |
|
175 |
|
176 |
/**
|
176 |
/**
|
Línea 180... |
Línea 180... |
180 |
* @param float $amount
|
180 |
* @param float $amount
|
181 |
* @param string $currency
|
181 |
* @param string $currency
|
182 |
* @param float $surcharge
|
182 |
* @param float $surcharge
|
183 |
* @param string $expected
|
183 |
* @param string $expected
|
184 |
*/
|
184 |
*/
|
185 |
public function test_get_cost_as_string(float $amount, string $currency, float $surcharge, string $expected) {
|
185 |
public function test_get_cost_as_string(float $amount, string $currency, float $surcharge, string $expected): void {
|
186 |
// Some old ICU versions have a bug, where they don't follow the CLDR and they are
|
186 |
// Some old ICU versions have a bug, where they don't follow the CLDR and they are
|
187 |
// missing the non-breaking-space between the currency abbreviation and the value.
|
187 |
// missing the non-breaking-space between the currency abbreviation and the value.
|
188 |
// i.e. it returns AUD50 instead of AU\xc2\xa050). See the following issues @ ICU:
|
188 |
// i.e. it returns AUD50 instead of AU\xc2\xa050). See the following issues @ ICU:
|
189 |
// - https://unicode-org.atlassian.net/browse/ICU-6560
|
189 |
// - https://unicode-org.atlassian.net/browse/ICU-6560
|
190 |
// - https://unicode-org.atlassian.net/browse/ICU-8853
|
190 |
// - https://unicode-org.atlassian.net/browse/ICU-8853
|