Skip to content

Commit

Permalink
Merge pull request #17 from grongor/fix-int-productids
Browse files Browse the repository at this point in the history
Fix unintentional string to int conversion - Fixes #13
  • Loading branch information
grongor committed Apr 28, 2016
2 parents fdc4611 + b979cdc commit 11f6d99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/ShopCertification.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ public function addProductItemId($productItemId)
{
$productItemId = (string)$productItemId;

if (isset($this->productItemIds[$productItemId])) {
if (array_search($productItemId, $this->productItemIds) !== false) {
throw new DuplicateProductItemIdException(
'The productItemId "%s" was already added. Please check the implementation.'
);
}

$this->productItemIds[$productItemId] = true;
$this->productItemIds[] = $productItemId;

return $this;
}
Expand Down Expand Up @@ -160,7 +160,7 @@ public function logOrder()
$data['orderId'] = $this->orderId;
}

$data['productItemIds'] = array_keys($this->productItemIds);
$data['productItemIds'] = $this->productItemIds;

$result = $this->requester->request(IRequester::ACTION_LOG_ORDER, $data);
if ($result->code !== 200) {
Expand Down
8 changes: 4 additions & 4 deletions tests/ShopCertificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testLogOrderSuccess()

$requester->shouldReceive('request')
->once()
->with(IRequester::ACTION_LOG_ORDER, $data)
->with(IRequester::ACTION_LOG_ORDER, Mockery::mustBe($data))
->andReturn($response);

$shopCertification = new ShopCertification($apiKey, [], $requester);
Expand Down Expand Up @@ -87,7 +87,7 @@ public function testLogOrderSuccessWithoutOptionalFields()

$requester->shouldReceive('request')
->once()
->with(IRequester::ACTION_LOG_ORDER, $data)
->with(IRequester::ACTION_LOG_ORDER, Mockery::mustBe($data))
->andReturn($response);

$shopCertification = new ShopCertification($apiKey, [], $requester);
Expand Down Expand Up @@ -133,7 +133,7 @@ public function testLogOrderFailure()

$requester->shouldReceive('request')
->once()
->with(IRequester::ACTION_LOG_ORDER, $data)
->with(IRequester::ACTION_LOG_ORDER, Mockery::mustBe($data))
->andReturn($response);

$shopCertification = new ShopCertification($apiKey, [], $requester);
Expand Down Expand Up @@ -168,7 +168,7 @@ public function testLogOrderDoubleSend()

$requester->shouldReceive('request')
->once()
->with(IRequester::ACTION_LOG_ORDER, $data)
->with(IRequester::ACTION_LOG_ORDER, Mockery::mustBe($data))
->andReturn($response);

$shopCertification = new ShopCertification($apiKey, [], $requester);
Expand Down

0 comments on commit 11f6d99

Please sign in to comment.