/** * Tests getting child by name * @covers \Copycat\Structure\SimpleXmlElement::getChild() */ public function testGetChild() { $element = new SimpleXmlElement('<Test></Test>'); $element->addChild('foo', 'bar'); $this->assertInstanceOf('\\Copycat\\Structure\\SimpleXmlElement', $element->getChild('foo')); $this->assertEquals('bar', $element->getChild('foo')); try { $caught = false; $element->getChild('bar'); } catch (Exception $exception) { $caught = true; $this->assertEquals('There is no bar', $exception->getMessage()); } if (!$caught) { $this->fail('Exception was not caught'); } }