Skip to content

Commit

Permalink
Bump Dependencies for PHP 8 (#47)
Browse files Browse the repository at this point in the history
* 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 <swilla@users.noreply.github.com>
  • Loading branch information
swilla and swilla authored Sep 16, 2021
1 parent ac8988f commit 9bde8f5
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 265 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AIRTABLE_KEY=
AIRTABLE_BASE=
AIRTABLE_TABLE=
46 changes: 46 additions & 0 deletions .github/run-tests-L7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Run Tests - Older"

on: [push, pull_request]

jobs:
test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [8.0, 7.4, 7.3, 7.2]
laravel: [7.*, 6.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 7.*
testbench: 5.*
- laravel: 6.*
testbench: 4.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "symfony/console:>=4.3.4" "mockery/mockery:^1.3.2" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
cp .env.example .env
- name: Execute tests
run: vendor/bin/phpunit
44 changes: 44 additions & 0 deletions .github/workflows/run-tests-l8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Run Tests - Current"

on: [push, pull_request]

jobs:
test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [8.0, 7.4, 7.3]
laravel: [8.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 8.*
testbench: 6.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "symfony/console:>=4.3.4" "mockery/mockery:^1.3.2" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
cp .env.example .env
- name: Execute tests
run: vendor/bin/phpunit
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ vendor
coverage
.env
.ac-php-conf.json
.phpunit.result.cache
.DS_Store
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
}
],
"require": {
"php": "^7.1 || ^8.0",
"php": "^7.3 || ^8.0",
"guzzlehttp/guzzle": "~6.0 || ~7.0",
"illuminate/support": "5.7.* || 5.8.* ||^6.0 || ^7.0 || ^8.0",
"symfony/dotenv": "^4.2 || ^5.1"
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/testbench": "3.7.*",
"phpunit/phpunit": "^7.0"
"mockery/mockery": "^1.4",
"orchestra/testbench": "^5.0 || ^6.0",
"phpunit/phpunit": "^8.4 || ^9.3.3"
},
"autoload": {
"psr-4": {
Expand Down
51 changes: 26 additions & 25 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<php>
<env name="APP_ENV" value="test" />
<env name="APP_ENV" value="test"/>
</php>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
6 changes: 3 additions & 3 deletions src/Airtable.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function create($data)
}

/**
* @param dynamic $args (string) $id, $data | (array) $data
* @param dynamic $args (string) $id, $data | (array) $data
* @return mixed
*
* @throws \InvalidArgumentException
Expand All @@ -45,7 +45,7 @@ public function update(...$args)
}

/**
* @param dynamic $args (string) $id, $data | (array) $data
* @param dynamic $args (string) $id, $data | (array) $data
* @return mixed
*
* @throws \InvalidArgumentException
Expand Down Expand Up @@ -123,7 +123,7 @@ public function firstOrCreate(array $idData, array $createData = [])

// first
if ($results->isNotEmpty()) {
return $results->first();
return $results;
}

// create
Expand Down
2 changes: 1 addition & 1 deletion src/AirtableManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function getConfig($name)
* Dynamically pass methods to the default connection.
*
* @param string $method
* @param array $parameters
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
Expand Down
24 changes: 6 additions & 18 deletions src/Api/AirtableApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tapp\Airtable\Api;

use GuzzleHttp\Client;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;

class AirtableApiClient implements ApiClient
Expand All @@ -21,36 +21,24 @@ class AirtableApiClient implements ApiClient
private $pageSize = 100;
private $maxRecords = 100;

public function __construct($base, $table, $access_token, $httpLogFormat = null, Client $client = null, $typecast = false, $delayBetweenRequests = 200000)
public function __construct($base, $table, $access_token, $httpLogFormat = null, Http $client = null, $typecast = false, $delayBetweenRequests = 200000)
{
$this->base = $base;
$this->table = $table;
$this->typecast = $typecast;
$this->delay = $delayBetweenRequests;

$stack = \GuzzleHttp\HandlerStack::create();

if ($httpLogFormat) {
$stack->push(
\GuzzleHttp\Middleware::log(
new \Monolog\Logger('Logger'),
new \GuzzleHttp\MessageFormatter($httpLogFormat)
)
);
}

$this->client = $client ?? $this->buildClient($access_token, $stack);
$this->client = $client ?? $this->buildClient($access_token);
}

private function buildClient($access_token, $stack)
private function buildClient($access_token)
{
return new Client([
return Http::withOptions([
'base_uri' => 'https://api.airtable.com',
'headers' => [
'Authorization' => "Bearer {$access_token}",
'content-type' => 'application/json',
],
'handler' => $stack,
]);
}

Expand Down Expand Up @@ -191,7 +179,7 @@ public function decodeResponse($response)
return [];
}

return json_decode($body, true);
return collect(json_decode($body, true));
}

public function setFields(?array $fields)
Expand Down
Loading

0 comments on commit 9bde8f5

Please sign in to comment.