Skip to content

Commit

Permalink
Add support for Laravel 6.* (#109)
Browse files Browse the repository at this point in the history
* Support for Laravel 6.*

* Update .travis.yml
  • Loading branch information
vdbelt authored and sandervanhooft committed Sep 4, 2019
1 parent 5105fbd commit 85ef2f3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ env:
- LARAVEL='5.5.*' TESTBENCH='3.5.*'
- LARAVEL='5.6.*' TESTBENCH='3.6.*'
- LARAVEL='5.7.*' TESTBENCH='3.7.*'
- LARAVEL='5.8.*' TESTBENCH='3.8.*'
- LARAVEL='6.*' TESTBENCH='4.*'

cache:
directories:
Expand All @@ -26,10 +28,12 @@ matrix:
- php: nightly
include:
- php: 7.3
env: COVERAGE=1 LARAVEL='5.7.*' TESTBENCH='3.7.*'
env: COVERAGE=1 LARAVEL='6.*' TESTBENCH='4.*'
exclude:
- php: 7.1
env: LARAVEL='6.*' TESTBENCH='4.*'
- php: 7.3
env: LARAVEL='5.7.*' TESTBENCH='3.7.*'
env: LARAVEL='6.*' TESTBENCH='4.*'


before_script:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
],
"require": {
"php": ">=7.0.0",
"illuminate/support": "^5.5",
"illuminate/support": "^5.5|^6.0",
"mollie/mollie-api-php": "^2.9"
},
"require-dev": {
"graham-campbell/testbench": "^4.0|^5.0",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^6.5|^7.0",
"laravel/socialite": "^3.0"
"phpunit/phpunit": "^6.0|^7.0|^8.3",
"laravel/socialite": "^3.0|^4.0"
},
"suggest": {
"laravel/socialite": "Use Mollie Connect (OAuth) to authenticate via Laravel Socialite with the Mollie API. This is needed for some endpoints."
Expand Down
10 changes: 3 additions & 7 deletions tests/MollieConnectProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,25 @@ public function testRedirectGeneratesTheProperSymfonyRedirectResponse()
$provider = new MollieConnectProvider($request, 'client_id', 'client_secret', 'redirect');
$response = $provider->redirect();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
$this->assertContains(
$this->assertStringStartsWith(
'https://www.mollie.com/oauth2/authorize?client_id=client_id&redirect_uri=redirect&scope=organizations.read&response_type=code&state=',
$response->getTargetUrl()
);
}

/**
* @expectedException \Laravel\Socialite\Two\InvalidStateException
*/
public function testExceptionIsThrownIfStateIsInvalid()
{
$this->expectException(\Laravel\Socialite\Two\InvalidStateException::class);
$request = Request::create('foo', 'GET', ['state' => str_repeat('B', 40), 'code' => 'code']);
$request->setSession($session = m::mock('Symfony\Component\HttpFoundation\Session\SessionInterface'));
$session->shouldReceive('pull')->once()->with('state')->andReturn(str_repeat('A', 40));
$provider = new MollieConnectProvider($request, 'client_id', 'client_secret', 'redirect');
$user = $provider->user();
}

/**
* @expectedException \Laravel\Socialite\Two\InvalidStateException
*/
public function testExceptionIsThrownIfStateIsNotSet()
{
$this->expectException(\Laravel\Socialite\Two\InvalidStateException::class);
$request = Request::create('foo', 'GET', ['state' => 'state', 'code' => 'code']);
$request->setSession($session = m::mock('Symfony\Component\HttpFoundation\Session\SessionInterface'));
$session->shouldReceive('pull')->once()->with('state');
Expand Down
12 changes: 4 additions & 8 deletions tests/Wrappers/MollieApiWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ public function testSetGoodApiKey()
$wrapper->setApiKey('test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
}

/**
* @expectedException Mollie\Api\Exceptions\ApiException
* @expectedExceptionMessage Invalid API key: 'live_'. An API key must start with 'test_' or 'live_' and must be at least 30 characters long.
*/
public function testSetBadApiKey()
{
$this->expectException(\Mollie\Api\Exceptions\ApiException::class);
$this->expectExceptionMessage("Invalid API key: 'live_'. An API key must start with 'test_' or 'live_' and must be at least 30 characters long.");
$wrapper = new MollieApiWrapper($this->app['config'], $this->app[MollieApiClient::class]);
$wrapper->setApiKey('live_');
}
Expand All @@ -73,12 +71,10 @@ public function testSetGoodToken()
$wrapper->setAccessToken('access_xxx');
}

/**
* @expectedException Mollie\Api\Exceptions\ApiException
* @expectedExceptionMessage Invalid OAuth access token: 'BAD'. An access token must start with 'access_'.
*/
public function testSetBadToken()
{
$this->expectException(\Mollie\Api\Exceptions\ApiException::class);
$this->expectExceptionMessage("Invalid OAuth access token: 'BAD'. An access token must start with 'access_'.");
$wrapper = new MollieApiWrapper($this->app['config'], $this->app[MollieApiClient::class]);
$wrapper->setAccessToken('BAD');
}
Expand Down

0 comments on commit 85ef2f3

Please sign in to comment.