@@ -25,29 +25,31 @@ class ResolverAwareTraitTest extends TestCase
2525{
2626 public function testBuildResolverFromClassName ()
2727 {
28- $ object = $ this ->getMockBuilder (ResolverAwareTrait::class)
29- ->addMethods (['getConfig ' ])
30- ->getMockForTrait ();
28+ $ object = new class {
29+ use ResolverAwareTrait;
3130
32- $ object ->expects ($ this ->once ())
33- ->method ('getConfig ' )
34- ->willReturn ('Test ' );
31+ public function getConfig ()
32+ {
33+ return 'Test ' ;
34+ }
35+ };
3536
3637 $ resolver = $ object ->getResolver ();
3738 $ this ->assertInstanceOf (TestResolver::class, $ resolver );
3839 }
3940
4041 public function testBuildResolverFromArray ()
4142 {
42- $ object = $ this ->getMockBuilder (ResolverAwareTrait::class)
43- ->addMethods (['getConfig ' ])
44- ->getMockForTrait ();
43+ $ object = new class {
44+ use ResolverAwareTrait;
4545
46- $ object ->expects ($ this ->once ())
47- ->method ('getConfig ' )
48- ->willReturn ([
49- 'className ' => 'Test ' ,
50- ]);
46+ public function getConfig ()
47+ {
48+ return [
49+ 'className ' => 'Test ' ,
50+ ];
51+ }
52+ };
5153
5254 $ resolver = $ object ->getResolver ();
5355 $ this ->assertInstanceOf (TestResolver::class, $ resolver );
@@ -57,13 +59,14 @@ public function testBuildResolverInvalid()
5759 {
5860 $ this ->expectException ('RuntimeException ' );
5961 $ this ->expectExceptionMessage ('Resolver must implement `Authentication\Identifier\Resolver\ResolverInterface`. ' );
60- $ object = $ this ->getMockBuilder (ResolverAwareTrait::class)
61- ->addMethods (['getConfig ' ])
62- ->getMockForTrait ();
62+ $ object = new class {
63+ use ResolverAwareTrait;
6364
64- $ object ->expects ($ this ->once ())
65- ->method ('getConfig ' )
66- ->willReturn ('Invalid ' );
65+ public function getConfig ()
66+ {
67+ return 'Invalid ' ;
68+ }
69+ };
6770
6871 $ object ->getResolver ();
6972 }
@@ -72,13 +75,14 @@ public function testBuildResolverMissing()
7275 {
7376 $ this ->expectException ('InvalidArgumentException ' );
7477 $ this ->expectExceptionMessage ('Resolver class `Missing` does not exist. ' );
75- $ object = $ this ->getMockBuilder (ResolverAwareTrait::class)
76- ->addMethods (['getConfig ' ])
77- ->getMockForTrait ();
78+ $ object = new class {
79+ use ResolverAwareTrait;
7880
79- $ object ->expects ($ this ->once ())
80- ->method ('getConfig ' )
81- ->willReturn ('Missing ' );
81+ public function getConfig ()
82+ {
83+ return 'Missing ' ;
84+ }
85+ };
8286
8387 $ object ->getResolver ();
8488 }
@@ -87,13 +91,14 @@ public function testBuildResolverMissingClassNameOption()
8791 {
8892 $ this ->expectException ('InvalidArgumentException ' );
8993 $ this ->expectExceptionMessage ('Option `className` is not present. ' );
90- $ object = $ this ->getMockBuilder (ResolverAwareTrait::class)
91- ->addMethods (['getConfig ' ])
92- ->getMockForTrait ();
94+ $ object = new class {
95+ use ResolverAwareTrait;
9396
94- $ object ->expects ($ this ->once ())
95- ->method ('getConfig ' )
96- ->willReturn ([]);
97+ public function getConfig ()
98+ {
99+ return [];
100+ }
101+ };
97102
98103 $ object ->getResolver ();
99104 }
@@ -102,22 +107,23 @@ public function testGetResolverNotSet()
102107 {
103108 $ this ->expectException ('RuntimeException ' );
104109 $ this ->expectExceptionMessage ('Resolver has not been set. ' );
105- $ object = $ this ->getMockBuilder (ResolverAwareTrait::class)
106- ->addMethods (['getConfig ' ])
107- ->getMockForTrait ();
110+ $ object = new class {
111+ use ResolverAwareTrait;
108112
109- $ object ->expects ($ this ->once ())
110- ->method ('getConfig ' )
111- ->willReturn (null );
113+ public function getConfig ()
114+ {
115+ return null ;
116+ }
117+ };
112118
113119 $ object ->getResolver ();
114120 }
115121
116122 public function testSetResolver ()
117123 {
118- $ object = $ this -> getMockBuilder (ResolverAwareTrait:: class)
119- -> addMethods ([ ' getConfig ' ])
120- -> getMockForTrait () ;
124+ $ object = new class {
125+ use ResolverAwareTrait;
126+ } ;
121127
122128 $ resolver = $ this ->createMock (ResolverInterface::class);
123129
0 commit comments