Skip to content

Commit

Permalink
Add test to prove issue when saving invalid tree data
Browse files Browse the repository at this point in the history
  • Loading branch information
rchavik committed Dec 27, 2013
1 parent 1daa27c commit c48afae
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,29 @@ public function testArrayScope() {
$this->assertEquals(11, $this->Tree->find('count'));
}

/**
* testSaveWithParentAndInvalidScope method
*
* Attempting to save an invalid data should not trigger an `Undefined offset`
* error
*
* @return void
*/
public function testSaveWithParentAndInvalidScope() {
$this->Tree = new FlagTree();
$this->Tree->order = null;
$data = $this->Tree->create(array(
'name' => 'Flag',
));
$tree = $this->Tree->save($data);
$this->Tree->Behaviors->load('Tree', array(
'scope' => array('FlagTree.flag' => 100)
));
$tree['FlagTree']['parent_id'] = 1;
$result = $this->Tree->save($tree);
$this->assertFalse($result);
}

/**
* testMoveUpWithScope method
*
Expand Down

0 comments on commit c48afae

Please sign in to comment.