Exemplo n.º 1
0
    /**
     * RssViewTest::testSerializeWithSpecialChars()
     *
     * @return void
     */
    public function testSerializeWithSpecialChars()
    {
        $Request = new CakeRequest();
        $Response = new CakeResponse();
        $Controller = new Controller($Request, $Response);
        $data = array('channel' => array('title' => 'Channel title with äöü umlauts and <!> special chars', 'link' => 'http://channel.example.org'), 'items' => array(array('title' => 'A <unsafe title', 'link' => array('controller' => 'foo', 'action' => 'bar'), 'description' => 'My content "&" and <other> stuff here should also be escaped safely')));
        $Controller->set(array('channel' => $data, '_serialize' => 'channel'));
        $View = new RssView($Controller);
        $result = $View->render(false);
        $expected = <<<RSS
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Channel title with äöü umlauts and &lt;!&gt; special chars</title>
    <link>http://channel.example.org</link>
    <description/>
    <item>
      <title>A &lt;unsafe title</title>
      <link>{$this->baseUrl}/foo/bar</link>
      <description>My content "&amp;" and &lt;other&gt; stuff here should also be escaped safely</description>
    </item>
  </channel>
</rss>

RSS;
        $this->assertTextEquals($expected, $result);
    }