diff --git a/src/Model/ViewModel.php b/src/Model/ViewModel.php index 806db9a0..2b8029e5 100644 --- a/src/Model/ViewModel.php +++ b/src/Model/ViewModel.php @@ -144,8 +144,7 @@ public function __unset($name) return null; } - $variables = $this->getVariables(); - unset($variables[$name]); + unset($this->variables[$name]); } /** diff --git a/test/Model/ViewModelTest.php b/test/Model/ViewModelTest.php index 151d4879..fa4f2859 100644 --- a/test/Model/ViewModelTest.php +++ b/test/Model/ViewModelTest.php @@ -82,6 +82,13 @@ public function testSetVariablesMergesWithPreviouslyStoredVariables() $this->assertEquals(array('foo' => 'bar', 'bar' => 'BAZBAT'), $model->getVariables()); } + public function testCanUnsetVariable() + { + $model = new ViewModel(array('foo' => 'bar')); + $model->__unset('foo'); + $this->assertEquals(array(), $model->getVariables()); + } + public function testCanSetOptionsSingly() { $model = new ViewModel(array(), array('foo' => 'bar'));