Skip to content

Commit

Permalink
Merge pull request #28 from Soapbox/change/update-to-laravel-8
Browse files Browse the repository at this point in the history
[Change] Update to Laravel 8
  • Loading branch information
Isaac Andrade authored May 14, 2021
2 parents 3a63085 + d0a7740 commit ecce8e9
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 76 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 7.2.27
- 7.3
- 7.4

Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
],
"minimum-stability": "stable",
"require": {
"php": ">=7.2",
"guzzlehttp/guzzle": "^6.2",
"illuminate/http": "^7.0",
"illuminate/support": "^7.0",
"nesbot/carbon": "^2.0",
"ramsey/uuid": "^3.6"
"php": "^7.3 || ^8.0",
"guzzlehttp/guzzle": "^7.2",
"illuminate/http": "^8.12",
"illuminate/support": "^8.12",
"nesbot/carbon": "^2.13",
"ramsey/uuid": "^4.0"
},
"require-dev": {
"jshayes/fake-requests": "dev-master",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^8.0",
"php-coveralls/php-coveralls": "^2.0"
"mockery/mockery": "^1.4",
"orchestra/testbench": "^6.3",
"phpunit/phpunit": "^9.3",
"php-coveralls/php-coveralls": "^2.4"
},
"autoload": {
"psr-4": {
Expand Down
30 changes: 11 additions & 19 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="All">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="All">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion src/Requests/Payload.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function generateFromPsr7Request(Psr7Request $request) : string
}

/**
* Retruns the payload from an illuminate request.
* Returns the payload from an illuminate request.
*
* @param \Illuminate\Http\Request $request
* An instance of the illuminate request to extract the payload from.
Expand Down
2 changes: 1 addition & 1 deletion src/Requests/Verifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Verifier
/**
* The underlying request that has the signature to validate.
*
* @var \Illluminate\Http\Request
* @var \Illuminate\Http\Request
*/
protected $request;

Expand Down
53 changes: 18 additions & 35 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use Carbon\Carbon;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidFactory;
use Ramsey\Uuid\UuidInterface;
use JSHayes\FakeRequests\MockHandler;
use Ramsey\Uuid\UuidFactoryInterface;
use JSHayes\FakeRequests\ClientFactory;
use SoapBox\SignedRequests\Configurations\CustomConfiguration;
use SoapBox\SignedRequests\Middlewares\Guzzle\GenerateSignature;
Expand All @@ -14,45 +15,27 @@ class ClientTest extends TestCase
{
private function expectUuid4(string $uuid): void
{
Uuid::setFactory(new class($uuid) implements UuidFactoryInterface {
public function __construct(string $uuid)
Uuid::setFactory(new class($uuid) extends UuidFactory {
public function __construct($uuid)
{
$this->uuid = $uuid;
}
$this->customUuid = $uuid;

public function uuid1($node = null, $clockSeq = null)
{
return null;
}

public function uuid3($ns, $name)
{
return null;
}

public function uuid4()
{
return $this->uuid;
}

public function uuid5($ns, $name)
{
return null;
}

public function fromBytes($bytes)
{
return null;
}

public function fromString($uuid)
{
return null;
parent::__construct();
}

public function fromInteger($integer)
public function uuid4(): UuidInterface
{
return null;
return new class($this->customUuid) extends Uuid {
public function __construct($uuid)
{
$this->customUuid = $uuid;
}

public function toString(): string
{
return $this->customUuid;
}
};
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Configurations/CustomConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CustomConfigurationTest extends TestCase
/**
* @test
*/
function it_returns_the_set_values_when_requested()
public function it_returns_the_set_values_when_requested()
{
$algorithmHeader = 'a';
$signatureHeader = 's';
Expand Down
10 changes: 5 additions & 5 deletions tests/Configurations/RepositoryConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RepositoryConfigurationTest extends TestCase
/**
* @before
*/
function setup_repository()
public function setup_repository()
{
$this->repository = Mockery::mock(Repository::class);
$this->configuration = new RepositoryConfiguration($this->repository);
Expand All @@ -24,7 +24,7 @@ function setup_repository()
/**
* @test
*/
function get_algorithm_header_returns_the_algorithm_header_value_from_the_configuration_repository()
public function get_algorithm_header_returns_the_algorithm_header_value_from_the_configuration_repository()
{
$this->repository->shouldReceive('get')
->with('signed-requests.headers.algorithm')
Expand All @@ -36,7 +36,7 @@ function get_algorithm_header_returns_the_algorithm_header_value_from_the_config
/**
* @test
*/
function get_signature_header_returns_the_signature_header_value_from_the_configuration_repository()
public function get_signature_header_returns_the_signature_header_value_from_the_configuration_repository()
{
$this->repository->shouldReceive('get')
->with('signed-requests.headers.signature')
Expand All @@ -48,7 +48,7 @@ function get_signature_header_returns_the_signature_header_value_from_the_config
/**
* @test
*/
function get_signing_algorithm_returns_the_signing_algorithm_to_use_from_the_configuration_repository()
public function get_signing_algorithm_returns_the_signing_algorithm_to_use_from_the_configuration_repository()
{
$this->repository->shouldReceive('get')
->with('signed-requests.algorithm')
Expand All @@ -60,7 +60,7 @@ function get_signing_algorithm_returns_the_signing_algorithm_to_use_from_the_con
/**
* @test
*/
function get_signing_key_returns_the_key_used_for_signing_the_request_from_the_configuration_repository()
public function get_signing_key_returns_the_key_used_for_signing_the_request_from_the_configuration_repository()
{
$this->repository->shouldReceive('get')
->with('signed-requests.key')
Expand Down
6 changes: 3 additions & 3 deletions tests/Requests/PayloadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function it_translates_a_guzzle_request_to_a_json_encoded_string()

$method = 'GET';
$uri = 'https://localhost';
$id = Uuid::uuid4();
$id = (string) Uuid::uuid4();

$request = (new GuzzleRequest('GET', 'https://localhost'))
->withHeader('X-SIGNED-ID', $id)
Expand All @@ -46,7 +46,7 @@ public function it_translates_a_guzzle_request_with_content_to_a_json_encoded_st

$method = 'GET';
$uri = 'https://localhost';
$id = Uuid::uuid4();
$id = (string) Uuid::uuid4();

$request = (new GuzzleRequest('GET', 'https://localhost', [], 'content'))
->withHeader('X-SIGNED-ID', $id)
Expand Down Expand Up @@ -152,7 +152,7 @@ public function it_upper_cases_the_guzzle_request_method()
$now = (string)Carbon::now();

$uri = 'https://localhost';
$id = Uuid::uuid4();
$id = (string)Uuid::uuid4();

$request = (new GuzzleRequest('get', 'https://localhost', [], 'content'))
->withHeader('X-SIGNED-ID', $id)
Expand Down

0 comments on commit ecce8e9

Please sign in to comment.