Skip to content

Commit a80067f

Browse files
Update phpunit and allow php8
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
1 parent caf17ca commit a80067f

File tree

80 files changed

+142
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+142
-203
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ matrix:
1313
- php: 7.2
1414
- php: 7.3
1515
- php: 7.4
16+
- php: 8.0
1617
- php: nightly
1718
allow_failures:
1819
- php: nightly

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
}
3434
},
3535
"require": {
36-
"php": "^7.2.5",
36+
"php": "^7.2.5|^8.0",
3737
"guzzlehttp/guzzle": "^7.0",
3838
"guzzlehttp/uri-template": "0.2",
3939
"justinrainbow/json-schema": "^5.2"
4040
},
4141
"require-dev": {
42-
"phpunit/phpunit": "^6.5",
42+
"phpunit/phpunit": "^8.0",
4343
"psr/log": "^1.0",
4444
"php-coveralls/php-coveralls": "^2.0",
4545
"friendsofphp/php-cs-fixer": "^2.13",

tests/unit/BlockStorage/v2/Models/QuotaSetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class QuotaSetTest extends TestCase
1212
/** @var QuotaSet */
1313
private $quotaSet;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818

tests/unit/BlockStorage/v2/Models/SnapshotTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class SnapshotTest extends TestCase
1212
/** @var Snapshot */
1313
private $snapshot;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818

tests/unit/BlockStorage/v2/Models/VolumeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class VolumeTest extends TestCase
1212
/** @var Volume */
1313
private $volume;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818

@@ -48,7 +48,7 @@ public function test_it_retrieves()
4848

4949
$volumeImageMetadata = $this->volume->volumeImageMetadata;
5050

51-
$this->assertInternalType('array', $volumeImageMetadata);
51+
self::assertIsArray($volumeImageMetadata);
5252
$this->assertEquals($volumeImageMetadata['os_distro'], 'ubuntu');
5353
$this->assertEquals($volumeImageMetadata['os_version'], 'xenial');
5454
$this->assertEquals($volumeImageMetadata['hypervisor_type'], 'qemu');

tests/unit/BlockStorage/v2/Models/VolumeTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class VolumeTypeTest extends TestCase
1212
/** @var VolumeType */
1313
private $volumeType;
1414

15-
public function setUp()
15+
public function setUp(): void
1616
{
1717
parent::setUp();
1818

tests/unit/BlockStorage/v2/ServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ServiceTest extends TestCase
1616
/** @var Service */
1717
private $service;
1818

19-
public function setUp()
19+
public function setUp(): void
2020
{
2121
parent::setUp();
2222

tests/unit/Common/Api/OperationTest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class OperationTest extends \PHPUnit\Framework\TestCase
1010
{
1111
private $operation;
1212

13-
public function setUp()
13+
public function setUp(): void
1414
{
1515
$def = (new ComputeV2Api())->postServer();
1616

@@ -37,32 +37,26 @@ public function test_it_validates_params()
3737
]));
3838
}
3939

40-
/**
41-
* @expectedException \Exception
42-
*/
4340
public function test_exceptions_are_propagated()
4441
{
42+
$this->expectException(\Exception::class);
4543
$this->assertFalse($this->operation->validate([
4644
'name' => true,
4745
'imageId' => 'bar',
4846
'flavorId' => 'baz',
4947
]));
5048
}
5149

52-
/**
53-
* @expectedException \Exception
54-
*/
5550
public function test_an_exception_is_thrown_when_user_does_not_provide_required_options()
5651
{
52+
$this->expectException(\Exception::class);
5753
$this->operation->validate([]);
5854
}
5955

60-
/**
61-
* @expectedException \Exception
62-
*/
6356
public function test_it_throws_exception_when_user_provides_undefined_options()
6457
{
6558
$userData = ['name' => 'new_server', 'undefined_opt' => 'bah'];
59+
$this->expectException(\Exception::class);
6660

6761
$this->operation->validate($userData);
6862
}

tests/unit/Common/Api/OperatorTraitTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class OperatorTraitTest extends TestCase
2020

2121
private $def;
2222

23-
public function setUp()
23+
public function setUp(): void
2424
{
2525
parent::setUp();
2626

@@ -74,19 +74,15 @@ public function test_it_wraps_sequential_ops_in_promise_when_async_is_appended_t
7474
$promise->wait();
7575
}
7676

77-
/**
78-
* @expectedException \RuntimeException
79-
*/
8077
public function test_it_throws_exception_when_async_is_called_on_a_non_existent_method()
8178
{
79+
$this->expectException(\RuntimeException::class);
8280
$this->operator->fooAsync();
8381
}
8482

85-
/**
86-
* @expectedException \Exception
87-
*/
8883
public function test_undefined_methods_result_in_error()
8984
{
85+
$this->expectException(\Exception::class);
9086
$this->operator->foo();
9187
}
9288

tests/unit/Common/Api/ParameterTest.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,19 @@ class ParameterTest extends \PHPUnit\Framework\TestCase
1111
private $data;
1212
private $api;
1313

14-
public function setUp()
14+
public function setUp(): void
1515
{
1616
$this->api = new ComputeV2Api();
1717

1818
$this->data = $this->api->postServer()['params']['name'] + ['name' => 'name'];
1919
$this->param = new Parameter($this->data);
2020
}
2121

22-
/**
23-
* @expectedException \RuntimeException
24-
*/
2522
public function test_exception_is_thrown_for_invalid_locations()
2623
{
2724
$data = $this->data;
2825
$data['location'] = 'foo';
26+
$this->expectException(\RuntimeException::class);
2927
new Parameter($data);
3028
}
3129

@@ -82,25 +80,21 @@ public function test_it_should_return_true_when_required_attributes_are_provided
8280
$this->assertTrue($this->param->validate('TestName'));
8381
}
8482

