Skip to content

Commit 57f51eb

Browse files
committed
Test enhancement
1 parent 3f9854c commit 57f51eb

File tree

7 files changed

+34
-15
lines changed

7 files changed

+34
-15
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"php": ">=5.4.0"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^4.8.0|^5.7.0"
28+
"phpunit/phpunit": "^4.8.0|^5.7.0|^6.5"
2929
},
3030
"config": {
3131
"optimize-autoloader": true,

tests/UnderscoreArrayTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
namespace Ahc\Underscore\Tests;
44

55
use Ahc\Underscore\Underscore as _;
6+
use PHPUnit\Framework\TestCase;
67

7-
class UnderscoreArrayTest extends \PHPUnit_Framework_TestCase
8+
class UnderscoreArrayTest extends TestCase
89
{
910
public function test_first_last()
1011
{
@@ -120,7 +121,7 @@ public function test_object()
120121
$array = [[1, 2], 'a' => 3, 'b' => 'B'];
121122

122123
foreach (underscore($array)->object() as $index => $value) {
123-
$this->assertTrue(is_object($value));
124+
$this->assertInternalType('object', $value);
124125
$this->assertSame($index, $value->index);
125126
$this->assertSame($array[$index], $value->value);
126127
}

tests/UnderscoreBaseTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Ahc\Underscore\Tests;
44

55
use Ahc\Underscore\Underscore as _;
6+
use PHPUnit\Framework\TestCase;
67

78
class Stub
89
{
@@ -20,7 +21,7 @@ public function jsonSerialize()
2021
}
2122
}
2223

23-
class UnderscoreBaseTest extends \PHPUnit_Framework_TestCase
24+
class UnderscoreBaseTest extends TestCase
2425
{
2526
public function test_asArray()
2627
{
@@ -47,7 +48,7 @@ public function test_underscore()
4748

4849
public function test_now()
4950
{
50-
$this->assertTrue(is_float(_::_()->now()));
51+
$this->assertInternalType('float', _::_()->now());
5152
}
5253

5354
public function test_keys_values()
@@ -113,7 +114,7 @@ public function test_mixin()
113114

114115
$und = underscore([10, 20, 30]);
115116

116-
$this->assertTrue(is_callable([$und, 'double']));
117+
$this->assertInternalType('callable', [$und, 'double']);
117118
$this->assertSame([20, 40, 60], $und->double()->toArray());
118119

119120
$und->notMixedIn();

tests/UnderscoreCollectionTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Ahc\Underscore\Tests;
44

5-
class UnderscoreCollectionTest extends \PHPUnit_Framework_TestCase
5+
use PHPUnit\Framework\TestCase;
6+
7+
class UnderscoreCollectionTest extends TestCase
68
{
79
public function test_array_json_props()
810
{
@@ -33,7 +35,7 @@ public function test_array_json_props()
3335
}
3436

3537
/**
36-
* @expectedException \PHPUnit_Framework_Error_Notice
38+
* @expectedException \PHPUnit\Framework\Error\Notice
3739
* @expectedExceptionMessage Undefined offset: 5
3840
*/
3941
public function test_get()
@@ -310,7 +312,8 @@ public function test_sortBy()
310312
$byA = $list->sortBy('a')->get();
311313
$this->assertSame(
312314
[2 => ['a' => 0, 'b' => 1], 0 => ['a' => 1, 'b' => 2], 1 => ['a' => 2, 'b' => 3]],
313-
$byA, 'sort by a'
315+
$byA,
316+
'sort by a'
314317
);
315318

316319
$byAB = $list->sortBy(function ($i) {
@@ -319,7 +322,8 @@ public function test_sortBy()
319322

320323
$this->assertSame(
321324
[2 => ['a' => 0, 'b' => 1], 0 => ['a' => 1, 'b' => 2], 1 => ['a' => 2, 'b' => 3]],
322-
$byAB, 'sort by a+b'
325+
$byAB,
326+
'sort by a+b'
323327
);
324328
}
325329

tests/UnderscoreFunctionTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Ahc\Underscore\Tests;
44

5-
class UnderscoreFunctionTest extends \PHPUnit_Framework_TestCase
5+
use PHPUnit\Framework\TestCase;
6+
7+
class UnderscoreFunctionTest extends TestCase
68
{
79
public function test_memoize()
810
{
@@ -27,10 +29,14 @@ public function test_memoize()
2729

2830
$buffer = ob_get_clean();
2931

30-
$this->assertSame(1, substr_count($buffer, 'sum 1 + 2'),
32+
$this->assertSame(
33+
1,
34+
substr_count($buffer, 'sum 1 + 2'),
3135
'Should be called only once, subsequent calls uses memo'
3236
);
33-
$this->assertSame(1, substr_count($buffer, 'sum 3 + 2'),
37+
$this->assertSame(
38+
1,
39+
substr_count($buffer, 'sum 3 + 2'),
3440
'Should be called only once, subsequent calls uses memo'
3541
);
3642
}
@@ -76,7 +82,9 @@ public function test_throttle()
7682

7783
$buffer = ob_get_clean();
7884

79-
$this->assertLessThanOrEqual(3, substr_count($buffer, 'throttle'),
85+
$this->assertLessThanOrEqual(
86+
3,
87+
substr_count($buffer, 'throttle'),
8088
'Should be called only once, subsequent calls uses memo'
8189
);
8290
}

tests/UnderscoreTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
namespace Ahc\Underscore\Tests;
44

55
use Ahc\Underscore\Underscore as _;
6+
use PHPUnit\Framework\TestCase;
67

7-
class UnderscoreTest extends \PHPUnit_Framework_TestCase
8+
class UnderscoreTest extends TestCase
89
{
910
public function test_constant()
1011
{

tests/bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
<?php
22

33
require_once __DIR__ . '/../vendor/autoload.php';
4+
5+
if (class_exists('\PHPUnit_Framework_Error_Notice')) {
6+
class_alias('\PHPUnit_Framework_Error_Notice', '\PHPUnit\Framework\Error\Notice');
7+
}

0 commit comments

Comments
 (0)