Skip to content

Commit 54a9d53

Browse files
Thomasnielsbauman
authored andcommitted
Update tests to be compatible with upgraded phpunit
1 parent 5aa612c commit 54a9d53

2 files changed

Lines changed: 34 additions & 6 deletions

File tree

tests/EntrustTest.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<?php
22

33
use Zizaco\Entrust\Entrust;
4-
use Illuminate\Support\Facades\Facade;
4+
use PHPUnit\Framework\TestCase;
55
use Mockery as m;
66

7-
class EntrustTest extends PHPUnit_Framework_TestCase
7+
class EntrustTest extends TestCase
88
{
99
protected $nullFilterTest;
1010
protected $abortFilterTest;
1111
protected $customResponseFilterTest;
1212

1313
protected $expectedResponse;
1414

15-
public function setUp()
15+
protected function setUp(): void
1616
{
17+
parent::setUp();
18+
1719
$this->nullFilterTest = function($filterClosure) {
1820
if (!($filterClosure instanceof Closure)) {
1921
return false;
@@ -54,8 +56,9 @@ public function setUp()
5456
};
5557
}
5658

57-
public function tearDown()
59+
protected function tearDown(): void
5860
{
61+
parent::tearDown();
5962
m::close();
6063
}
6164

@@ -214,6 +217,8 @@ public function testRouteNeedsRole()
214217
*/
215218
$entrust->routeNeedsRole($route, $oneRole);
216219
$entrust->routeNeedsRole($route, $manyRole);
220+
221+
$this->assertTrueWithoutException();
217222
}
218223

219224
public function testRouteNeedsPermission()
@@ -254,6 +259,8 @@ public function testRouteNeedsPermission()
254259
*/
255260
$entrust->routeNeedsPermission($route, $onePerm);
256261
$entrust->routeNeedsPermission($route, $manyPerm);
262+
263+
$this->assertTrueWithoutException();
257264
}
258265

259266
public function testRouteNeedsRoleOrPermission()
@@ -316,6 +323,8 @@ public function testRouteNeedsRoleOrPermission()
316323
$entrust->routeNeedsRoleOrPermission($route, $oneRole, $manyPerm);
317324
$entrust->routeNeedsRoleOrPermission($route, $manyRole, $onePerm);
318325
$entrust->routeNeedsRoleOrPermission($route, $manyRole, $manyPerm);
326+
327+
$this->assertTrueWithoutException();
319328
}
320329

321330
public function simpleFilterDataProvider()
@@ -432,4 +441,9 @@ protected function makeFilterName($route, array $roles, array $permissions = nul
432441
return implode('_', $roles) . '_' . implode('_', $permissions) . '_' . substr(md5($route), 0, 6);
433442
}
434443
}
444+
445+
private function assertTrueWithoutException()
446+
{
447+
$this->assertTrue(true, 'Make it to the end without exception');
448+
}
435449
}

tests/EntrustUserTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?php
22

3+
use PHPUnit\Framework\TestCase;
34
use Zizaco\Entrust\Contracts\EntrustUserInterface;
45
use Zizaco\Entrust\Traits\EntrustUserTrait;
56
use Illuminate\Support\Facades\Config;
67
use Mockery as m;
78

8-
class EntrustUserTest extends PHPUnit_Framework_TestCase
9+
class EntrustUserTest extends TestCase
910
{
10-
public function tearDown()
11+
protected function tearDown(): void
1112
{
1213
m::close();
1314
}
@@ -817,6 +818,8 @@ public function testAttachRole()
817818
$user->attachRole($roleObject);
818819
$user->attachRole($roleArray);
819820
$user->attachRole(3);
821+
822+
$this->assertTrueWithoutException();
820823
}
821824

822825
public function testDetachRole()
@@ -860,6 +863,8 @@ public function testDetachRole()
860863
$user->detachRole($roleObject);
861864
$user->detachRole($roleArray);
862865
$user->detachRole(3);
866+
867+
$this->assertTrueWithoutException();
863868
}
864869

865870
public function testAttachRoles()
@@ -892,6 +897,8 @@ public function testAttachRoles()
892897
|------------------------------------------------------------
893898
*/
894899
$user->attachRoles([1, 2, 3]);
900+
901+
$this->assertTrueWithoutException();
895902
}
896903

897904
public function testDetachRoles()
@@ -924,6 +931,8 @@ public function testDetachRoles()
924931
|------------------------------------------------------------
925932
*/
926933
$user->detachRoles([1, 2, 3]);
934+
935+
$this->assertTrueWithoutException();
927936
}
928937

929938
protected function mockPermission($permName)
@@ -944,6 +953,11 @@ protected function mockRole($roleName)
944953

945954
return $roleMock;
946955
}
956+
957+
private function assertTrueWithoutException()
958+
{
959+
$this->assertTrue(true, 'Make it to the end without exception');
960+
}
947961
}
948962

949963
class HasRoleUser implements EntrustUserInterface

0 commit comments

Comments
 (0)