Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 94e9fa6

Browse files
committed
Merge branch 'hotfix/v2.12.1'
2 parents 5380d1f + d2cff12 commit 94e9fa6

File tree

5 files changed

+93
-10
lines changed

5 files changed

+93
-10
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [2.12.1](https://github.com/commercetools/commercetools-php-sdk/compare/v2.12.0...v2.12.1) (2020-10-30)
2+
3+
4+
### Bug Fixes
5+
6+
* **Client:** fix adapter factory to correctly identify the GuzzleAdapter ([221b690](https://github.com/commercetools/commercetools-php-sdk/commit/221b69018badbc26a49dcbcb619509c2daccb0b9))
7+
8+
9+
110
# [2.12.0](https://github.com/commercetools/commercetools-php-sdk/compare/v2.11.1...v2.12.0) (2020-10-12)
211

312

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "commercetools-php-sdk-changelog",
3-
"version": "2.12.0",
3+
"version": "2.12.1",
44
"description": "commercetools PHP SDK changelog generator package description",
55
"homepage": "https://github.com/commercetools/commercetools-php-sdk",
66
"bugs": "https://github.com/commercetools/commercetools-php-sdk/issues",

src/Core/Client/Adapter/AdapterFactory.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,8 @@ public function register($name, $adapterClass)
3939
public function getClass($name = null)
4040
{
4141
if (is_null($name)) {
42-
if (defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
43-
$name = 'guzzle6';
44-
} elseif (version_compare(Client::class . '::VERSION', '6.0.0', '>=')) {
45-
$name = 'guzzle6';
46-
} else {
42+
$name = "guzzle6";
43+
if (defined('\GuzzleHttp\Client::VERSION') && version_compare(constant('\GuzzleHttp\Client::VERSION'), '6.0.0', '<')) {
4744
$name = 'guzzle5';
4845
}
4946
}

tests/integration/Cart/CartUpdateRequestTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,10 +1820,10 @@ function (Cart $cart) use ($client, $discountCode, $cartDiscount) {
18201820
$response = $this->execute($client, $request);
18211821
$cart = $request->mapFromResponse($response);
18221822

1823-
$this->assertSame(
1824-
$discountCode->getId(),
1825-
$cart->getDiscountCodes()->current()->getDiscountCode()->getId()
1826-
);
1823+
$this->assertSame(
1824+
$discountCode->getId(),
1825+
$cart->getDiscountCodes()->current()->getDiscountCode()->getId()
1826+
);
18271827
$this->assertSame(
18281828
$cartDiscount->getId(),
18291829
$cart->getLineItems()->current()
@@ -2622,6 +2622,15 @@ function (Cart $cart) use ($client, $project) {
26222622
$response = $this->execute($client, $request);
26232623
$request->mapFromResponse($response);
26242624

2625+
$this->eventually(function () use ($client) {
2626+
$request = RequestBuilder::of()->project()->get();
2627+
$response = $this->execute($client, $request);
2628+
$project = $request->mapFromResponse($response);
2629+
2630+
$this->assertInstanceOf(CartScoreType::class, $project->getShippingRateInputType());
2631+
return $project;
2632+
});
2633+
26252634
$request = RequestBuilder::of()->carts()->update($cart)
26262635
->addAction(
26272636
CartSetShippingRateInputAction::of()
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
namespace Commercetools\Core\Client;
4+
5+
use Commercetools\Core\Client\Adapter\AdapterFactory;
6+
use Commercetools\Core\Client\Adapter\Guzzle5Adapter;
7+
use Commercetools\Core\Client\Adapter\Guzzle6Adapter;
8+
use PHPUnit\Framework\TestCase;
9+
10+
class AdapterFactoryTest extends TestCase
11+
{
12+
public function testGetClassGuzzle5()
13+
{
14+
$adapter = new AdapterFactory();
15+
if (defined('\GuzzleHttp\Client::VERSION') && strpos(constant('\GuzzleHttp\Client::VERSION'), '5.') === 0) {
16+
$this->assertSame(Guzzle5Adapter::class, $adapter->getClass());
17+
} else {
18+
$this->markTestSkipped("No guzzle 5 installed");
19+
}
20+
}
21+
22+
public function testGetClassGuzzle6()
23+
{
24+
$adapter = new AdapterFactory();
25+
if (defined('\GuzzleHttp\Client::VERSION') && strpos(constant('\GuzzleHttp\Client::VERSION'), '6.') === 0) {
26+
$this->assertSame(Guzzle6Adapter::class, $adapter->getClass());
27+
} else {
28+
$this->markTestSkipped("No guzzle 6 installed");
29+
}
30+
}
31+
32+
public function testGetClassGuzzle7()
33+
{
34+
$adapter = new AdapterFactory();
35+
if (defined('\GuzzleHttp\Client::MAJOR_VERSION') && constant('\GuzzleHttp\Client::MAJOR_VERSION') === 7) {
36+
$this->assertSame(Guzzle6Adapter::class, $adapter->getClass());
37+
} else {
38+
$this->markTestSkipped("No guzzle 6 installed");
39+
}
40+
}
41+
42+
/**
43+
* @dataProvider getClass
44+
*/
45+
public function testGetClassByName($adapterName, $expectedClassName)
46+
{
47+
$adapter = new AdapterFactory();
48+
$this->assertSame($expectedClassName, $adapter->getClass($adapterName));
49+
}
50+
51+
/**
52+
* @dataProvider getClass
53+
*/
54+
public function testGetAdapterByName($adapterName, $expectedClassName)
55+
{
56+
$adapter = new AdapterFactory();
57+
$this->assertInstanceOf($expectedClassName, $adapter->getAdapter($adapterName, []));
58+
}
59+
60+
61+
public function getClass()
62+
{
63+
return [
64+
'guzzle6' => ['guzzle6', Guzzle6Adapter::class],
65+
'guzzle5' => ['guzzle5', Guzzle5Adapter::class]
66+
];
67+
}
68+
}

0 commit comments

Comments
 (0)