@@ -18,7 +18,7 @@ final class QueueTest extends TestCase
18
18
private $ mongoUrl ;
19
19
private $ queue ;
20
20
21
- public function setUp ()
21
+ public function setUp (): void
22
22
{
23
23
$ this ->mongoUrl = getenv ('TESTING_MONGO_URL ' ) ?: 'mongodb://localhost:27017 ' ;
24
24
$ mongo = new Client (
@@ -32,18 +32,18 @@ public function setUp()
32
32
$ this ->queue = new Queue ($ this ->collection );
33
33
}
34
34
35
- public function tearDown ()
35
+ public function tearDown (): void
36
36
{
37
37
(new Client ($ this ->mongoUrl ))->dropDatabase ('testing ' );
38
38
}
39
39
40
40
/**
41
41
* @test
42
42
* @covers ::__construct
43
- * @expectedException \InvalidArgumentException
44
43
*/
45
44
public function constructWithNonStringUrl ()
46
45
{
46
+ $ this ->expectException (\InvalidArgumentException::class);
47
47
new Queue (1 , 'testing ' , 'messages ' );
48
48
}
49
49
@@ -71,10 +71,10 @@ public function ensureGetIndex()
71
71
/**
72
72
* @test
73
73
* @covers ::ensureGetIndex
74
- * @expectedException \Exception
75
74
*/
76
75
public function ensureGetIndexWithTooLongCollectionName ()
77
76
{
77
+ $ this ->expectException (\Exception::class);
78
78
$ collectionName = 'messages012345678901234567890123456789012345678901234567890123456789 ' ;
79
79
$ collectionName .= '012345678901234567890123456789012345678901234567890123456789 ' ;//128 chars
80
80
@@ -85,40 +85,40 @@ public function ensureGetIndexWithTooLongCollectionName()
85
85
/**
86
86
* @test
87
87
* @covers ::ensureGetIndex
88
- * @expectedException \InvalidArgumentException
89
88
*/
90
89
public function ensureGetIndexWithNonStringBeforeSortKey ()
91
90
{
91
+ $ this ->expectException (\InvalidArgumentException::class);
92
92
$ this ->queue ->ensureGetIndex ([0 => 1 ]);
93
93
}
94
94
95
95
/**
96
96
* @test
97
97
* @covers ::ensureGetIndex
98
- * @expectedException \InvalidArgumentException
99
98
*/
100
99
public function ensureGetIndexWithNonStringAfterSortKey ()
101
100
{
101
+ $ this ->expectException (\InvalidArgumentException::class);
102
102
$ this ->queue ->ensureGetIndex (['field ' => 1 ], [0 => 1 ]);
103
103
}
104
104
105
105
/**
106
106
* @test
107
107
* @covers ::ensureGetIndex
108
- * @expectedException \InvalidArgumentException
109
108
*/
110
109
public function ensureGetIndexWithBadBeforeSortValue ()
111
110
{
111
+ $ this ->expectException (\InvalidArgumentException::class);
112
112
$ this ->queue ->ensureGetIndex (['field ' => 'NotAnInt ' ]);
113
113
}
114
114
115
115
/**
116
116
* @test
117
117
* @covers ::ensureGetIndex
118
- * @expectedException \InvalidArgumentException
119
118
*/
120
119
public function ensureGetIndexWithBadAfterSortValue ()
121
120
{
121
+ $ this ->expectException (\InvalidArgumentException::class);
122
122
$ this ->queue ->ensureGetIndex ([], ['field ' => 'NotAnInt ' ]);
123
123
}
124
124
@@ -127,11 +127,11 @@ public function ensureGetIndexWithBadAfterSortValue()
127
127
*
128
128
* @test
129
129
* @covers ::ensureGetIndex
130
- * @expectedException \Exception
131
- * @expectedExceptionMessage couldnt create index after 5 attempts
132
130
*/
133
131
public function ensureIndexCannotBeCreatedAfterFiveAttempts ()
134
132
{
133
+ $ this ->expectException (\Exception::class);
134
+ $ this ->expectExceptionMessage ('couldnt create index after 5 attempts ' );
135
135
$ mockCollection = $ this ->getMockBuilder ('\MongoDB\Collection ' )->disableOriginalConstructor ()->getMock ();
136
136
137
137
$ mockCollection ->method ('listIndexes ' )->willReturn ([]);
@@ -180,20 +180,20 @@ public function ensureCountIndexWithPrefixOfPrevious()
180
180
/**
181
181
* @test
182
182
* @covers ::ensureCountIndex
183
- * @expectedException \InvalidArgumentException
184
183
*/
185
184
public function ensureCountIndexWithNonStringKey ()
186
185
{
186
+ $ this ->expectException (\InvalidArgumentException::class);
187
187
$ this ->queue ->ensureCountIndex ([0 => 1 ], false );
188
188
}
189
189
190
190
/**
191
191
* @test
192
192
* @covers ::ensureCountIndex
193
- * @expectedException \InvalidArgumentException
194
193
*/
195
194
public function ensureCountIndexWithBadValue ()
196
195
{
196
+ $ this ->expectException (\InvalidArgumentException::class);
197
197
$ this ->queue ->ensureCountIndex (['field ' => 'NotAnInt ' ], false );
198
198
}
199
199
@@ -237,10 +237,10 @@ public function getWithNegativePollDuration()
237
237
/**
238
238
* @test
239
239
* @covers ::get
240
- * @expectedException \InvalidArgumentException
241
240
*/
242
241
public function getWithNonStringKey ()
243
242
{
243
+ $ this ->expectException (\InvalidArgumentException::class);
244
244
$ this ->queue ->get ([0 => 'a value ' ]);
245
245
}
246
246
@@ -386,10 +386,10 @@ public function earliestGet()
386
386
/**
387
387
* @test
388
388
* @covers ::count
389
- * @expectedException \InvalidArgumentException
390
389
*/
391
390
public function countWithNonStringKey ()
392
391
{
392
+ $ this ->expectException (\InvalidArgumentException::class);
393
393
$ this ->queue ->count ([0 => 'a value ' ]);
394
394
}
395
395
0 commit comments