channelInterface); $feed = new Feed(); $this->assertSame($feed, $feed->addChannel($channel)); $this->assertAttributeSame([$channel], 'channels', $feed); } public function testRender() { $feed = new Feed(); $xml1 = new SimpleXMLElement('channel1'); $xml2 = new SimpleXMLElement('channel2'); $xml3 = new SimpleXMLElement('channel3'); $channel1 = $this->getMock($this->channelInterface); $channel1->expects($this->once())->method('asXML')->will($this->returnValue($xml1)); $channel2 = $this->getMock($this->channelInterface); $channel2->expects($this->once())->method('asXML')->will($this->returnValue($xml2)); $channel3 = $this->getMock($this->channelInterface); $channel3->expects($this->once())->method('asXML')->will($this->returnValue($xml3)); $this->reveal($feed)->attr('channels', [$channel1, $channel2, $channel3]); $expect = ' channel1 channel2 channel3 '; $this->assertXmlStringEqualsXmlString($expect, $feed->render()); } public function testRender_with_japanese() { $feed = new Feed(); $xml1 = new SimpleXMLElement('日本語1'); $xml2 = new SimpleXMLElement('日本語2'); $xml3 = new SimpleXMLElement('日本語3'); $channel1 = $this->getMock($this->channelInterface); $channel1->expects($this->once())->method('asXML')->will($this->returnValue($xml1)); $channel2 = $this->getMock($this->channelInterface); $channel2->expects($this->once())->method('asXML')->will($this->returnValue($xml2)); $channel3 = $this->getMock($this->channelInterface); $channel3->expects($this->once())->method('asXML')->will($this->returnValue($xml3)); $this->reveal($feed)->attr('channels', [$channel1, $channel2, $channel3]); $expect = <<< 'XML' 日本語1 日本語2 日本語3 XML; $this->assertSame($expect, $feed->render()); } public function test__toString() { $feed = new Feed(); $xml1 = new SimpleXMLElement('channel1'); $xml2 = new SimpleXMLElement('channel2'); $xml3 = new SimpleXMLElement('channel3'); $channel1 = $this->getMock($this->channelInterface); $channel1->expects($this->once())->method('asXML')->will($this->returnValue($xml1)); $channel2 = $this->getMock($this->channelInterface); $channel2->expects($this->once())->method('asXML')->will($this->returnValue($xml2)); $channel3 = $this->getMock($this->channelInterface); $channel3->expects($this->once())->method('asXML')->will($this->returnValue($xml3)); $this->reveal($feed)->attr('channels', [$channel1, $channel2, $channel3]); $expect = ' channel1 channel2 channel3 '; $this->assertXmlStringEqualsXmlString($expect, strval($feed)); } }