Skip to content

Commit

Permalink
Refactor deprecated PHPUnit annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
ifox committed Feb 10, 2022
1 parent 1195f44 commit de97a56
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
35 changes: 14 additions & 21 deletions tests/NodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,32 +221,29 @@ public function testCategoryMovesUp()
$this->assertNodeReceivesValidValues($node);
}

/**
* @expectedException Exception
*/
public function testFailsToInsertIntoChild()
{
$this->expectException(Exception::class);

$node = $this->findCategory('notebooks');
$target = $node->children()->first();

$node->afterNode($target)->save();
}

/**
* @expectedException Exception
*/
public function testFailsToAppendIntoItself()
{
$this->expectException(Exception::class);

$node = $this->findCategory('notebooks');

$node->appendToNode($node)->save();
}

/**
* @expectedException Exception
*/
public function testFailsToPrependIntoItself()
{
$this->expectException(Exception::class);

$node = $this->findCategory('notebooks');

$node->prependTo($node)->save();
Expand Down Expand Up @@ -338,11 +335,10 @@ public function testParentIdAttributeAccessorAppendsNode()
$this->assertTrue($node->isRoot());
}

/**
* @expectedException Exception
*/
public function testFailsToSaveNodeUntilNotInserted()
{
$this->expectException(Exception::class);

$node = new Category;
$node->save();
}
Expand Down Expand Up @@ -405,11 +401,10 @@ public function testSoftDeletedNodeisDeletedWhenParentIsDeleted()
$this->assertNull($this->findCategory('sony'));
}

/**
* @expectedException Exception
*/
public function testFailsToSaveNodeUntilParentIsSaved()
{
$this->expectException(Exception::class);

$node = new Category(array('title' => 'Node'));
$parent = new Category(array('title' => 'Parent'));

Expand Down Expand Up @@ -641,11 +636,10 @@ public function testDescendantsOfNonExistingNode()
$this->assertTrue($node->getDescendants()->isEmpty());
}

/**
* @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
*/
public function testWhereDescendantsOf()
{
$this->expectException(\Illuminate\Database\Eloquent\ModelNotFoundException::class);

Category::whereDescendantOf(124)->get();
}

Expand Down Expand Up @@ -852,11 +846,10 @@ public function testRebuildTreeWithDeletion()
$this->assertTrue($nodes->count() > 1);
}

/**
* @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
*/
public function testRebuildFailsWithInvalidPK()
{
$this->expectException(\Illuminate\Database\Eloquent\ModelNotFoundException::class);

Category::rebuildTree([ [ 'id' => 24 ] ]);
}

Expand Down
15 changes: 6 additions & 9 deletions tests/ScopedNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,10 @@ public function testInsertion()
$this->assertOtherScopeNotAffected();
}

/**
* @expectedException \Illuminate\Database\Eloquent\ModelNotFoundException
*/
public function testInsertionToParentFromOtherScope()
{
$this->expectException(\Illuminate\Database\Eloquent\ModelNotFoundException::class);

$node = MenuItem::create([ 'menu_id' => 2, 'parent_id' => 5 ]);
}

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

/**
* @expectedException LogicException
*/
public function testAppendingToAnotherScopeFails()
{
$this->expectException(LogicException::class);

$a = MenuItem::find(1);
$b = MenuItem::find(3);

$a->appendToNode($b)->save();
}

/**
* @expectedException LogicException
*/
public function testInsertingBeforeAnotherScopeFails()
{
$this->expectException(LogicException::class);

$a = MenuItem::find(1);
$b = MenuItem::find(3);

Expand Down

0 comments on commit de97a56

Please sign in to comment.