Skip to content

Commit bd6fd47

Browse files
authored
Merge pull request #282 from TomA-R/dep_warning
Fix deprecation warning and upgrade PHPUnit
2 parents cb1bbed + 00d615e commit bd6fd47

File tree

9 files changed

+60
-64
lines changed

9 files changed

+60
-64
lines changed

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
"ecommerce",
1010
"business"
1111
],
12-
"homepage": "http://developer.bigcommerce.com",
12+
"homepage": "https://developer.bigcommerce.com",
1313
"license": "MIT",
1414
"authors": [
1515
{
1616
"name": "Bigcommerce",
17-
"homepage": "http://www.bigcommerce.com"
17+
"homepage": "https://www.bigcommerce.com"
1818
}
1919
],
2020
"require": {
21-
"php": ">=7.0",
21+
"php": ">=7.1",
2222
"firebase/php-jwt": "~3.0 || ~5.0",
2323
"ext-curl": "*"
2424
},
2525
"require-dev": {
2626
"codeless/jugglecode": "1.0",
27-
"friendsofphp/php-cs-fixer": "^2.13",
28-
"php-coveralls/php-coveralls": "2.1",
29-
"phpunit/phpunit": "^6.4 || ^7.4"
27+
"friendsofphp/php-cs-fixer": "^3.13",
28+
"php-coveralls/php-coveralls": "2.5",
29+
"phpunit/phpunit": "^9.5"
3030
},
3131
"autoload": {
3232
"psr-0": {

phpunit.xml.dist

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation='vendor/phpunit/phpunit/phpunit.xsd'
4-
backupGlobals="true"
5-
backupStaticAttributes="true"
6-
colors="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
forceCoversAnnotation="false"
11-
processIsolation="false"
12-
bootstrap="vendor/autoload.php">
13-
<logging>
14-
<log type="coverage-clover" target="build/logs/clover.xml"/>
15-
<log type="coverage-php" target="build/logs/coverage.cov"/>
16-
<log type="coverage-text" target="build/logs/coverage.txt" showUncoveredFiles="false"/>
17-
<log type="coverage-html" target="test/reports/coverage/" showUncoveredFiles="true"/>
18-
<log type="junit" target="test/reports/junit.xml"/>
19-
</logging>
20-
<testsuites>
21-
<testsuite name="test">
22-
<directory>test/</directory>
23-
</testsuite>
24-
</testsuites>
25-
<filter>
26-
<whitelist>
27-
<directory suffix=".php">src/</directory>
28-
</whitelist>
29-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="true" backupStaticAttributes="true" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" forceCoversAnnotation="false" processIsolation="false" bootstrap="vendor/autoload.php">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src/</directory>
6+
</include>
7+
<report>
8+
<clover outputFile="build/logs/clover.xml"/>
9+
<html outputDirectory="test/reports/coverage/"/>
10+
<php outputFile="build/logs/coverage.cov"/>
11+
<text outputFile="build/logs/coverage.txt" showUncoveredFiles="false"/>
12+
</report>
13+
</coverage>
14+
<logging>
15+
<junit outputFile="test/reports/junit.xml"/>
16+
</logging>
17+
<testsuites>
18+
<testsuite name="test">
19+
<directory>test/</directory>
20+
</testsuite>
21+
</testsuites>
3022
</phpunit>

src/Bigcommerce/Api/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ private static function mapCollection($resource, $object)
353353
$baseResource = __NAMESPACE__ . '\\' . $resource;
354354
self::$resource = (class_exists($baseResource)) ? $baseResource : 'Bigcommerce\\Api\\Resources\\' . $resource;
355355

356-
return array_map(array('self', 'mapCollectionObject'), $object);
356+
return array_map(array(self::class, 'mapCollectionObject'), $object);
357357
}
358358

359359
/**

src/Bigcommerce/Api/Connection.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ public function removeHeader($header)
241241
unset($this->headers[$header]);
242242
}
243243

244+
/**
245+
* Return the request headers
246+
*
247+
* @return array
248+
*/
249+
public function getRequestHeaders()
250+
{
251+
return $this->headers;
252+
}
253+
244254
/**
245255
* Get the MIME type that should be used for this request.
246256
*

test/Unit/Api/ClientTest.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ClientTest extends TestCase
1414
private $connection;
1515
private $basePath = '';
1616

17-
public function setUp()
17+
public function setUp(): void
1818
{
1919
$methods = array(
2020
'useXml',
@@ -37,15 +37,15 @@ public function setUp()
3737
'getHeaders',
3838
'__destruct'
3939
);
40-
$this->basePath = $this->getStaticAttribute('Bigcommerce\\Api\\Client', 'api_path');
40+
$this->basePath = Client::$api_path;
4141
$this->connection = $this->getMockBuilder('Bigcommerce\\Api\\Connection')
4242
->disableOriginalConstructor()
4343
->setMethods($methods)
4444
->getMock();
4545
Client::setConnection($this->connection);
4646
}
4747

48-
public function tearDown()
48+
public function tearDown(): void
4949
{
5050
Client::configure(array('username' => '', 'api_key' => '', 'store_url' => ''));
5151
unset($this->connection);
@@ -138,7 +138,9 @@ public function testGetCustomerLoginTokenReturnsValidLoginToken()
138138
);
139139
$token = Client::getCustomerLoginToken(1);
140140
$actualPayload = (array)\Firebase\JWT\JWT::decode($token, 'zyx', array('HS256'));
141-
$this->assertArraySubset($expectedPayload, $actualPayload);
141+
foreach ($expectedPayload as $value) {
142+
$this->assertContains($value, $actualPayload);
143+
}
142144
}
143145

144146
public function testGetCustomerLoginTokenThrowsIfNoClientSecret()
@@ -189,7 +191,7 @@ public function testGetCollectionReturnsCollectionOfSpecifiedTypes()
189191
Client::configure(array('store_url' => 'http://storeurl', 'username' => 'whatever', 'api_key' => 'whatever'));
190192
Client::setConnection($this->connection); // re-set the connection since Client::configure unsets it
191193
$resources = Client::getCollection('/whatever');
192-
$this->assertInternalType('array', $resources);
194+
$this->assertIsArray($resources);
193195
foreach ($resources as $resource) {
194196
$this->assertInstanceOf('Bigcommerce\\Api\\Resource', $resource);
195197
}
@@ -308,7 +310,7 @@ public function testGettingASpecificResourceReturnsACollectionOfThatResource($pa
308310
->will($this->returnValue(array(array(), array())));
309311

310312
$collection = Client::$fnName();
311-
$this->assertInternalType('array', $collection);
313+
$this->assertIsArray($collection);
312314
foreach ($collection as $resource) {
313315
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\' . $class, $resource);
314316
}
@@ -438,7 +440,7 @@ public function testGettingProductImagesReturnsCollectionOfProductImages()
438440
->will($this->returnValue(array(array(), array())));
439441

440442
$collection = Client::getProductImages(1);
441-
$this->assertInternalType('array', $collection);
443+
$this->assertIsArray($collection);
442444
$this->assertContainsOnlyInstancesOf('Bigcommerce\\Api\\Resources\\ProductImage', $collection);
443445
}
444446

@@ -450,7 +452,7 @@ public function testGettingProductCustomFieldsReturnsCollectionOfProductCustomFi
450452
->will($this->returnValue(array(array(), array())));
451453

452454
$collection = Client::getProductCustomFields(1);
453-
$this->assertInternalType('array', $collection);
455+
$this->assertIsArray($collection);
454456
foreach ($collection as $resource) {
455457
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\ProductCustomField', $resource);
456458
}
@@ -497,7 +499,7 @@ public function testGettingCustomerAddressesReturnsCollectionOfCustomerAddresses
497499
->will($this->returnValue(array(array(), array())));
498500

499501
$collection = Client::getCustomerAddresses(1);
500-
$this->assertInternalType('array', $collection);
502+
$this->assertIsArray($collection);
501503
foreach ($collection as $resource) {
502504
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\Address', $resource);
503505
}
@@ -511,7 +513,7 @@ public function testGettingOptionValuesReturnsCollectionOfOptionValues()
511513
->will($this->returnValue(array(array(), array())));
512514

513515
$collection = Client::getOptionValues();
514-
$this->assertInternalType('array', $collection);
516+
$this->assertIsArray($collection);
515517
foreach ($collection as $resource) {
516518
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\OptionValue', $resource);
517519
}
@@ -713,7 +715,7 @@ public function testGettingOrderProductsReturnsTheOrderProductsCollection()
713715
->will($this->returnValue(array(array(), array())));
714716

715717
$collection = Client::getOrderProducts(1);
716-
$this->assertInternalType('array', $collection);
718+
$this->assertIsArray($collection);
717719
foreach ($collection as $resource) {
718720
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\OrderProduct', $resource);
719721
}
@@ -727,7 +729,7 @@ public function testGettingOrderShipmentsReturnsTheOrderShipmentsResource()
727729
->will($this->returnValue(array(array(), array())));
728730

729731
$collection = Client::getShipments(1);
730-
$this->assertInternalType('array', $collection);
732+
$this->assertIsArray($collection);
731733
foreach ($collection as $resource) {
732734
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\Shipment', $resource);
733735
}
@@ -788,7 +790,7 @@ public function testGettingOrderShippingAddressesReturnsTheAddressResource()
788790
->will($this->returnValue(array(array(), array())));
789791

790792
$collection = Client::getOrderShippingAddresses(1);
791-
$this->assertInternalType('array', $collection);
793+
$this->assertIsArray($collection);
792794
foreach ($collection as $resource) {
793795
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\Address', $resource);
794796
}
@@ -858,7 +860,7 @@ public function testGettingWebhooksReturnsAllWebhooks()
858860
->with($this->basePath . '/hooks', false)
859861
->will($this->returnValue(array(new \Bigcommerce\Api\Resource(),new \Bigcommerce\Api\Resource())));
860862
$collection = Client::listWebhooks();
861-
$this->assertInternalType('array', $collection);
863+
$this->assertIsArray($collection);
862864
foreach ($collection as $resource) {
863865
$this->assertInstanceOf('Bigcommerce\\Api\\Resource', $resource);
864866
}

test/Unit/Api/ConnectionTest.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,15 @@ class ConnectionTest extends TestCase
1212
*/
1313
protected $object;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
$this->object = new Connection();
1818
}
1919

