66
77use DateInterval ;
88use Exception ;
9+ use Mockery ;
910use React \Cache \CacheInterface ;
1011use WyriHaximus \AsyncTestUtilities \AsyncTestCase ;
1112use WyriHaximus \React \Cache \PSR16Adapter ;
@@ -17,49 +18,49 @@ final class PSR16AdapterTest extends AsyncTestCase
1718{
1819 public function testGet (): void
1920 {
20- $ client = $ this -> prophesize (CacheInterface::class);
21+ $ client = Mockery:: mock (CacheInterface::class);
2122 $ key = 'key ' ;
2223 $ 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 ));
2526 }
2627
2728 public function testGetNonExistant (): void
2829 {
29- $ client = $ this -> prophesize (CacheInterface::class);
30+ $ client = Mockery:: mock (CacheInterface::class);
3031 $ 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 ));
3334 }
3435
3536 public function testSet (): void
3637 {
37- $ client = $ this -> prophesize (CacheInterface::class);
38+ $ client = Mockery:: mock (CacheInterface::class);
3839 $ key = 'key ' ;
3940 $ 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) );
4243 }
4344
4445 public function testSetTtl (): void
4546 {
46- $ client = $ this -> prophesize (CacheInterface::class);
47+ $ client = Mockery:: mock (CacheInterface::class);
4748 $ key = 'key ' ;
4849 $ value = 'value ' ;
4950 $ 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 ));
5253 }
5354
5455 public function testSetDateIntervalTtl (): void
5556 {
56- $ client = $ this -> prophesize (CacheInterface::class);
57+ $ client = Mockery:: mock (CacheInterface::class);
5758 $ key = 'key ' ;
5859 $ value = 'value ' ;
5960 $ dateIntervalTtl = new DateInterval ('PT123S ' );
6061 $ 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 ));
6364 }
6465
6566 public function testSetTtlException (): void
@@ -68,12 +69,12 @@ public function testSetTtlException(): void
6869 self ::expectException ($ exception ::class);
6970 self ::expectExceptionMessage ($ exception ->getMessage ());
7071
71- $ client = $ this -> prophesize (CacheInterface::class);
72+ $ client = Mockery:: mock (CacheInterface::class);
7273 $ key = 'key ' ;
7374 $ value = 'value ' ;
7475 $ 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 ));
7778 }
7879
7980 public function testSetException (): void
@@ -82,19 +83,19 @@ public function testSetException(): void
8283 self ::expectException ($ exception ::class);
8384 self ::expectExceptionMessage ($ exception ->getMessage ());
8485
85- $ client = $ this -> prophesize (CacheInterface::class);
86+ $ client = Mockery:: mock (CacheInterface::class);
8687 $ key = 'key ' ;
8788 $ 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 ));
9091 }
9192
9293 public function testDelete (): void
9394 {
94- $ client = $ this -> prophesize (CacheInterface::class);
95+ $ client = Mockery:: mock (CacheInterface::class);
9596 $ 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) );
9899 }
99100
100101 public function testDeleteException (): void
@@ -103,26 +104,26 @@ public function testDeleteException(): void
103104 self ::expectException ($ exception ::class);
104105 self ::expectExceptionMessage ($ exception ->getMessage ());
105106
106- $ client = $ this -> prophesize (CacheInterface::class);
107+ $ client = Mockery:: mock (CacheInterface::class);
107108 $ 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 );
110111 }
111112
112113 public function testHas (): void
113114 {
114- $ client = $ this -> prophesize (CacheInterface::class);
115+ $ client = Mockery:: mock (CacheInterface::class);
115116 $ 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) );
118119 }
119120
120121 public function testDeleteMultiple (): void
121122 {
122- $ client = $ this -> prophesize (CacheInterface::class);
123+ $ client = Mockery:: mock (CacheInterface::class);
123124 $ 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 ]) );
126127 }
127128
128129 public function testDeleteMultipleException (): void
@@ -131,35 +132,35 @@ public function testDeleteMultipleException(): void
131132 self ::expectException ($ exception ::class);
132133 self ::expectExceptionMessage ($ exception ->getMessage ());
133134
134- $ client = $ this -> prophesize (CacheInterface::class);
135+ $ client = Mockery:: mock (CacheInterface::class);
135136 $ 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 ]);
138139 }
139140
140141 public function testCLear (): void
141142 {
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 () );
145146 }
146147
147148 public function testSetMultiple (): void
148149 {
149- $ client = $ this -> prophesize (CacheInterface::class);
150+ $ client = Mockery:: mock (CacheInterface::class);
150151 $ key = 'key ' ;
151152 $ value = 'value ' ;
152153 $ 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 ));
155156 }
156157
157158 public function testGetMultiple (): void
158159 {
159- $ client = $ this -> prophesize (CacheInterface::class);
160+ $ client = Mockery:: mock (CacheInterface::class);
160161 $ key = 'key ' ;
161162 $ 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 ]));
164165 }
165166}
0 commit comments