Skip to content

Commit de97a56

Browse files
committed
Refactor deprecated PHPUnit annotations
1 parent 1195f44 commit de97a56

File tree

2 files changed

+20
-30
lines changed

2 files changed

+20
-30
lines changed

tests/NodeTest.php

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -221,32 +221,29 @@ public function testCategoryMovesUp()
221221
$this->assertNodeReceivesValidValues($node);
222222
}
223223

224-
/**
225-
* @expectedException Exception
226-
*/
227224
public function testFailsToInsertIntoChild()
228225
{
226+
$this->expectException(Exception::class);
227+
229228
$node = $this->findCategory('notebooks');
230229
$target = $node->children()->first();
231230

232231
$node->afterNode($target)->save();
233232
}
234233

235-
/**
236-
* @expectedException Exception
237-
*/
238234
public function testFailsToAppendIntoItself()
239235
{
236+
$this->expectException(Exception::class);
237+
240238
$node = $this->findCategory('notebooks');
241239

242240
$node->appendToNode($node)->save();
243241
}
244242

245-
/**
246-
* @expectedException Exception
247-
*/
248243
public function testFailsToPrependIntoItself()
249244
{
245+
$this->expectException(Exception::class);
246+
250247
$node = $this->findCategory('notebooks');
251248

252249
$node->prependTo($node)->save();
@@ -338,11 +335,10 @@ public function testParentIdAttributeAccessorAppendsNode()
338335
$this->assertTrue($node->isRoot());
339336
}
340337

341-
/**
342-
* @expectedException Exception
343-
*/
344338
public function testFailsToSaveNodeUntilNotInserted()
345339
{
340+
$this->expectException(Exception::class);
341+
346342
$node = new Category;
347343
$node->save();
348344
}
@@ -405,11 +401,10 @@ public function testSoftDeletedNodeisDeletedWhenParentIsDeleted()
405401
$this->assertNull($this->findCategory('sony'));
406402
}
407403

408-
/**
409-
* @expectedException Exception
410-
*/
411404
public function testFailsToSaveNodeUntilParentIsSaved()
412405
{
406+
$this->expectException(Exception::class);
407+
413408
$node = new Category(array('title' => 'Node'));
414409
$parent = new Category(array('title' => 'Parent'));
415410

@@ -641,11 +636,10 @@ public function testDescendantsOfNonExistingNode()
641636
$this->assertTrue($node->getDescendants()->isEmpty());
642637
}
643638

644-
/**
645-
* @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
646-
*/
647639
public function testWhereDescendantsOf()
648640
{
641+
$this->expectException(\Illuminate\Database\Eloquent\ModelNotFoundException::class);
642+
649643
Category::whereDescendantOf(124)->get();
650644
}
651645

@@ -852,11 +846,10 @@ public function testRebuildTreeWithDeletion()
852846
$this->assertTrue($nodes->count() > 1);
853847
}
854848

855-
/**
856-
* @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
857-
*/
858849
public function testRebuildFailsWithInvalidPK()
859850
{
851+
$this->expectException(\Illuminate\Database\Eloquent\ModelNotFoundException::class);
852+
860853
Category::rebuildTree([ [ 'id' => 24 ] ]);
861854
}
862855

tests/ScopedNodeTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,10 @@ public function testInsertion()
159159
$this->assertOtherScopeNotAffected();
160160
}
161161

162-
/**
163-
* @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
164-
*/
165162
public function testInsertionToParentFromOtherScope()
166163
{
164+
$this->expectException(\Illuminate\Database\Eloquent\ModelNotFoundException::class);
165+
167166
$node = MenuItem::create([ 'menu_id' => 2, 'parent_id' => 5 ]);
168167
}
169168

@@ -201,22 +200,20 @@ protected function assertOtherScopeNotAffected()
201200
MenuItem::scoped([ 'menu_id' => 2 ])->rebuildTree($data);
202201
}*/
203202

204-
/**
205-
* @expectedException LogicException
206-
*/
207203
public function testAppendingToAnotherScopeFails()
208204
{
205+
$this->expectException(LogicException::class);
206+
209207
$a = MenuItem::find(1);
210208
$b = MenuItem::find(3);
211209

212210
$a->appendToNode($b)->save();
213211
}
214212

215-
/**
216-
* @expectedException LogicException
217-
*/
218213
public function testInsertingBeforeAnotherScopeFails()
219214
{
215+
$this->expectException(LogicException::class);
216+
220217
$a = MenuItem::find(1);
221218
$b = MenuItem::find(3);
222219

0 commit comments

Comments
 (0)