Skip to content

Commit 5ebc2ca

Browse files
authored
Merge pull request #129 from norkunas/upd
Allow Symfony 5.0 and improve travis + tests compatibility
2 parents 6359f32 + 9083195 commit 5ebc2ca

18 files changed

+149
-89
lines changed

.travis.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,29 @@ matrix:
1414
fast_finish: true
1515
include:
1616
# Test minimum supported dependencies with the latest and oldest PHP version
17-
- php: 5.6
1817
- php: 7.1
18+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
1919
- php: 7.2
20+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
2021
- php: 7.3
2122
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
23+
2224
# Test the latest stable release
2325
- php: 7.1
2426
- php: 7.2
2527
- php: 7.3
2628
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text --coverage-clover=build/coverage.xml"
29+
2730
# Test forcing symfony components version
28-
- php: 5.6
2931
- php: 7.1
30-
env: DEPENDENCIES="dunglas/symfony-lock:^3"
31-
- php: 7.2
32+
env: SYMFONY_VERSION=3.4.*
33+
- php: 7.3
34+
env: SYMFONY_VERSION=4.3.*
3235
- php: 7.3
33-
env: DEPENDENCIES="dunglas/symfony-lock:^4"
36+
env: SYMFONY_VERSION=4.4.*
37+
- php: 7.3
38+
env: SYMFONY_VERSION=5.0.*
39+
3440
# Latest commit to master
3541
- php: 7.3
3642
env: STABILITY="dev"
@@ -42,7 +48,7 @@ matrix:
4248
before_install:
4349
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
4450
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
45-
- if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
51+
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi
4652

