@@ -28,20 +28,22 @@ public function testGetReturnsNullWhenNotFound()
28
28
$ this ->assertNull ($ store ->get ('bar ' ));
29
29
}
30
30
31
- public function testAPCValueIsReturned ()
31
+ #[DataProvider('resolveKeyNameDataProvider ' )]
32
+ public function testAPCValueIsReturned (mixed $ key , string $ expected )
32
33
{
33
34
$ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['get ' ])->getMock ();
34
- $ apc ->expects ($ this ->once ())->method ('get ' )->willReturn ('bar ' );
35
+ $ apc ->expects ($ this ->once ())->method ('get ' )->with ( $ this -> equalTo ( $ expected ))-> willReturn ('bar ' );
35
36
$ store = new ApcStore ($ apc );
36
- $ this ->assertSame ('bar ' , $ store ->get (' foo ' ));
37
+ $ this ->assertSame ('bar ' , $ store ->get ($ key ));
37
38
}
38
39
39
- public function testAPCFalseValueIsReturned ()
40
+ #[DataProvider('resolveKeyNameDataProvider ' )]
41
+ public function testAPCFalseValueIsReturned (mixed $ key , string $ expected )
40
42
{
41
43
$ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['get ' ])->getMock ();
42
- $ apc ->expects ($ this ->once ())->method ('get ' )->willReturn (false );
44
+ $ apc ->expects ($ this ->once ())->method ('get ' )->with ( $ this -> equalTo ( $ expected ))-> willReturn (false );
43
45
$ store = new ApcStore ($ apc );
44
- $ this ->assertFalse ($ store ->get (' foo ' ));
46
+ $ this ->assertFalse ($ store ->get ($ key ));
45
47
}
46
48
47
49
public function testGetMultipleReturnsNullWhenNotFoundAndValueWhenFound ()
@@ -60,14 +62,15 @@ public function testGetMultipleReturnsNullWhenNotFoundAndValueWhenFound()
60
62
], $ store ->many (['foo ' , 'bar ' , 'baz ' ]));
61
63
}
62
64
63
- public function testSetMethodProperlyCallsAPC ()
65
+ #[DataProvider('resolveKeyNameDataProvider ' )]
66
+ public function testSetMethodProperlyCallsAPC (mixed $ key , string $ expected )
64
67
{
65
68
$ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['put ' ])->getMock ();
66
69
$ apc ->expects ($ this ->once ())
67
- ->method ('put ' )->with ($ this ->equalTo (' foo ' ), $ this ->equalTo ('bar ' ), $ this ->equalTo (60 ))
70
+ ->method ('put ' )->with ($ this ->equalTo ($ expected ), $ this ->equalTo ('bar ' ), $ this ->equalTo (60 ))
68
71
->willReturn (true );
69
72
$ store = new ApcStore ($ apc );
70
- $ result = $ store ->put (' foo ' , 'bar ' , 60 );
73
+ $ result = $ store ->put ($ key , 'bar ' , 60 );
71
74
$ this ->assertTrue ($ result );
72
75
}
73
76
@@ -99,39 +102,43 @@ public function testSetMultipleMethodProperlyCallsAPC()
99
102
$ this ->assertTrue ($ result );
100
103
}
101
104
102
- public function testIncrementMethodProperlyCallsAPC ()
105
+ #[DataProvider('resolveKeyNameDataProvider ' )]
106
+ public function testIncrementMethodProperlyCallsAPC (mixed $ key , string $ expected )
103
107
{
104
108
$ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['increment ' ])->getMock ();
105
- $ apc ->expects ($ this ->once ())->method ('increment ' )->with ($ this ->equalTo (' foo ' ), $ this ->equalTo (5 ));
109
+ $ apc ->expects ($ this ->once ())->method ('increment ' )->with ($ this ->equalTo ($ expected ), $ this ->equalTo (5 ));
106
110
$ store = new ApcStore ($ apc );
107
- $ store ->increment (' foo ' , 5 );
111
+ $ store ->increment ($ key , 5 );
108
112
}
109
113
110
- public function testDecrementMethodProperlyCallsAPC ()
114
+ #[DataProvider('resolveKeyNameDataProvider ' )]
115
+ public function testDecrementMethodProperlyCallsAPC (mixed $ key , string $ expected )
111
116
{
112
117
$ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['decrement ' ])->getMock ();
113
- $ apc ->expects ($ this ->once ())->method ('decrement ' )->with ($ this ->equalTo (' foo ' ), $ this ->equalTo (5 ));
118
+ $ apc ->expects ($ this ->once ())->method ('decrement ' )->with ($ this ->equalTo ($ expected ), $ this ->equalTo (5 ));
114
119
$ store = new ApcStore ($ apc );
115
- $ store ->decrement (' foo ' , 5 );
120
+ $ store ->decrement ($ key , 5 );
116
121
}
117
122
118
- public function testStoreItemForeverProperlyCallsAPC ()
123
+ #[DataProvider('resolveKeyNameDataProvider ' )]
124
+ public function testStoreItemForeverProperlyCallsAPC (mixed $ key , string $ expected )
119
125
{
120
126
$ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['put ' ])->getMock ();
121
127
$ apc ->expects ($ this ->once ())
122
- ->method ('put ' )->with ($ this ->equalTo (' foo ' ), $ this ->equalTo ('bar ' ), $ this ->equalTo (0 ))
128
+ ->method ('put ' )->with ($ this ->equalTo ($ expected ), $ this ->equalTo ('bar ' ), $ this ->equalTo (0 ))
123
129
->willReturn (true );
124
130
$ store = new ApcStore ($ apc );
125
- $ result = $ store ->forever (' foo ' , 'bar ' );
131
+ $ result = $ store ->forever ($ key , 'bar ' );
126
132
$ this ->assertTrue ($ result );
127
133
}
128
134
129
- public function testForgetMethodProperlyCallsAPC ()
135
+ #[DataProvider('resolveKeyNameDataProvider ' )]
136
+ public function testForgetMethodProperlyCallsAPC (mixed $ key , string $ expected )
130
137
{
131
138
$ apc = $ this ->getMockBuilder (ApcWrapper::class)->onlyMethods (['delete ' ])->getMock ();
132
- $ apc ->expects ($ this ->once ())->method ('delete ' )->with ($ this ->equalTo (' foo ' ))->willReturn (true );
139
+ $ apc ->expects ($ this ->once ())->method ('delete ' )->with ($ this ->equalTo ($ expected ))->willReturn (true );
133
140
$ store = new ApcStore ($ apc );
134
- $ result = $ store ->forget (' foo ' );
141
+ $ result = $ store ->forget ($ key );
135
142
$ this ->assertTrue ($ result );
136
143
}
137
144
0 commit comments