Changeset View
Changeset View
Standalone View
Standalone View
externals/balanced-php/tests/Balanced/SuiteTest.php
Show All 21 Lines | |||||
* Suite test cases. These talk to an API server and so make network calls. | * Suite test cases. These talk to an API server and so make network calls. | ||||
* | * | ||||
* Environment variables can be used to control client settings: | * Environment variables can be used to control client settings: | ||||
* | * | ||||
* <ul> | * <ul> | ||||
* <li>$BALANCED_URL_ROOT If set applies to \Balanced\Settings::$url_root. | * <li>$BALANCED_URL_ROOT If set applies to \Balanced\Settings::$url_root. | ||||
* <li>$BALANCED_API_KEY If set applies to \Balanced\Settings::$api_key. | * <li>$BALANCED_API_KEY If set applies to \Balanced\Settings::$api_key. | ||||
* </ul> | * </ul> | ||||
* | |||||
* @group suite | |||||
*/ | */ | ||||
class SuiteTest extends \PHPUnit_Framework_TestCase | class SuiteTest extends \PHPUnit_Framework_TestCase | ||||
{ | { | ||||
static $key, | static $key, | ||||
$marketplace, | $marketplace, | ||||
$email_counter = 0; | $email_counter = 0; | ||||
static function _createBuyer($email_address = null, $card = null) | static function _createBuyer($email_address = null, $card = null) | ||||
▲ Show 20 Lines • Show All 739 Lines • ▼ Show 20 Lines | function testBankAccountVerificationSuccess() { | ||||
'something i bought', | 'something i bought', | ||||
array('hi' => 'bye'), | array('hi' => 'bye'), | ||||
$bank_account | $bank_account | ||||
); | ); | ||||
$this->assertTrue(strpos($debit->source->uri, 'bank_account') > 0); | $this->assertTrue(strpos($debit->source->uri, 'bank_account') > 0); | ||||
} | } | ||||
function testEvents() { | function testEvents() { | ||||
$prev_num_events = Marketplace::mine()->events->total(); | $prev_num_events = Marketplace::mine()->events->total(); | ||||
$account = self::_createBuyer(); | $account = self::_createBuyer(); | ||||
$account->debit(123); | $account->debit(123); | ||||
$cur_num_events = Marketplace::mine()->events->total(); | $cur_num_events = Marketplace::mine()->events->total(); | ||||
$count = 0; | $count = 0; | ||||
while ($cur_num_events == $prev_num_events && $count < 10) { | while ($cur_num_events == $prev_num_events && $count < 10) { | ||||
printf("waiting for events - %d, %d == %d\n", $count + 1, $cur_num_events, $prev_num_events); | printf("waiting for events - %d, %d == %d\n", $count + 1, $cur_num_events, $prev_num_events); | ||||
sleep(2); // 2 seconds | sleep(2); // 2 seconds | ||||
$cur_num_events = Marketplace::mine()->events->total(); | $cur_num_events = Marketplace::mine()->events->total(); | ||||
$count += 1; | $count += 1; | ||||
} | } | ||||
$this->assertTrue($cur_num_events > $prev_num_events); | $this->assertTrue($cur_num_events > $prev_num_events); | ||||
} | } | ||||
} | } |