Skip to content

Commit

Permalink
Get marketplace from AmznSPA
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbrink committed Oct 12, 2021
1 parent c5dee33 commit c471ddc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/Traits/HasConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Jasara\AmznSPA\Traits;

use Jasara\AmznSPA\AmznSPAConfig;
use Jasara\AmznSPA\Constants\Marketplace;
use Jasara\AmznSPA\Exceptions\AmznSPAException;

trait HasConfig
Expand All @@ -24,6 +25,11 @@ public function getAccessToken(): string
return $tokens->access_token;
}

public function getMarketplace(): Marketplace
{
return $this->config->getMarketplace();
}

public function getMarketplaceId(): string
{
return $this->config->getMarketplace()->getIdentifier();
Expand Down
18 changes: 2 additions & 16 deletions tests/Unit/AmznSPATest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
use Jasara\AmznSPA\Resources\LwaResource;

/**
* @coversDefaultClass \Jasara\AmznSPA\AmznSPA
* @covers \Jasara\AmznSPA\AmznSPA
*/
class AmznSPATest extends UnitTestCase
{
/**
* @covers ::__get
*/
public function testInvalidResource()
{
$this->expectException(InvalidResourceException::class);
Expand All @@ -25,9 +22,6 @@ public function testInvalidResource()
$amzn->not_a_resource;
}

/**
* @covers ::__get
*/
public function testValidResource()
{
$amzn = new AmznSPA($this->setupMinimalConfig());
Expand All @@ -36,10 +30,6 @@ public function testValidResource()
$this->assertInstanceOf(LwaResource::class, $auth);
}

/**
* @covers ::__construct
* @covers ::usingMarketplace
*/
public function testUsingMarketplace()
{
$config = $this->setupMinimalConfig();
Expand All @@ -52,13 +42,9 @@ public function testUsingMarketplace()
// Doesn't change original object
$this->assertEquals($config->getMarketplace()->getIdentifier(), $amzn->getMarketplaceId());

$this->assertEquals($new_marketplace_id, $new_amzn->getMarketplaceId());
$this->assertEquals($new_marketplace_id, $new_amzn->getMarketplace()->getIdentifier());
}

/**
* @covers ::__construct
* @covers ::usingHttp
*/
public function testUsingHttp()
{
$state = Str::random();
Expand Down

0 comments on commit c471ddc

Please sign in to comment.