Skip to content

Commit 0202907

Browse files
committed
Require php>=7.2
1 parent c931c9f commit 0202907

8 files changed

+89
-197
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
22
vendor
33
composer.lock
4-
build
4+
build
5+
.phpunit.result.cache

composer.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
}
1414
],
1515
"require": {
16-
"php": ">=5.6"
16+
"php": ">=7.2",
17+
"phpunit/phpunit": "^8.0"
1718
},
1819
"require-dev": {
19-
"phpunit/phpunit": "5.5.*",
2020
"php-coveralls/php-coveralls": "^2.1"
2121
},
2222
"autoload": {
@@ -27,9 +27,6 @@
2727
"autoload-dev": {
2828
"psr-4": {
2929
"Sevavietl\\Arrays\\Tests\\Unit\\": "tests/unit/"
30-
},
31-
"classmap": [
32-
"tests/TestCase.php"
33-
]
30+
}
3431
}
3532
}

tests/TestCase.php

-33
This file was deleted.

tests/unit/BaseArrayTest.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
namespace Sevavietl\Arrays\Tests\Unit;
44

5+
use PHPUnit\Framework\TestCase;
56
use Sevavietl\Arrays\BaseArray;
67
use Sevavietl\Arrays\UndefinedOffsetException;
78

8-
class BaseArrayTest extends \TestCase
9+
class BaseArrayTest extends TestCase
910
{
1011
/**
1112
* @dataProvider instantiationDataProvider
1213
*/
13-
public function testInstantiation($argument)
14+
public function testInstantiation($argument): void
1415
{
1516
new BaseArray($argument);
1617
}
1718

18-
public function instantiationDataProvider()
19+
public function instantiationDataProvider(): array
1920
{
2021
return [
2122
[[1, 2, 3]],
@@ -25,15 +26,15 @@ public function instantiationDataProvider()
2526

2627
/**
2728
* @dataProvider instantiationThrowsExceptionDataProvider
28-
*
29-
* @expectedException InvalidArgumentException
3029
*/
31-
public function testInstantiationThrowsException($argument)
30+
public function testInstantiationThrowsException($argument): void
3231
{
32+
$this->expectException(\InvalidArgumentException::class);
33+
3334
new BaseArray($argument);
3435
}
3536

36-
public function instantiationThrowsExceptionDataProvider()
37+
public function instantiationThrowsExceptionDataProvider(): array
3738
{
3839
return [
3940
[1],
@@ -42,15 +43,15 @@ public function instantiationThrowsExceptionDataProvider()
4243
];
4344
}
4445

45-
public function testThrowsExceptionOnUndefinedOffset()
46+
public function testThrowsExceptionOnUndefinedOffset(): void
4647
{
4748
$this->expectException(UndefinedOffsetException::class);
4849

4950
$arr = new BaseArray([1, 2, 3]);
5051
$arr[3];
5152
}
5253

53-
public function testItIsIterable()
54+
public function testItIsIterable(): void
5455
{
5556
$arr = new BaseArray($initial = [1, 2, 3]);
5657

tests/unit/CompositeKeyArrayTest.php

+22-48
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,23 @@
22

33
namespace Sevavietl\Arrays\Tests\Unit;
44

5+
use PHPUnit\Framework\TestCase;
56
use Sevavietl\Arrays\CompositeKeyArray;
67
use Sevavietl\Arrays\UndefinedOffsetException;
78

8-
class CompositeKeyArrayTest extends \TestCase
9+
class CompositeKeyArrayTest extends TestCase
910
{
1011
/**
1112
* @dataProvider arrayDataProviderForIssetTesting
1213
*/
13-
public function testOffsetExists($array, $offset, $exists)
14+
public function testOffsetExists($array, $offset, bool $exists): void
1415
{
1516
$array = new CompositeKeyArray($array);
1617

17-
$this->assertEquals(
18-
$exists,
19-
isset($array[$offset])
20-
);
18+
$this->assertEquals($exists, isset($array[$offset]));
2119
}
2220

23-
public function arrayDataProviderForIssetTesting()
21+
public function arrayDataProviderForIssetTesting(): array
2422
{
2523
return [
2624
[[1], 0, true],
@@ -41,17 +39,14 @@ public function arrayDataProviderForIssetTesting()
4139
/**
4240
* @dataProvider arrayDataProviderForGetTesting
4341
*/
44-
public function testOffsetGet($array, $offset, $value)
42+
public function testOffsetGet($array, $offset, $value): void
4543
{
4644
$array = new CompositeKeyArray($array);
4745

48-
$this->assertEquals(
49-
$value,
50-
$array[$offset]
51-
);
46+
$this->assertEquals($value, $array[$offset]);
5247
}
5348

54-
public function arrayDataProviderForGetTesting()
49+
public function arrayDataProviderForGetTesting(): array
5550
{
5651
return [
5752
[[1], 0, 1],
@@ -63,11 +58,10 @@ public function arrayDataProviderForGetTesting()
6358
];
6459
}
6560

66-
/**
67-
* @expectedException Sevavietl\Arrays\UndefinedOffsetException
68-
*/
69-
public function testOffsetGetThrowsException()
61+
public function testOffsetGetThrowsException(): void
7062
{
63+
$this->expectException(UndefinedOffsetException::class);
64+
7165
$array = new CompositeKeyArray();
7266

7367
$value = $array[['foo', 'bar']];
@@ -76,72 +70,52 @@ public function testOffsetGetThrowsException()
7670
/**
7771
* @dataProvider arrayDataProviderForSetTesting
7872
*/
79-
public function testOffsetSet($array, $offset, $value)
73+
public function testOffsetSet($array, $offset, $value): void
8074
{
8175
$array = new CompositeKeyArray($array);
82-
8376
$array[$offset] = $value;
8477

85-
$this->assertEquals(
86-
$value,
87-
$array[$offset]
88-
);
78+
$this->assertEquals($value, $array[$offset]);
8979
}
9080

91-
public function arrayDataProviderForSetTesting()
81+
public function arrayDataProviderForSetTesting(): array
9282
{
9383
return [
9484
[[], 0, 1],
9585
[[], [0, 1], 2],
9686
];
9787
}
9888

99-
public function testOffsetSetEdgeCases()
89+
public function testOffsetSetEdgeCases(): void
10090
{
10191
$array = new CompositeKeyArray();
102-
10392
$array[[[]]] = 'foo';
10493

105-
$this->assertEquals(
106-
'foo',
107-
$array[0]
108-
);
94+
$this->assertEquals('foo', $array[0]);
10995

11096
$array = new CompositeKeyArray();
111-
11297
$array[[1, [], 2]] = 3;
11398

114-
$this->assertEquals(
115-
3,
116-
$array[[1, 0, 2]]
117-
);
99+
$this->assertEquals(3, $array[[1, 0, 2]]);
118100

119101
$array = new CompositeKeyArray();
120-
121102
$array[[1, [], [], [], 2]] = 3;
122103

123-
$this->assertEquals(
124-
3,
125-
$array[[1, 0, 0, 0, 2]]
126-
);
104+
$this->assertEquals(3, $array[[1, 0, 0, 0, 2]]);
127105
}
128106

129107
/**
130108
* @dataProvider arrayDataProviderForUnsetTesting
131109
*/
132-
public function testOffsetUnset($array, $offset, $arrayAfterUnset)
110+
public function testOffsetUnset($array, $offset, $arrayAfterUnset): void
133111
{
134112
$array = new CompositeKeyArray($array);
135-
136113
unset($array[$offset]);
137114

138-
$this->assertEquals(
139-
$arrayAfterUnset,
140-
$array->toArray()
141-
);
115+
$this->assertEquals($arrayAfterUnset, $array->toArray());
142116
}
143117

144-
public function arrayDataProviderForUnsetTesting()
118+
public function arrayDataProviderForUnsetTesting(): array
145119
{
146120
return [
147121
[[1], 0, []],
@@ -157,7 +131,7 @@ public function arrayDataProviderForUnsetTesting()
157131
];
158132
}
159133

160-
public function testItIsIterable()
134+
public function testItIsIterable(): void
161135
{
162136
$arr = new CompositeKeyArray($initial = [
163137
'foo' => ['bar' => ['baz']],

0 commit comments

Comments
 (0)