Skip to content
This repository has been archived by the owner on Mar 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #59 from BenMorel/master
Browse files Browse the repository at this point in the history
Fix issue when looking up by ASIN number
  • Loading branch information
Exeu committed Jan 1, 2015
2 parents 12101e6 + 776f6bc commit a235f86
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ApaiIO/Operations/Lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function setIdType($idType)

$this->parameter['IdType'] = $idType;

if (empty($this->parameter['SearchIndex'])) {
if (empty($this->parameter['SearchIndex']) && $idType != self::TYPE_ASIN) {
$this->parameter['SearchIndex'] = 'All';
}

Expand Down
34 changes: 34 additions & 0 deletions tests/ApaiIO/Test/Operations/Types/LookupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,40 @@ public function testGetIdType()
}
}

/**
* @dataProvider providerSetIdTypeAffectsSearchIndex
*
* @param string $idType
* @param string|null $expectedSearchIndex
*/
public function testSetIdTypeAffectsSearchIndex($idType, $expectedSearchIndex)
{
$lookup = new Lookup();
$lookup->setIdType($idType);

$parameters = $lookup->getOperationParameter();

if ($expectedSearchIndex === null) {
$this->assertArrayNotHasKey('SearchIndex', $parameters);
} else {
$this->assertSame($expectedSearchIndex, $parameters['SearchIndex']);
}
}

/**
* @return array
*/
public function providerSetIdTypeAffectsSearchIndex()
{
return array(
array(Lookup::TYPE_ASIN, null),
array(Lookup::TYPE_SKU, 'All'),
array(Lookup::TYPE_UPC, 'All'),
array(Lookup::TYPE_EAN, 'All'),
array(Lookup::TYPE_ISBN, 'All')
);
}

/**
* @expectedException InvalidArgumentException
*/
Expand Down

0 comments on commit a235f86

Please sign in to comment.