assertSame(null, $decorator->foo); } public function testDecoratorReturnsNullWhenPropertyIsMissing() { $object = new stdclass(); $decorator = new Zend_Service_StrikeIron_Decorator($object); $this->assertSame(null, $decorator->foo); } public function testDecoratorReturnsPropertyByItsName() { $object = (object)array('Foo' => 'bar', 'Baz' => 'qux'); $decorator = new Zend_Service_StrikeIron_Decorator($object); $this->assertEquals('qux', $decorator->Baz); } public function testDecoratorReturnsPropertyByInflectedName() { $object = (object)array('Foo' => 'bar', 'Baz' => 'qux'); $decorator = new Zend_Service_StrikeIron_Decorator($object); $this->assertEquals('qux', $decorator->baz); } public function testDecoratorTriesActualPropertyNameBeforeInflecting() { $object = (object)array('foo' => 'bar', 'Foo' => 'qux'); $decorator = new Zend_Service_StrikeIron_Decorator($object); $this->assertEquals('bar', $decorator->foo); } public function testDecoratorReturnsAnotherDecoratorWhenValueIsAnObject() { $object = (object)array('Foo' => new stdclass); $decorator = new Zend_Service_StrikeIron_Decorator($object); $class = get_class($decorator); $this->assertTrue($decorator->Foo instanceof $class); } public function testDecoratorProxiesMethodCalls() { $decorator = new Zend_Service_StrikeIron_Decorator($this); $this->assertEquals('bar', $decorator->foo()); } public function foo() { return 'bar'; } public function testGettingTheDecoratedObject() { $decorator = new Zend_Service_StrikeIron_Decorator($this); $this->assertSame($this, $decorator->getDecoratedObject()); } public function testGettingDecoratedObjectName() { $decorator = new Zend_Service_StrikeIron_Decorator($this, 'foo'); $this->assertSame('foo', $decorator->getDecoratedObjectName()); } }