1
0
Fork 0
mirror of https://github.com/Oreolek/yii2-nested-sets.git synced 2024-06-29 04:55:00 +03:00

Added new cases to unit tests

This commit is contained in:
Alexander Kochetov 2015-01-03 16:35:59 +03:00
parent bcc816c017
commit 4612b0aba0

View file

@ -44,7 +44,7 @@ class NestedSetsBehaviorTest extends DatabaseTestCase
* @covers \creocoder\nestedsets\NestedSetsBehavior::beforeInsert * @covers \creocoder\nestedsets\NestedSetsBehavior::beforeInsert
* @expectedException \yii\db\Exception * @expectedException \yii\db\Exception
*/ */
public function testMakeNewRootExceptionIsRaisedWhenRootIsExists() public function testMakeNewRootExceptionIsRaisedWhenTreeAttributeIsFalseAndRootIsExists()
{ {
$dataSet = $this->createFlatXMLDataSet(__DIR__ . '/datasets/tree.xml'); $dataSet = $this->createFlatXMLDataSet(__DIR__ . '/datasets/tree.xml');
$this->getDatabaseTester()->setDataSet($dataSet); $this->getDatabaseTester()->setDataSet($dataSet);
@ -321,7 +321,33 @@ class NestedSetsBehaviorTest extends DatabaseTestCase
$this->assertDataSetsEqual($expectedDataSet, $dataSet); $this->assertDataSetsEqual($expectedDataSet, $dataSet);
} }
// @todo: makeRoot exceptions tests here /**
* @covers \creocoder\nestedsets\NestedSetsBehavior::makeRoot
* @covers \creocoder\nestedsets\NestedSetsBehavior::beforeUpdate
* @expectedException \yii\db\Exception
*/
public function testMakeExistsRootExceptionIsRaisedWhenTreeAttributeIsFalse()
{
$dataSet = $this->createFlatXMLDataSet(__DIR__ . '/datasets/tree.xml');
$this->getDatabaseTester()->setDataSet($dataSet);
$this->getDatabaseTester()->onSetUp();
$node = Tree::findOne(9);
$node->makeRoot();
}
/**
* @covers \creocoder\nestedsets\NestedSetsBehavior::makeRoot
* @covers \creocoder\nestedsets\NestedSetsBehavior::beforeUpdate
* @expectedException \yii\db\Exception
*/
public function testMakeExistsRootExceptionIsRaisedWhenItsRoot()
{
$dataSet = $this->createFlatXMLDataSet(__DIR__ . '/datasets/multiple-roots-tree.xml');
$this->getDatabaseTester()->setDataSet($dataSet);
$this->getDatabaseTester()->onSetUp();
$node = MultipleRootsTree::findOne(23);
$node->makeRoot();
}
/** /**
* @covers \creocoder\nestedsets\NestedSetsBehavior::prependTo * @covers \creocoder\nestedsets\NestedSetsBehavior::prependTo