Skip to content

Commit

Permalink
Fixup RiskData (#307)
Browse files Browse the repository at this point in the history
* set to php 7.2 in sdk docker image to get tests running

* Add unit tests for RiskData

* drop RiskDataScore integration check

* fixup unit tests
  • Loading branch information
hstotelmyer authored and GitHub Enterprise committed Mar 1, 2021
1 parent 65b5fbe commit 481daa3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc
RUN apt-get update

RUN apt-get -y install rake php7.2 php7.2-cli php7.2-curl php-pear phpunit php7.2-xml php7.2-mbstring

RUN update-alternatives --set php /usr/bin/php7.2
WORKDIR /braintree-php
1 change: 0 additions & 1 deletion tests/integration/CreditCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ public function testCreate_withCardVerificationReturnsVerificationWithRiskData()
$this->assertNotNull($result->creditCard->verification->riskData->id);
$this->assertNotNull($result->creditCard->verification->riskData->fraudServiceProvider);
$this->assertNotNull($result->creditCard->verification->riskData->decisionReasons);
$this->assertNotNull($result->creditCard->verification->riskData->transactionRiskScore);
error_reporting(E_ALL); // reset error reporting
}

Expand Down
1 change: 0 additions & 1 deletion tests/integration/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2066,7 +2066,6 @@ public function testSaleWithRiskData()
$this->assertNotNull($transaction->riskData->deviceDataCaptured);
$this->assertNotNull($transaction->riskData->fraudServiceProvider);
$this->assertNotNull($transaction->riskData->decisionReasons);
$this->assertNotNull($transaction->riskData->transactionRiskScore);
error_reporting(E_ALL); // reset error reporting
}

Expand Down
38 changes: 38 additions & 0 deletions tests/unit/RiskDataTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
namespace Test\Unit;

require_once dirname(__DIR__) . '/Setup.php';

use DateTime;
use Test\Setup;
use Braintree;

class RiskDataTest extends Setup
{

public function testAttributes()
{
$riskData = Braintree\RiskData::factory([
'customerDeviceId' => 'deviceId',
'customerLocationZip' => '12345',
'customerTenure' => 'tenure',
'decision' => 'decision',
'id' => 'id',
'transactionRiskScore' => '100',
'deviceDataCaptured' => true,
'decisionReasons' => [
'foo', 'bar'
],
]);

$this->assertEquals('deviceId', $riskData->customerDeviceId);
$this->assertEquals('12345', $riskData->customerLocationZip);
$this->assertEquals('tenure', $riskData->customerTenure);
$this->assertEquals('decision', $riskData->decision);
$this->assertEquals('id', $riskData->id);
$this->assertEquals('100', $riskData->transactionRiskScore);
$this->assertTrue($riskData->deviceDataCaptured);
$this->assertContains('foo', $riskData->decisionReasons);
$this->assertContains('bar', $riskData->decisionReasons);
}
}

0 comments on commit 481daa3

Please sign in to comment.