Skip to content

Commit

Permalink
Merge pull request #1 from vimeo/long-test-int
Browse files Browse the repository at this point in the history
Long test int
  • Loading branch information
hannahlorane committed Dec 11, 2017
2 parents fdc6b43 + ac72e57 commit fbf3344
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 23 deletions.
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</errorLevel>
</MissingConstructor>
<PropertyNotSetInConstructor errorLevel="suppress" />
<ImplementedReturnTypeMismatch errorLevel="suppress" />
</issueHandlers>

<mockClasses>
Expand Down
1 change: 0 additions & 1 deletion src/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class CreditCard extends \Omnipay\Common\CreditCard
/**
* Gets the card brand. Returns the brand that was set if one was set,
* otherwise determines the brand from the card number.
*
* @return string|null
*/
public function getBrand()
Expand Down
4 changes: 2 additions & 2 deletions src/ExtendedGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ public function fetchSubscription(array $parameters = array())
* parameters passed.
*
* @param array $parameters
* @return \Omnipay\BlueSnap\Message\AbstractRequest
* @return \Omnipay\BlueSnap\Message\FetchSubscriptionsRequest
*/
public function fetchSubscriptions(array $parameters = array())
{
if (isset($parameters['customerReference'])) {
/**
* @var \Omnipay\BlueSnap\Message\AbstractRequest
* @var \Omnipay\BlueSnap\Message\FetchSubscriptionsRequest
*/
return $this->createRequest(
'\Omnipay\BlueSnap\Message\ExtendedFetchSubscriptionsRequest',
Expand Down
7 changes: 4 additions & 3 deletions src/Message/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ public function getMessage()
if ($this->data instanceof SimpleXMLElement && isset($this->data->message->description)) {
return (string) $this->data->message->description;
}
// some error responses are plain text instead of XML
return (string) $this->data;
if (is_string($this->data)) {
return $this->data;
} // some error responses are plain text instead of XML
}

return null;
Expand Down Expand Up @@ -391,7 +392,7 @@ public function getNextChargeDate()
*/
public function getTransactions()
{
if (!isset($this->data['data'])) {
if (!is_array($this->data) || !isset($this->data['data'])) {
return null;
}
$transactions = array();
Expand Down
10 changes: 5 additions & 5 deletions tests/Framework/DataFaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public function password()
public function customerReference()
{
do {
$result = $this->randomCharacters(self::DIGITS, $this->intBetween(6, 10));
$result = $this->randomCharacters(self::DIGITS, $this->intBetween(6, 9));
} while ($result == 0);
return $result;
}
Expand All @@ -295,7 +295,7 @@ public function customerReference()
public function transactionReference()
{
do {
$result = $this->randomCharacters(self::DIGITS, $this->intBetween(6, 10));
$result = $this->randomCharacters(self::DIGITS, $this->intBetween(6, 9));
} while ($result == 0);
return $result;
}
Expand All @@ -308,7 +308,7 @@ public function transactionReference()
public function subscriptionReference()
{
do {
$result = $this->randomCharacters(self::DIGITS, $this->intBetween(6, 10));
$result = $this->randomCharacters(self::DIGITS, $this->intBetween(6, 9));
} while ($result == 0);
return $result;
}
Expand All @@ -321,7 +321,7 @@ public function subscriptionReference()
public function subscriptionChargeReference()
{
do {
$result = $this->randomCharacters(self::DIGITS, $this->intBetween(3, 10));
$result = $this->randomCharacters(self::DIGITS, $this->intBetween(3, 9));
} while ($result == 0);
return $result;
}
Expand All @@ -347,7 +347,7 @@ public function storeReference()
public function planReference()
{
do {
$result = $this->randomCharacters(self::DIGITS, $this->intBetween(6, 10));
$result = $this->randomCharacters(self::DIGITS, $this->intBetween(6, 9));
} while ($result == 0);
return $result;
}
Expand Down
12 changes: 8 additions & 4 deletions tests/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getMockHttpResponse($path, $substitutions = array())
* then the function will replace all instances of '[NAME]' in the
* response with 'Fake Name'. Substitutions are not required.
*
* @param array<string>|string $paths
* @param array<string, string>|string $paths
* @param array<string, string> $substitutions
*
* @return MockPlugin
Expand All @@ -95,8 +95,12 @@ public function setMockHttpResponse($paths, $substitutions = array())
$this->substitutableMockHttpRequests = array();
$that = $this;
$mock = new MockPlugin(null, true);
$this->getHttpClient()->getEventDispatcher()->removeSubscriber($mock);
$mock->getEventDispatcher()->addListener(
/** @var \Symfony\Component\EventDispatcher\EventDispatcher */
$event_dispatcher = $this->getHttpClient()->getEventDispatcher();
$event_dispatcher->removeSubscriber($mock);
/** @var \Symfony\Component\EventDispatcher\EventDispatcher */
$mock_event_dispatcher = $mock->getEventDispatcher();
$mock_event_dispatcher->addListener(
'mock.request',
// @codingStandardsIgnoreStart
/**
Expand All @@ -120,7 +124,7 @@ function (Event $event) use ($that) {
$mock->addResponse($this->getMockHttpResponse($path, $substitutions) ?: '');
}

$this->getHttpClient()->getEventDispatcher()->addSubscriber($mock);
$event_dispatcher->addSubscriber($mock);

return $mock;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/ExtendedFetchSubscriptionsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function testSendSuccess()
$this->assertFalse($response->isRedirect());
$this->assertSame('200', $response->getCode());
$subscriptions = $response->getSubscriptions();
$this->assertSame(2, count($subscriptions));
$this->assertCount(2, $subscriptions);
if ($subscriptions) {
foreach ($subscriptions as $i => $subscription) {
$fakeSubscription = $fakeSubscriptions[intval($i) + 1];
Expand Down
8 changes: 4 additions & 4 deletions tests/Message/ExtendedFetchTransactionRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public function testSendSuccess()
$fakeCard = $this->faker->card();
$cardBrand = $fakeCard->getBrand();
$cardLastFour = $fakeCard->getNumberLastFour();
$expiryMonth = $fakeCard->getExpiryMonth();
$expiryYear = $fakeCard->getExpiryYear();
$expiryMonth = (string) $fakeCard->getExpiryMonth();
$expiryYear = (string) $fakeCard->getExpiryYear();
$firstName = $fakeCard->getFirstName();
$lastName = $fakeCard->getLastName();
$email = $fakeCard->getEmail();
Expand Down Expand Up @@ -152,8 +152,8 @@ public function testSendSuccess()
}
$this->assertSame($cardLastFour, $card->getNumberLastFour());
$this->assertSame($cardBrand, $card->getBrand());
$this->assertSame($expiryMonth, $card->getExpiryMonth());
$this->assertSame($expiryYear, $card->getExpiryYear());
$this->assertSame($expiryMonth, (string) $card->getExpiryMonth());
$this->assertSame($expiryYear, (string) $card->getExpiryYear());
$this->assertSame($firstName, $card->getFirstName());
$this->assertSame($lastName, $card->getLastName());
$this->assertSame($email, $card->getEmail());
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/FetchCanceledSubscriptionsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function testSendSuccess()
$this->assertFalse($response->isRedirect());
$this->assertSame('200', $response->getCode());
$subscriptions = $response->getSubscriptions();
$this->assertSame(2, count($subscriptions));
$this->assertCount(2, $subscriptions);
if ($subscriptions) {
foreach ($subscriptions as $i => $subscription) {
$fakeSubscription = $fakeSubscriptions[intval($i) + 1];
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/FetchSubscriptionsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function testSendSuccess()
$this->assertFalse($response->isRedirect());
$this->assertSame('200', $response->getCode());
$subscriptions = $response->getSubscriptions();
$this->assertSame(2, count($subscriptions));
$this->assertCount(2, $subscriptions);
if ($subscriptions) {
foreach ($subscriptions as $i => $subscription) {
$fakeSubscription = $fakeSubscriptions[intval($i) + 1];
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/FetchTransactionsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function testSendSuccess()
$this->assertFalse($response->isRedirect());
$this->assertSame('200', $response->getCode());
$transactions = $response->getTransactions();
$this->assertSame(2, count($transactions));
$this->assertCount(2, $transactions);
if ($transactions) {
foreach ($transactions as $i => $transaction) {
$fakeTransaction = $fakeTransactions[intval($i) + 1];
Expand Down

0 comments on commit fbf3344

Please sign in to comment.