Skip to content

Commit

Permalink
Add payline unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
trecouvr committed Nov 7, 2013
1 parent d0f6120 commit 584011b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
30 changes: 24 additions & 6 deletions tests/Payutc/Bom/PaylineRwdbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,35 @@ public function testNotificationBeforeValidate()
$transaction = $this->fakeSdk->getLastTransaction();
$token = $transaction['token'];
$this->payline->notification($token);
$records = Log::getStreamHandler()->getRecords();
$s = 'PAYLINE : Tentative de validation avant erreur ou succes !';
$found = false;
$this->assertTrue($this->strIsInLogs($s));
}

/**
* Test payline failure of a web payment
*
* @expectedException \Payutc\Exception\PaylineException
*/
public function testDoWebPaymentFailure()
{
$t = Transaction::getById(12);
$u = User::getById(1);
$this->fakeSdk->nextWillFail();
$this->payline->doWebPayment($u, $t, 50, 'http://localhost/nowhere');
}

protected function strIsInLogs($s, $lvl=null)
{
$records = Log::getStreamHandler()->getRecords();
foreach($records as $record) {
// if (message startswith s)
if (!strncmp($record['message'], $s, strlen($s))) {
$found = true;
break;
if ($lvl === null or $record['level'] == $lvl) {
if (!strncmp($record['message'], $s, strlen($s))) {
return true;
}
}
}
$this->assertTrue($found);
return false;
}


Expand Down
2 changes: 1 addition & 1 deletion tests/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class FakePaylineSdk

public function nextWillFail()
{
$next_will_fail = true;
$this->next_will_fail = true;
}

public function doWebPayment($arr)
Expand Down

0 comments on commit 584011b

Please sign in to comment.