Skip to content

Commit 9bde8f5

Browse files
authored
Bump Dependencies for PHP 8 (#47)
* bump up requirements for php8 support * Apply fixes from StyleCI [ci skip] [skip ci] * remove travis * upgrade phpunit * update test suite * Apply fixes from StyleCI [ci skip] [skip ci] * fix tests * Apply fixes from StyleCI [ci skip] [skip ci] * github actions * copy .env * missing file * remove unit tests * fix config file * fix config file * fix tests * formatting * laravel 7 Co-authored-by: Steve Williamson <[email protected]>
1 parent ac8988f commit 9bde8f5

File tree

13 files changed

+285
-265
lines changed

13 files changed

+285
-265
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
AIRTABLE_KEY=
2+
AIRTABLE_BASE=
3+
AIRTABLE_TABLE=

.github/run-tests-L7.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Run Tests - Older"
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php: [8.0, 7.4, 7.3, 7.2]
13+
laravel: [7.*, 6.*]
14+
dependency-version: [prefer-lowest, prefer-stable]
15+
include:
16+
- laravel: 7.*
17+
testbench: 5.*
18+
- laravel: 6.*
19+
testbench: 4.*
20+
21+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v2
26+
27+
- name: Cache dependencies
28+
uses: actions/cache@v2
29+
with:
30+
path: ~/.composer/cache/files
31+
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
32+
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: ${{ matrix.php }}
37+
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
38+
coverage: none
39+
40+
- name: Install dependencies
41+
run: |
42+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "symfony/console:>=4.3.4" "mockery/mockery:^1.3.2" --no-interaction --no-update
43+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
44+
cp .env.example .env
45+
- name: Execute tests
46+
run: vendor/bin/phpunit

.github/workflows/run-tests-l8.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: "Run Tests - Current"
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php: [8.0, 7.4, 7.3]
13+
laravel: [8.*]
14+
dependency-version: [prefer-lowest, prefer-stable]
15+
include:
16+
- laravel: 8.*
17+
testbench: 6.*
18+
19+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v2
24+
25+
- name: Cache dependencies
26+
uses: actions/cache@v2
27+
with:
28+
path: ~/.composer/cache/files
29+
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
30+
31+
- name: Setup PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: ${{ matrix.php }}
35+
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
36+
coverage: none
37+
38+
- name: Install dependencies
39+
run: |
40+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "symfony/console:>=4.3.4" "mockery/mockery:^1.3.2" --no-interaction --no-update
41+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
42+
cp .env.example .env
43+
- name: Execute tests
44+
run: vendor/bin/phpunit

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ vendor
55
coverage
66
.env
77
.ac-php-conf.json
8+
.phpunit.result.cache
9+
.DS_Store

.travis.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^7.1 || ^8.0",
19+
"php": "^7.3 || ^8.0",
2020
"guzzlehttp/guzzle": "~6.0 || ~7.0",
2121
"illuminate/support": "5.7.* || 5.8.* ||^6.0 || ^7.0 || ^8.0",
2222
"symfony/dotenv": "^4.2 || ^5.1"
2323
},
2424
"require-dev": {
25-
"mockery/mockery": "^1.0",
26-
"orchestra/testbench": "3.7.*",
27-
"phpunit/phpunit": "^7.0"
25+
"mockery/mockery": "^1.4",
26+
"orchestra/testbench": "^5.0 || ^6.0",
27+
"phpunit/phpunit": "^8.4 || ^9.3.3"
2828
},
2929
"autoload": {
3030
"psr-4": {

phpunit.xml.dist

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

src/Airtable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function create($data)
2424
}
2525

2626
/**
27-
* @param dynamic $args (string) $id, $data | (array) $data
27+
* @param dynamic $args (string) $id, $data | (array) $data
2828
* @return mixed
2929
*
3030
* @throws \InvalidArgumentException
@@ -45,7 +45,7 @@ public function update(...$args)
4545
}
4646

4747
/**
48-
* @param dynamic $args (string) $id, $data | (array) $data
48+
* @param dynamic $args (string) $id, $data | (array) $data
4949
* @return mixed
5050
*
5151
* @throws \InvalidArgumentException
@@ -123,7 +123,7 @@ public function firstOrCreate(array $idData, array $createData = [])
123123

124124
// first
125125
if ($results->isNotEmpty()) {
126-
return $results->first();
126+
return $results;
127127
}
128128

129129
// create

src/AirtableManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function getConfig($name)
142142
* Dynamically pass methods to the default connection.
143143
*
144144
* @param string $method
145-
* @param array $parameters
145+
* @param array $parameters
146146
* @return mixed
147147
*/
148148
public function __call($method, $parameters)

src/Api/AirtableApiClient.php

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Tapp\Airtable\Api;
44

5-
use GuzzleHttp\Client;
5+
use Illuminate\Support\Facades\Http;
66
use Illuminate\Support\Str;
77

88
class AirtableApiClient implements ApiClient
@@ -21,36 +21,24 @@ class AirtableApiClient implements ApiClient
2121
private $pageSize = 100;
2222
private $maxRecords = 100;
2323

24-
public function __construct($base, $table, $access_token, $httpLogFormat = null, Client $client = null, $typecast = false, $delayBetweenRequests = 200000)
24+
public function __construct($base, $table, $access_token, $httpLogFormat = null, Http $client = null, $typecast = false, $delayBetweenRequests = 200000)
2525
{
2626
$this->base = $base;
2727
$this->table = $table;
2828
$this->typecast = $typecast;
2929
$this->delay = $delayBetweenRequests;
3030

31-
$stack = \GuzzleHttp\HandlerStack::create();
32-
33-
if ($httpLogFormat) {
34-
$stack->push(
35-
\GuzzleHttp\Middleware::log(
36-
new \Monolog\Logger('Logger'),
37-
new \GuzzleHttp\MessageFormatter($httpLogFormat)
38-
)
39-
);
40-
}
41-
42-
$this->client = $client ?? $this->buildClient($access_token, $stack);
31+
$this->client = $client ?? $this->buildClient($access_token);
4332
}
4433

45-
private function buildClient($access_token, $stack)
34+
private function buildClient($access_token)
4635
{
47-
return new Client([
36+
return Http::withOptions([
4837
'base_uri' => 'https://api.airtable.com',
4938
'headers' => [
5039
'Authorization' => "Bearer {$access_token}",
5140
'content-type' => 'application/json',
5241
],
53-
'handler' => $stack,
5442
]);
5543
}
5644

@@ -191,7 +179,7 @@ public function decodeResponse($response)
191179
return [];
192180
}
193181

194-
return json_decode($body, true);
182+
return collect(json_decode($body, true));
195183
}
196184

197185
public function setFields(?array $fields)

0 commit comments

Comments
 (0)