4753
install:
4854
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=5.6|>=7.1",
13+
"php": "^7.1",
1414
"ext-json": "*",
1515
"php-http/client-common": "^1.9|^2.0",
1616
"php-http/client-implementation": "^1.0",
1717
"php-http/message": "^1.7",
18-
"symfony/options-resolver": "^3.4|^4.0"
18+
"symfony/options-resolver": "^3.4|^4.0|^5.0"
1919
},
2020
"require-dev": {
2121
"php-http/guzzle6-adapter": "^1.1",
22-
"symfony/phpunit-bridge": "^4.3"
22+
"symfony/phpunit-bridge": "^5.0"
2323
},
2424
"autoload": {
2525
"psr-4": { "OneSignal\\": "src/" }

tests/OneSignal/Tests/AbstractApiTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
use OneSignal\Resolver\ResolverFactory;
77
use OneSignal\Resolver\ResolverInterface;
88
use PHPUnit\Framework\TestCase;
9+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
910

1011
abstract class AbstractApiTest extends TestCase
1112
{
1213
use ConfigMockerTrait;
14+
use SetUpTearDownTrait;
1315

1416
/**
1517
* @var OneSignal
@@ -21,7 +23,7 @@ abstract class AbstractApiTest extends TestCase
2123
*/
2224
protected $resolverFactory;
2325

24-
public function setUp()
26+
public function doSetUp()
2527
{
2628
$mockResolver = $this->createMock(ResolverInterface::class);
2729
$mockResolver->method('resolve')->willReturnArgument(0);

tests/OneSignal/Tests/AppsTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
namespace OneSignal\Tests;
44

55
use OneSignal\Apps;
6+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
67

78
class AppsTest extends AbstractApiTest
89
{
10+
use SetUpTearDownTrait;
11+
912
/**
1013
* @var Apps
1114
*/
1215
private $apps;
1316

14-
public function setUp()
17+
public function doSetUp()
1518
{
16-
parent::setUp();
19+
parent::doSetUp();
1720

1821
$this->apps = new Apps($this->api, $this->resolverFactory);
1922
}

tests/OneSignal/Tests/ConfigMockerTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
namespace OneSignal\Tests;
44

55
use OneSignal\Config;
6+
use PHPUnit\Framework\MockObject\MockObject;
67

78
trait ConfigMockerTrait
89
{
910
public function createMockedConfig()
1011
{
12+
/** @var MockObject $config */
1113
$config = $this->createMock(Config::class);
1214
$config->method('getApplicationId')->willReturn('fakeApplicationId');
1315
$config->method('getApplicationAuthKey')->willReturn('fakeApplicationAuthKey');

tests/OneSignal/Tests/ConfigTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44

55
use OneSignal\Config;
66
use PHPUnit\Framework\TestCase;
7+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
78

89
class ConfigTest extends TestCase
910
{
11+
use SetUpTearDownTrait;
12+
1013
/**
1114
* @var Config
1215
*/
1316
private $config;
1417

15-
public function setUp()
18+
public function doSetUp()
1619
{
1720
$this->config = new Config();
1821
}

tests/OneSignal/Tests/DevicesTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
namespace OneSignal\Tests;
44

55
use OneSignal\Devices;
6+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
67

78
class DevicesTest extends AbstractApiTest
89
{
10+
use SetUpTearDownTrait;
11+
912
/**
1013
* @var Devices;
1114
*/
1215
private $devices;
1316

14-
public function setUp()
17+
public function doSetUp()
1518
{
16-
parent::setUp();
19+
parent::doSetUp();
1720

1821
$this->devices = new Devices($this->api, $this->resolverFactory);
1922
}

tests/OneSignal/Tests/NotificationsTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
namespace OneSignal\Tests;
44

55
use OneSignal\Notifications;
6+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
67

78
class NotificationsTest extends AbstractApiTest
89
{
10+
use SetUpTearDownTrait;
11+
912
/**
1013
* @var Notifications
1114
*/
1215
private $notifications;
1316

14-
public function setUp()
17+
public function doSetUp()
1518
{
16-
parent::setUp();
19+
parent::doSetUp();
1720

1821
$this->notifications = new Notifications($this->api, $this->resolverFactory);
1922
}

tests/OneSignal/Tests/OneSignalTest.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@
66
use OneSignal\Apps;
77
use OneSignal\Config;
88
use OneSignal\Devices;
9+
use OneSignal\Exception\OneSignalException;
910
use OneSignal\Notifications;
1011
use OneSignal\OneSignal;
1112
use Psr\Http\Message\ResponseInterface;
1213
use PHPUnit\Framework\TestCase;
14+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
1315

1416
class OneSignalTest extends TestCase
1517
{
18+
use SetUpTearDownTrait;
19+
1620
/**
1721
* @var OneSignal
1822
*/
1923
private $api;
2024

21-
public function setUp()
25+
public function doSetUp()
2226
{
2327
$this->api = new OneSignal();
2428
}
@@ -36,11 +40,10 @@ public function testIfInstanceIsCached()
3640
$this->assertInstanceOf(Apps::class, $this->api->apps);
3741
}
3842

39-
/**
40-
* @expectedException \OneSignal\Exception\OneSignalException
41-
*/
4243
public function testBadInstance()
4344
{
45+
$this->expectException(OneSignalException::class);
46+
4447
$this->api->unknownInstance;
4548
}
4649

@@ -86,23 +89,21 @@ public function testRequestParseJSONResponse()
8689
$this->assertEquals($expectedData, $this->api->request('fakeMethod', 'fakeURI'));
8790
}
8891

89-
/**
90-
* @expectedException \OneSignal\Exception\OneSignalException
91-
*/
9292
public function testRequestHandleExceptions()
9393
{
94+
$this->expectException(OneSignalException::class);
95+
9496
$client = $this->createMock(HttpMethodsClient::class);
9597
$client->method('send')->will($this->throwException(new \Exception()));
9698

9799
$this->api->setClient($client);
98100
$this->api->request('DummyMethod', 'DummyURI');
99101
}
100102

101-
/**
102-
* @expectedException \OneSignal\Exception\OneSignalException
103-
*/
104103
public function testMagicGetHandleRequest()
105104
{
105+
$this->expectException(OneSignalException::class);
106+
106107
$this->api->unexistingService;
107108
}
108109
}

tests/OneSignal/Tests/Resolver/AppResolverTest.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44

55
use OneSignal\Resolver\AppResolver;
66
use PHPUnit\Framework\TestCase;
7+
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
8+
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
9+
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
10+
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException;
711

812
class AppResolverTest extends TestCase
913
{
14+
use SetUpTearDownTrait;
15+
1016
/**
1117
* @var AppResolver
1218
*/
1319
private $appResolver;
1420

15-
public function setUp()
21+
public function doSetUp()
1622
{
1723
$this->appResolver = new AppResolver();
1824
}
@@ -47,11 +53,10 @@ public function testResolveWithValidValues()
4753
$this->assertEquals($expectedData, $this->appResolver->resolve($expectedData));
4854
}
4955

50-
/**
51-
* @expectedException \Symfony\Component\OptionsResolver\Exception\MissingOptionsException
52-
*/
5356
public function testResolveWithMissingRequiredValue()
5457
{
58+
$this->expectException(MissingOptionsException::class);
59+
5560
$this->appResolver->resolve([]);
5661
}
5762

@@ -85,22 +90,22 @@ public function wrongValueTypesProvider()
8590

8691
/**
8792
* @dataProvider wrongValueTypesProvider
88-
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
8993
*/
9094
public function testResolveWithWrongValueTypes($wrongOption)
9195
{
96+
$this->expectException(InvalidOptionsException::class);
97+
9298
$requiredOptions = [
9399
'name' => 'fakeName',
94100
];
95101

96102
$this->appResolver->resolve(array_merge($requiredOptions, $wrongOption));
97103
}
98104

99-
/**
100-
* @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
101-
*/
102105
public function testResolveWithWrongOption()
103106
{
107+
$this->expectException(UndefinedOptionsException::class);
108+
104109
$this->appResolver->resolve(['wrongOption' => 'wrongValue']);
105110
}
106111
}

0 commit comments

Comments
 (0)