6
6
7
7
use DateInterval ;
8
8
use Exception ;
9
+ use Mockery ;
9
10
use React \Cache \CacheInterface ;
10
11
use WyriHaximus \AsyncTestUtilities \AsyncTestCase ;
11
12
use WyriHaximus \React \Cache \PSR16Adapter ;
@@ -17,49 +18,49 @@ final class PSR16AdapterTest extends AsyncTestCase
17
18
{
18
19
public function testGet (): void
19
20
{
20
- $ client = $ this -> prophesize (CacheInterface::class);
21
+ $ client = Mockery:: mock (CacheInterface::class);
21
22
$ key = 'key ' ;
22
23
$ value = 'value ' ;
23
- $ client ->get ($ key , null )->shouldBeCalled ()-> willReturn (resolve ($ value ));
24
- self ::assertSame ($ value , (new PSR16Adapter ($ client-> reveal () ))->get ($ key ));
24
+ $ client ->shouldReceive ( ' get ' )-> with ($ key , null )->andReturn (resolve ($ value ));
25
+ self ::assertSame ($ value , (new PSR16Adapter ($ client ))->get ($ key ));
25
26
}
26
27
27
28
public function testGetNonExistant (): void
28
29
{
29
- $ client = $ this -> prophesize (CacheInterface::class);
30
+ $ client = Mockery:: mock (CacheInterface::class);
30
31
$ key = 'key ' ;
31
- $ client ->get ($ key , null )->shouldBeCalled ()-> willReturn (resolve (null ));
32
- self ::assertNull ((new PSR16Adapter ($ client-> reveal () ))->get ($ key ));
32
+ $ client ->shouldReceive ( ' get ' )-> with ($ key , null )->andReturn (resolve (null ));
33
+ self ::assertNull ((new PSR16Adapter ($ client ))->get ($ key ));
33
34
}
34
35
35
36
public function testSet (): void
36
37
{
37
- $ client = $ this -> prophesize (CacheInterface::class);
38
+ $ client = Mockery:: mock (CacheInterface::class);
38
39
$ key = 'key ' ;
39
40
$ value = 'value ' ;
40
- $ client ->set ($ key , $ value , null )->shouldBeCalled ()-> willReturn (resolve (true ));
41
- ( new PSR16Adapter ($ client-> reveal ())) ->set ($ key , $ value );
41
+ $ client ->shouldReceive ( ' set ' )-> with ($ key , $ value , null )->andReturn (resolve (true ));
42
+ self :: assertTrue (( new PSR16Adapter ($ client)) ->set ($ key , $ value) );
42
43
}
43
44
44
45
public function testSetTtl (): void
45
46
{
46
- $ client = $ this -> prophesize (CacheInterface::class);
47
+ $ client = Mockery:: mock (CacheInterface::class);
47
48
$ key = 'key ' ;
48
49
$ value = 'value ' ;
49
50
$ ttl = 123 ;
50
- $ client ->set ($ key , $ value , $ ttl )->shouldBeCalled ()-> willReturn (resolve (true ));
51
- self ::assertTrue ((new PSR16Adapter ($ client-> reveal () ))->set ($ key , $ value , $ ttl ));
51
+ $ client ->shouldReceive ( ' set ' )-> with ($ key , $ value , $ ttl )->andReturn (resolve (true ));
52
+ self ::assertTrue ((new PSR16Adapter ($ client ))->set ($ key , $ value , $ ttl ));
52
53
}
53
54
54
55
public function testSetDateIntervalTtl (): void
55
56
{
56
- $ client = $ this -> prophesize (CacheInterface::class);
57
+ $ client = Mockery:: mock (CacheInterface::class);
57
58
$ key = 'key ' ;
58
59
$ value = 'value ' ;
59
60
$ dateIntervalTtl = new DateInterval ('PT123S ' );
60
61
$ ttl = 123 ;
61
- $ client ->set ($ key , $ value , $ ttl )->shouldBeCalled ()-> willReturn (resolve (true ));
62
- self ::assertTrue ((new PSR16Adapter ($ client-> reveal () ))->set ($ key , $ value , $ dateIntervalTtl ));
62
+ $ client ->shouldReceive ( ' set ' )-> with ($ key , $ value , $ ttl )->andReturn (resolve (true ));
63
+ self ::assertTrue ((new PSR16Adapter ($ client ))->set ($ key , $ value , $ dateIntervalTtl ));
63
64
}
64
65
65
66
public function testSetTtlException (): void
@@ -68,12 +69,12 @@ public function testSetTtlException(): void
68
69
self ::expectException ($ exception ::class);
69
70
self ::expectExceptionMessage ($ exception ->getMessage ());
70
71
71
- $ client = $ this -> prophesize (CacheInterface::class);
72
+ $ client = Mockery:: mock (CacheInterface::class);
72
73
$ key = 'key ' ;
73
74
$ value = 'value ' ;
74
75
$ ttl = 123 ;
75
- $ client ->set ($ key , $ value , $ ttl )->shouldBeCalled ()-> willReturn (reject ($ exception ));
76
- self ::assertFalse ((new PSR16Adapter ($ client-> reveal () ))->set ($ key , $ value , $ ttl ));
76
+ $ client ->shouldReceive ( ' set ' )-> with ($ key , $ value , $ ttl )->andReturn (reject ($ exception ));
77
+ self ::assertFalse ((new PSR16Adapter ($ client ))->set ($ key , $ value , $ ttl ));
77
78
}
78
79
79
80
public function testSetException (): void
@@ -82,19 +83,19 @@ public function testSetException(): void
82
83
self ::expectException ($ exception ::class);
83
84
self ::expectExceptionMessage ($ exception ->getMessage ());
84
85
85
- $ client = $ this -> prophesize (CacheInterface::class);
86
+ $ client = Mockery:: mock (CacheInterface::class);
86
87
$ key = 'key ' ;
87
88
$ value = 'value ' ;
88
- $ client ->set ($ key , $ value , null )->shouldBeCalled ()-> willReturn (reject ($ exception ));
89
- self ::assertFalse ((new PSR16Adapter ($ client-> reveal () ))->set ($ key , $ value ));
89
+ $ client ->shouldReceive ( ' set ' )-> with ($ key , $ value , null )->andReturn (reject ($ exception ));
90
+ self ::assertFalse ((new PSR16Adapter ($ client ))->set ($ key , $ value ));
90
91
}
91
92
92
93
public function testDelete (): void
93
94
{
94
- $ client = $ this -> prophesize (CacheInterface::class);
95
+ $ client = Mockery:: mock (CacheInterface::class);
95
96
$ key = 'key ' ;
96
- $ client ->delete ( $ key )->shouldBeCalled ( )->willReturn (resolve (true ));
97
- ( new PSR16Adapter ($ client-> reveal ())) ->delete ($ key );
97
+ $ client ->shouldReceive ( ' delete ' )->with ( $ key )->andReturn (resolve (true ));
98
+ self :: assertTrue (( new PSR16Adapter ($ client)) ->delete ($ key) );
98
99
}
99
100
100
101
public function testDeleteException (): void
@@ -103,26 +104,26 @@ public function testDeleteException(): void
103
104
self ::expectException ($ exception ::class);
104
105
self ::expectExceptionMessage ($ exception ->getMessage ());
105
106
106
- $ client = $ this -> prophesize (CacheInterface::class);
107
+ $ client = Mockery:: mock (CacheInterface::class);
107
108
$ key = 'key ' ;
108
- $ client ->delete ( $ key )->shouldBeCalled ( )->willReturn (reject ($ exception ));
109
- (new PSR16Adapter ($ client-> reveal () ))->delete ($ key );
109
+ $ client ->shouldReceive ( ' delete ' )->with ( $ key )->andReturn (reject ($ exception ));
110
+ (new PSR16Adapter ($ client ))->delete ($ key );
110
111
}
111
112
112
113
public function testHas (): void
113
114
{
114
- $ client = $ this -> prophesize (CacheInterface::class);
115
+ $ client = Mockery:: mock (CacheInterface::class);
115
116
$ key = 'key ' ;
116
- $ client ->has ( $ key )->shouldBeCalled ( )->willReturn (resolve (true ));
117
- ( new PSR16Adapter ($ client-> reveal ())) ->has ($ key );
117
+ $ client ->shouldReceive ( ' has ' )->with ( $ key )->andReturn (resolve (true ));
118
+ self :: assertTrue (( new PSR16Adapter ($ client)) ->has ($ key) );
118
119
}
119
120
120
121
public function testDeleteMultiple (): void
121
122
{
122
- $ client = $ this -> prophesize (CacheInterface::class);
123
+ $ client = Mockery:: mock (CacheInterface::class);
123
124
$ key = 'key ' ;
124
- $ client ->deleteMultiple ([$ key ])->shouldBeCalled ()-> willReturn (resolve (true ));
125
- ( new PSR16Adapter ($ client-> reveal ())) ->deleteMultiple ([$ key ]);
125
+ $ client ->shouldReceive ( ' deleteMultiple ' )-> with ([$ key ])->andReturn (resolve (true ));
126
+ self :: assertTrue (( new PSR16Adapter ($ client)) ->deleteMultiple ([$ key ]) );
126
127
}
127
128
128
129
public function testDeleteMultipleException (): void
@@ -131,35 +132,35 @@ public function testDeleteMultipleException(): void
131
132
self ::expectException ($ exception ::class);
132
133
self ::expectExceptionMessage ($ exception ->getMessage ());
133
134
134
- $ client = $ this -> prophesize (CacheInterface::class);
135
+ $ client = Mockery:: mock (CacheInterface::class);
135
136
$ key = 'key ' ;
136
- $ client ->deleteMultiple ([$ key ])->shouldBeCalled ()-> willReturn (reject ($ exception ));
137
- (new PSR16Adapter ($ client-> reveal () ))->deleteMultiple ([$ key ]);
137
+ $ client ->shouldReceive ( ' deleteMultiple ' )-> with ([$ key ])->andReturn (reject ($ exception ));
138
+ (new PSR16Adapter ($ client ))->deleteMultiple ([$ key ]);
138
139
}
139
140
140
141
public function testCLear (): void
141
142
{
142
- $ client = $ this -> prophesize (CacheInterface::class);
143
- $ client ->clear ( )->shouldBeCalled ()-> willReturn (resolve (true ));
144
- ( new PSR16Adapter ($ client-> reveal ())) ->clear ();
143
+ $ client = Mockery:: mock (CacheInterface::class);
144
+ $ client ->shouldReceive ( ' clear ' )->andReturn (resolve (true ));
145
+ self :: assertTrue (( new PSR16Adapter ($ client)) ->clear () );
145
146
}
146
147
147
148
public function testSetMultiple (): void
148
149
{
149
- $ client = $ this -> prophesize (CacheInterface::class);
150
+ $ client = Mockery:: mock (CacheInterface::class);
150
151
$ key = 'key ' ;
151
152
$ value = 'value ' ;
152
153
$ ttl = 123 ;
153
- $ client ->setMultiple ([$ key => $ value ], $ ttl )->shouldBeCalled ()-> willReturn (resolve (true ));
154
- self ::assertTrue ((new PSR16Adapter ($ client-> reveal () ))->setMultiple ([$ key => $ value ], $ ttl ));
154
+ $ client ->shouldReceive ( ' setMultiple ' )-> with ([$ key => $ value ], $ ttl )->andReturn (resolve (true ));
155
+ self ::assertTrue ((new PSR16Adapter ($ client ))->setMultiple ([$ key => $ value ], $ ttl ));
155
156
}
156
157
157
158
public function testGetMultiple (): void
158
159
{
159
- $ client = $ this -> prophesize (CacheInterface::class);
160
+ $ client = Mockery:: mock (CacheInterface::class);
160
161
$ key = 'key ' ;
161
162
$ value = 'value ' ;
162
- $ client ->getMultiple ([$ key ], null )->shouldBeCalled ()-> willReturn (resolve ([$ key => $ value ]));
163
- self ::assertSame ([$ key => $ value ], (new PSR16Adapter ($ client-> reveal () ))->getMultiple ([$ key ]));
163
+ $ client ->shouldReceive ( ' getMultiple ' )-> with ([$ key ], null )->andReturn (resolve ([$ key => $ value ]));
164
+ self ::assertSame ([$ key => $ value ], (new PSR16Adapter ($ client ))->getMultiple ([$ key ]));
164
165
}
165
166
}
0 commit comments