From 411a1b84d560a90deb9269a7254f53c6db3f709e Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 25 Feb 2013 02:40:40 +0400 Subject: [PATCH] more tests for Object --- tests/unit/framework/base/ObjectTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unit/framework/base/ObjectTest.php b/tests/unit/framework/base/ObjectTest.php index 5b95815..b47b178 100644 --- a/tests/unit/framework/base/ObjectTest.php +++ b/tests/unit/framework/base/ObjectTest.php @@ -71,6 +71,12 @@ class ObjectTest extends TestCase $this->object->NewMember = $value; } + public function testSetReadOnlyProperty() + { + $this->setExpectedException('yii\base\InvalidCallException'); + $this->object->object = 'test'; + } + public function testIsset() { $this->assertTrue(isset($this->object->Text)); @@ -83,6 +89,9 @@ class ObjectTest extends TestCase $this->object->Text = null; $this->assertFalse(isset($this->object->Text)); $this->assertTrue(empty($this->object->Text)); + + $this->assertFalse(isset($this->object->unknownProperty)); + $this->assertTrue(empty($this->object->unknownProperty)); } public function testUnset() @@ -92,6 +101,18 @@ class ObjectTest extends TestCase $this->assertTrue(empty($this->object->Text)); } + public function testUnsetReadOnlyProperty() + { + $this->setExpectedException('yii\base\InvalidCallException'); + unset($this->object->object); + } + + public function testCallUnknownMethod() + { + $this->setExpectedException('yii\base\UnknownMethodException'); + $this->object->unknownMethod(); + } + public function testArrayProperty() { $this->assertEquals(array(), $this->object->items);