85-
/**
86-
* @expectedException \Exception
87-
*/
8883
public function test_it_throws_exception_when_values_do_not_match_their_definition_types()
8984
{
9085
$data = $this->api->postServer()['params']['networks'] + ['name' => 'networks'];
9186
$param = new Parameter($data);
87+
$this->expectException(\Exception::class);
9288

9389
$param->validate('a_network!'); // should be an array
9490
}
9591

96-
/**
97-
* @expectedException \Exception
98-
*/
9992
public function test_it_throws_exception_when_deeply_nested_values_have_wrong_types()
10093
{
10194
$data = $this->api->postServer()['params']['networks'] + ['name' => 'networks'];
102-
10395
$param = new Parameter($data);
96+
$this->expectException(\Exception::class);
97+
10498
$param->validate(['name' => false]); // value should be a string, not bool
10599
}
106100

@@ -134,15 +128,13 @@ public function test_it_passes_validation_when_array_values_pass()
134128
$this->assertTrue($param->validate($userVals));
135129
}
136130

137-
/**
138-
* @expectedException \Exception
139-
*/
140131
public function test_an_exception_is_thrown_when_an_undefined_property_is_provided()
141132
{
142133
$params = ['type' => 'object', 'properties' => ['foo' => ['type' => 'string']]];
143134
$userVals = ['bar' => 'baz'];
144-
145135
$param = new Parameter($params);
136+
$this->expectException(\Exception::class);
137+
146138
$param->validate($userVals);
147139
}
148140

@@ -187,15 +179,13 @@ public function test_it_gets_prefixed_name()
187179
$this->assertEquals('foo-metadata', $property->getPrefixedName());
188180
}
189181

190-
/**
191-
* @expectedException \Exception
192-
*/
193182
public function test_exception_is_thrown_when_value_is_not_in_enum_list()
194183
{
195184
$data = $this->data;
196185
$data['enum'] = ['foo'];
197-
198186
$param = new Parameter($data);
187+
$this->expectException(\Exception::class);
188+
199189
$param->validate('blah');
200190
}
201191
}

0 commit comments

Comments
 (0)