Skip to content

Commit

Permalink
Merge pull request #3
Browse files Browse the repository at this point in the history
[1.x] Adds PHP 8.2, Laravel 10 support
  • Loading branch information
DarkGhostHunter authored Feb 25, 2023
2 parents 1e5fb53 + 2ee9bce commit e3e1a49
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 53 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ jobs:
php-version:
- "8.0"
- "8.1"
- "8.2"
laravel-constrain:
- "9.*"
- "10.*"
dependencies:
- "lowest"
- "highest"
exclude:
- laravel-constrain: "10.*"
php-version: "8.0"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
Expand All @@ -77,7 +82,7 @@ jobs:
run: "composer run-script test"

- name: "Upload coverage to Codecov"
uses: "codecov/codecov-action@v2"
uses: "codecov/codecov-action@v3"

static_analysis:
name: "3️⃣ Static Analysis"
Expand All @@ -91,6 +96,7 @@ jobs:
with:
tools: "phpstan"
php-version: "latest"
coverage: "none"

- name: "Checkout code"
uses: "actions/checkout@v3"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
/coverage
/.idea
.phpunit.result.cache
.phpunit.cache
phpunit.xml.dist.bak
composer.lock
30 changes: 10 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,24 @@
{
"name": "Italo Israel Baeza Cabrera",
"email": "darkghosthunter@gmail.com",
"homepage": "https://patreon.com/packagesforlaravel"
"homepage": "https://github.com/sponsors/DarkGhostHunter"
}
],
"support": {
"source": "https://github.com/Laragear/Transbank",
"issues": "https://github.com/Laragear/Transbank/issues"
},
"require": {
"php": "^8.0.2",
"php": "8.*",
"ext-json": "*",
"illuminate/http": "9.*",
"illuminate/log": "9.*",
"illuminate/events": "9.*",
"guzzlehttp/guzzle": "^7.2"
"illuminate/http": "9.*|10.*",
"illuminate/log": "9.*|10.*",
"illuminate/events": "9.*|10.*",
"guzzlehttp/guzzle": "^7.5"
},
"require-dev": {
"orchestra/testbench": "7.*",
"phpunit/phpunit": "^9.5",
"mockery/mockery": "^1.4",
"jetbrains/phpstorm-attributes": "^1.0"
"orchestra/testbench": "^7.22|8.*",
"jetbrains/phpstorm-attributes": "*"
},
"autoload": {
"psr-4": {
Expand All @@ -62,22 +60,14 @@
"Laragear\\Transbank\\TransbankServiceProvider"
],
"aliases": {
"ReCaptcha": "Laragear\\Transbank\\Facades\\Webpay"
"Webpay": "Laragear\\Transbank\\Facades\\Webpay"
}
}
},
"funding": [
{
"type": "Patreon",
"url": "https://patreon.com/PackagesForLaravel"
},
{
"type": "Ko-Fi",
"url": "https://ko-fi.com/DarkGhostHunter"
},
{
"type": "Buy me a cofee",
"url": "https://www.buymeacoffee.com/darkghosthunter"
"url": "https://github.com/sponsors/DarkGhostHunter"
},
{
"type": "Paypal",
Expand Down
46 changes: 20 additions & 26 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/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.5/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_DEBUG" value="true"/>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="DB_CONNECTION" value="testing"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_DEBUG" value="true"/>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="DB_CONNECTION" value="testing"/>
</php>
</phpunit>
3 changes: 2 additions & 1 deletion src/ApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Laragear\Transbank;

use ArrayAccess;
use Error;
use Illuminate\Contracts\Support\Jsonable;
use JsonSerializable;

Expand Down Expand Up @@ -64,7 +65,7 @@ public function offsetExists(mixed $offset): bool
*/
public function offsetGet(mixed $offset): mixed
{
return $this->attributes[$offset];
return $this->attributes[$offset] ?? throw new Error("Undefined array key \"$offset\"");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Client
*
* @var string
*/
public const API_VERSION = 'v1.2';
public const API_VERSION = 'v1.3';

/**
* Transbank API Key header name.
Expand Down
5 changes: 3 additions & 2 deletions tests/ApiRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests;

use Error;
use Laragear\Transbank\ApiRequest;
use PHPUnit\Framework\TestCase as PHPUnitTestCase;

Expand Down Expand Up @@ -37,8 +38,8 @@ public function test_array_access(): void

public function test_exception_on_non_existent_key(): void
{
$this->expectError();
$this->expectErrorMessage('Undefined array key "bar"');
$this->expectException(Error::class);
$this->expectExceptionMessage('Undefined array key "bar"');

$request = new ApiRequest('foo', 'bar', [
'foo' => 'bar'
Expand Down
4 changes: 2 additions & 2 deletions tests/Http/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static function (): MockInterface {
->with(['synchronous' => true])
->andReturnSelf();

$mock->expects('send')->with('post', 'https://endpoint/v1.2/', ['json' => ['foo' => 'bar']])->andReturn(static::response());
$mock->expects('send')->with('post', 'https://endpoint/v1.3/', ['json' => ['foo' => 'bar']])->andReturn(static::response());

return $mock;
}
Expand Down Expand Up @@ -403,7 +403,7 @@ public function test_doesnt_sends_api_data_when_method_is_read(): void
static function (): MockInterface {
$pending = Mockery::mock(PendingRequest::class)->makePartial();

$pending->expects('send')->with('get', 'https://endpoint/v1.2/', [])->andReturn(static::response());
$pending->expects('send')->with('get', 'https://endpoint/v1.3/', [])->andReturn(static::response());

return $pending;
}
Expand Down

0 comments on commit e3e1a49

Please sign in to comment.