@@ -54,7 +54,7 @@ public function testOptimisticLockingIntThrowsException()
54
54
// Now lets change a property and try and save it again
55
55
$ article ->title = 'ok ' ;
56
56
57
- $ this ->setExpectedException ( ' Doctrine\ODM\MongoDB\LockException ' );
57
+ $ this ->expectException (\ Doctrine \ODM \MongoDB \LockException::class );
58
58
59
59
$ this ->dm ->flush ();
60
60
}
@@ -133,11 +133,14 @@ public function testLockTimestampThrowsException()
133
133
// Now lets change a property and try and save it again
134
134
$ article ->title = 'ok ' ;
135
135
136
- $ this ->setExpectedException ( ' Doctrine\ODM\MongoDB\LockException ' );
136
+ $ this ->expectException (\ Doctrine \ODM \MongoDB \LockException::class );
137
137
138
138
$ this ->dm ->flush ();
139
139
}
140
140
141
+ /**
142
+ * @doesNotPerformAssertions
143
+ */
141
144
public function testLockVersionedDocument ()
142
145
{
143
146
$ article = new LockInt ();
@@ -157,7 +160,7 @@ public function testLockVersionedDocumentMissmatchThrowsException()
157
160
$ this ->dm ->persist ($ article );
158
161
$ this ->dm ->flush ();
159
162
160
- $ this ->setExpectedException ( ' Doctrine\ODM\MongoDB\LockException ' );
163
+ $ this ->expectException (\ Doctrine \ODM \MongoDB \LockException::class );
161
164
162
165
$ this ->dm ->lock ($ article , LockMode::OPTIMISTIC , $ article ->version + 1 );
163
166
}
@@ -170,7 +173,8 @@ public function testLockUnversionedDocumentThrowsException()
170
173
$ this ->dm ->persist ($ user );
171
174
$ this ->dm ->flush ();
172
175
173
- $ this ->setExpectedException ('Doctrine\ODM\MongoDB\LockException ' , 'Document Documents\User is not versioned. ' );
176
+ $ this ->expectException (\Doctrine \ODM \MongoDB \LockException::class);
177
+ $ this ->expectExceptionMessage ('Document Documents\User is not versioned. ' );
174
178
175
179
$ this ->dm ->lock ($ user , LockMode::OPTIMISTIC );
176
180
}
@@ -179,7 +183,8 @@ public function testLockUnmanagedDocumentThrowsException()
179
183
{
180
184
$ article = new LockInt ();
181
185
182
- $ this ->setExpectedException ('InvalidArgumentException ' , 'Document is not MANAGED. ' );
186
+ $ this ->expectException (\InvalidArgumentException::class);
187
+ $ this ->expectExceptionMessage ('Document is not MANAGED. ' );
183
188
184
189
$ this ->dm ->lock ($ article , LockMode::OPTIMISTIC , $ article ->version + 1 );
185
190
}
@@ -244,7 +249,7 @@ public function testPessimisticReadLockThrowsExceptionOnRemove()
244
249
$ coll = $ this ->dm ->getDocumentCollection (__NAMESPACE__ .'\LockInt ' );
245
250
$ coll ->update (array ('_id ' => new \MongoId ($ article ->id )), array ('locked ' => LockMode::PESSIMISTIC_READ ));
246
251
247
- $ this ->setExpectedException ( ' Doctrine\ODM\MongoDB\LockException ' );
252
+ $ this ->expectException (\ Doctrine \ODM \MongoDB \LockException::class );
248
253
249
254
$ this ->dm ->remove ($ article );
250
255
$ this ->dm ->flush ();
@@ -261,7 +266,7 @@ public function testPessimisticReadLockThrowsExceptionOnUpdate()
261
266
$ coll = $ this ->dm ->getDocumentCollection (__NAMESPACE__ .'\LockInt ' );
262
267
$ coll ->update (array ('_id ' => new \MongoId ($ article ->id )), array ('locked ' => LockMode::PESSIMISTIC_READ ));
263
268
264
- $ this ->setExpectedException ( ' Doctrine\ODM\MongoDB\LockException ' );
269
+ $ this ->expectException (\ Doctrine \ODM \MongoDB \LockException::class );
265
270
266
271
$ article ->title = 'changed ' ;
267
272
$ this ->dm ->flush ();
@@ -278,7 +283,7 @@ public function testPessimisticWriteLockThrowExceptionOnRemove()
278
283
$ coll = $ this ->dm ->getDocumentCollection (__NAMESPACE__ .'\LockInt ' );
279
284
$ coll ->update (array ('_id ' => new \MongoId ($ article ->id )), array ('locked ' => LockMode::PESSIMISTIC_WRITE ));
280
285
281
- $ this ->setExpectedException ( ' Doctrine\ODM\MongoDB\LockException ' );
286
+ $ this ->expectException (\ Doctrine \ODM \MongoDB \LockException::class );
282
287
283
288
$ this ->dm ->remove ($ article );
284
289
$ this ->dm ->flush ();
@@ -295,7 +300,7 @@ public function testPessimisticWriteLockThrowExceptionOnUpdate()
295
300
$ coll = $ this ->dm ->getDocumentCollection (__NAMESPACE__ .'\LockInt ' );
296
301
$ coll ->update (array ('_id ' => new \MongoId ($ article ->id )), array ('locked ' => LockMode::PESSIMISTIC_WRITE ));
297
302
298
- $ this ->setExpectedException ( ' Doctrine\ODM\MongoDB\LockException ' );
303
+ $ this ->expectException (\ Doctrine \ODM \MongoDB \LockException::class );
299
304
300
305
$ article ->title = 'changed ' ;
301
306
$ this ->dm ->flush ();
@@ -312,7 +317,7 @@ public function testPessimisticWriteLockThrowExceptionOnRead()
312
317
$ coll = $ this ->dm ->getDocumentCollection (__NAMESPACE__ .'\LockInt ' );
313
318
$ coll ->update (array ('_id ' => new \MongoId ($ article ->id )), array ('locked ' => LockMode::PESSIMISTIC_WRITE ));
314
319
315
- $ this ->setExpectedException ( ' Doctrine\ODM\MongoDB\LockException ' );
320
+ $ this ->expectException (\ Doctrine \ODM \MongoDB \LockException::class );
316
321
317
322
$ this ->dm ->clear ();
318
323
$ article = $ this ->dm ->find (__NAMESPACE__ .'\LockInt ' , $ article ->id );
@@ -358,13 +363,15 @@ public function testPessimisticWriteLockFunctional()
358
363
359
364
public function testInvalidLockDocument ()
360
365
{
361
- $ this ->setExpectedException ('Doctrine\ODM\MongoDB\MongoDBException ' , 'Invalid lock field type string. Lock field must be int. ' );
366
+ $ this ->expectException (\Doctrine \ODM \MongoDB \MongoDBException::class);
367
+ $ this ->expectExceptionMessage ('Invalid lock field type string. Lock field must be int. ' );
362
368
$ this ->dm ->getClassMetadata (__NAMESPACE__ .'\InvalidLockDocument ' );
363
369
}
364
370
365
371
public function testInvalidVersionDocument ()
366
372
{
367
- $ this ->setExpectedException ('Doctrine\ODM\MongoDB\MongoDBException ' , 'Invalid version field type string. Version field must be int or date. ' );
373
+ $ this ->expectException (\Doctrine \ODM \MongoDB \MongoDBException::class);
374
+ $ this ->expectExceptionMessage ('Invalid version field type string. Version field must be int or date. ' );
368
375
$ this ->dm ->getClassMetadata (__NAMESPACE__ .'\InvalidVersionDocument ' );
369
376
}
370
377
0 commit comments