20-
public function testFailOnError()
21-
{
22-
$this->object->failOnError(false);
23-
$this->assertAttributeSame(false, 'failOnError', $this->object);
24-
$this->object->failOnError(true);
25-
$this->assertAttributeSame(true, 'failOnError', $this->object);
26-
}
27-
2820
public function testAddHeader()
2921
{
3022
$this->object->addHeader('Content-Length', 4);
31-
$this->assertAttributeContains('Content-Length: 4', 'headers', $this->object);
23+
$this->assertContains('Content-Length: 4', $this->object->getRequestHeaders());
3224
}
3325

3426
/**
@@ -38,6 +30,6 @@ public function testRemoveHeader()
3830
{
3931
$this->object->addHeader('Content-Length', 4);
4032
$this->object->removeHeader('Content-Length');
41-
$this->assertAttributeNotContains('Content-Length: 4', 'headers', $this->object);
33+
$this->assertNotContains('Content-Length: 4', $this->object->getRequestHeaders());
4234
}
4335
}

test/Unit/Api/Resources/ProductTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testPropertyCollectionsPassThroughToTheConnection($property, $cl
6363
->will($this->returnValue(array(array(), array())));
6464

6565
$collection = $product->$property;
66-
$this->assertInternalType('array', $collection);
66+
$this->assertIsArray($collection);
6767
foreach ($collection as $value) {
6868
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\' . $className, $value);
6969
}

test/Unit/Api/Resources/ResourceTestBase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ResourceTestBase extends TestCase
1313
protected $connection;
1414
protected $basePath = '';
1515

16-
public function setUp()
16+
public function setUp(): void
1717
{
1818
$methods = array(
1919
'useXml',
@@ -40,7 +40,7 @@ public function setUp()
4040
->disableOriginalConstructor()
4141
->setMethods($methods)
4242
->getMock();
43-
$this->basePath = $this->getStaticAttribute('Bigcommerce\\Api\\Client', 'api_path');
43+
$this->basePath = Client::$api_path;
4444
Client::setConnection($this->connection);
4545
}
4646
}

test/Unit/Api/Resources/RuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testConditionsPassesThroughToConnection()
3838
->will($this->returnValue(array(array(), array())));
3939

4040
$collection = $rule->conditions;
41-
$this->assertInternalType('array', $collection);
41+
$this->assertIsArray($collection);
4242
foreach ($collection as $condition) {
4343
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\RuleCondition', $condition);
4444
}

0 commit comments

Comments
 (0)