Skip to content

Commit 3d993bf

Browse files
committed
test: fix/refactor tests for newer php and phpunit
1 parent 7841d8f commit 3d993bf

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

phpunit.xml.dist

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
bootstrap="tests/bootstrap.php"
1312
>
1413
<testsuites>

tests/HigherOrderMessageTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class HigherOrderMessageTest extends TestCase
3939
*/
4040
protected $hom2;
4141

42-
public function setUp()
42+
public function setUp(): void
4343
{
4444
parent::setUp();
4545

tests/UnderscoreArrayTest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ public function test_unique_uniq()
6868

6969
$this->assertSame(
7070
['a', '', 3 => 1, 5 => 0, 7 => 'b', 8 => 3, 9 => 2],
71-
underscore($array)->uniq(function ($i) {
72-
return $i;
73-
})->get(),
71+
underscore($array)->uniq(fn ($i) => $i)->get(),
7472
'uniq'
7573
);
7674
}
@@ -130,7 +128,7 @@ public function test_object()
130128
$array = [[1, 2], 'a' => 3, 'b' => 'B'];
131129

132130
foreach (underscore($array)->object() as $index => $value) {
133-
$this->assertInternalType('object', $value);
131+
$this->assertTrue(is_object($value));
134132
$this->assertSame($index, $value->index);
135133
$this->assertSame($array[$index], $value->value);
136134
}

tests/UnderscoreBaseTest.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function toArray()
2424

2525
class Json implements \JsonSerializable
2626
{
27+
#[\ReturnTypeWillChange]
2728
public function jsonSerialize()
2829
{
2930
return ['a' => 1, 'b' => 2, 'c' => 3];
@@ -74,7 +75,7 @@ public function test_underscore()
7475

7576
public function test_now()
7677
{
77-
$this->assertInternalType('float', _::_()->now());
78+
$this->assertNotEmpty(_::_()->now());
7879
}
7980

8081
public function test_keys_values()
@@ -126,10 +127,6 @@ public function test_clone_tap()
126127
$this->assertSame($main, $tap, 'hard equal');
127128
}
128129

129-
/**
130-
* @expectedException \Ahc\Underscore\UnderscoreException
131-
* @expectedExceptionMessage The mixin with name 'notMixedIn' is not defined
132-
*/
133130
public function test_mixin()
134131
{
135132
_::mixin('double', function () {
@@ -140,9 +137,12 @@ public function test_mixin()
140137

141138
$und = underscore([10, 20, 30]);
142139

143-
$this->assertInternalType('callable', [$und, 'double']);
140+
$this->assertIsCallable([$und, 'double']);
144141
$this->assertSame([20, 40, 60], $und->double()->toArray());
145142

143+
$this->expectException(\Ahc\Underscore\UnderscoreException::class);
144+
$this->expectExceptionMessage("The mixin with name 'notMixedIn' is not defined");
145+
146146
$und->notMixedIn();
147147
}
148148

@@ -168,12 +168,11 @@ public function test_hom()
168168
$this->assertSame([1 => 64, 3 => 36, 5 => 16, 7 => 4, 9 => 0], $sq);
169169
}
170170

171-
/**
172-
* @expectedException \Ahc\Underscore\UnderscoreException
173-
* @expectedExceptionMessage The 'anon' is not defined
174-
*/
175171
public function test_hom_throws()
176172
{
173+
$this->expectException(\Ahc\Underscore\UnderscoreException::class);
174+
$this->expectExceptionMessage("The 'anon' is not defined");
175+
177176
underscore()->anon->value();
178177
}
179178
}

0 commit comments

Comments
 (0)