@@ -18,7 +18,7 @@ final class QueueTest extends TestCase
1818 private $ mongoUrl ;
1919 private $ queue ;
2020
21- public function setUp ()
21+ public function setUp (): void
2222 {
2323 $ this ->mongoUrl = getenv ('TESTING_MONGO_URL ' ) ?: 'mongodb://localhost:27017 ' ;
2424 $ mongo = new Client (
@@ -32,18 +32,18 @@ public function setUp()
3232 $ this ->queue = new Queue ($ this ->collection );
3333 }
3434
35- public function tearDown ()
35+ public function tearDown (): void
3636 {
3737 (new Client ($ this ->mongoUrl ))->dropDatabase ('testing ' );
3838 }
3939
4040 /**
4141 * @test
4242 * @covers ::__construct
43- * @expectedException \InvalidArgumentException
4443 */
4544 public function constructWithNonStringUrl ()
4645 {
46+ $ this ->expectException (\InvalidArgumentException::class);
4747 new Queue (1 , 'testing ' , 'messages ' );
4848 }
4949
@@ -71,10 +71,10 @@ public function ensureGetIndex()
7171 /**
7272 * @test
7373 * @covers ::ensureGetIndex
74- * @expectedException \Exception
7574 */
7675 public function ensureGetIndexWithTooLongCollectionName ()
7776 {
77+ $ this ->expectException (\Exception::class);
7878 $ collectionName = 'messages012345678901234567890123456789012345678901234567890123456789 ' ;
7979 $ collectionName .= '012345678901234567890123456789012345678901234567890123456789 ' ;//128 chars
8080
@@ -85,40 +85,40 @@ public function ensureGetIndexWithTooLongCollectionName()
8585 /**
8686 * @test
8787 * @covers ::ensureGetIndex
88- * @expectedException \InvalidArgumentException
8988 */
9089 public function ensureGetIndexWithNonStringBeforeSortKey ()
9190 {
91+ $ this ->expectException (\InvalidArgumentException::class);
9292 $ this ->queue ->ensureGetIndex ([0 => 1 ]);
9393 }
9494
9595 /**
9696 * @test
9797 * @covers ::ensureGetIndex
98- * @expectedException \InvalidArgumentException
9998 */
10099 public function ensureGetIndexWithNonStringAfterSortKey ()
101100 {
101+ $ this ->expectException (\InvalidArgumentException::class);
102102 $ this ->queue ->ensureGetIndex (['field ' => 1 ], [0 => 1 ]);
103103 }
104104
105105 /**
106106 * @test
107107 * @covers ::ensureGetIndex
108- * @expectedException \InvalidArgumentException
109108 */
110109 public function ensureGetIndexWithBadBeforeSortValue ()
111110 {
111+ $ this ->expectException (\InvalidArgumentException::class);
112112 $ this ->queue ->ensureGetIndex (['field ' => 'NotAnInt ' ]);
113113 }
114114
115115 /**
116116 * @test
117117 * @covers ::ensureGetIndex
118- * @expectedException \InvalidArgumentException
119118 */
120119 public function ensureGetIndexWithBadAfterSortValue ()
121120 {
121+ $ this ->expectException (\InvalidArgumentException::class);
122122 $ this ->queue ->ensureGetIndex ([], ['field ' => 'NotAnInt ' ]);
123123 }
124124
@@ -127,11 +127,11 @@ public function ensureGetIndexWithBadAfterSortValue()
127127 *
128128 * @test
129129 * @covers ::ensureGetIndex
130- * @expectedException \Exception
131- * @expectedExceptionMessage couldnt create index after 5 attempts
132130 */
133131 public function ensureIndexCannotBeCreatedAfterFiveAttempts ()
134132 {
133+ $ this ->expectException (\Exception::class);
134+ $ this ->expectExceptionMessage ('couldnt create index after 5 attempts ' );
135135 $ mockCollection = $ this ->getMockBuilder ('\MongoDB\Collection ' )->disableOriginalConstructor ()->getMock ();
136136
137137 $ mockCollection ->method ('listIndexes ' )->willReturn ([]);
@@ -180,20 +180,20 @@ public function ensureCountIndexWithPrefixOfPrevious()
180180 /**
181181 * @test
182182 * @covers ::ensureCountIndex
183- * @expectedException \InvalidArgumentException
184183 */
185184 public function ensureCountIndexWithNonStringKey ()
186185 {
186+ $ this ->expectException (\InvalidArgumentException::class);
187187 $ this ->queue ->ensureCountIndex ([0 => 1 ], false );
188188 }
189189
190190 /**
191191 * @test
192192 * @covers ::ensureCountIndex
193- * @expectedException \InvalidArgumentException
194193 */
195194 public function ensureCountIndexWithBadValue ()
196195 {
196+ $ this ->expectException (\InvalidArgumentException::class);
197197 $ this ->queue ->ensureCountIndex (['field ' => 'NotAnInt ' ], false );
198198 }
199199
@@ -237,10 +237,10 @@ public function getWithNegativePollDuration()
237237 /**
238238 * @test
239239 * @covers ::get
240- * @expectedException \InvalidArgumentException
241240 */
242241 public function getWithNonStringKey ()
243242 {
243+ $ this ->expectException (\InvalidArgumentException::class);
244244 $ this ->queue ->get ([0 => 'a value ' ]);
245245 }
246246
@@ -386,10 +386,10 @@ public function earliestGet()
386386 /**
387387 * @test
388388 * @covers ::count
389- * @expectedException \InvalidArgumentException
390389 */
391390 public function countWithNonStringKey ()
392391 {
392+ $ this ->expectException (\InvalidArgumentException::class);
393393 $ this ->queue ->count ([0 => 'a value ' ]);
394394 }
395395
0 commit comments