Example #1
0
    public function testIsPermalink()
    {
        $Request = new Request();
        $Response = new Response();
        $data = ['channel' => ['title' => 'Channel title'], 'items' => [['guid' => ['url' => 'Testing', '@isPermalink' => 'false']], ['guid' => ['url' => 'Testing', '@isPermalink' => 'true']], ['guid' => ['url' => 'Testing']]]];
        $viewVars = ['channel' => $data, '_serialize' => 'channel'];
        $View = new RssView($Request, $Response, null, ['viewVars' => $viewVars]);
        $result = $View->render(false);
        $expected = <<<RSS
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Channel title</title>
    <link>/</link>
    <description/>
    <item>
      <guid isPermalink="false">Testing</guid>
    </item>
    <item>
      <guid isPermalink="true">/Testing</guid>
    </item>
    <item>
      <guid>/Testing</guid>
    </item>
  </channel>
</rss>

RSS;
        $this->assertTextEquals($expected, $result);
    }
Example #2
0
    /**
     * RssViewTest::testSerializeWithSpecialChars()
     *
     * @return void
     */
    public function testSerializeWithSpecialChars()
    {
        $Request = new Request();
        $Response = new Response();
        $data = ['channel' => ['title' => 'Channel title with äöü umlauts and <!> special chars', 'link' => 'http://channel.example.org'], 'items' => [['title' => 'A <unsafe title', 'link' => ['controller' => 'foo', 'action' => 'bar'], 'description' => 'My content "&" and <other> stuff here should also be escaped safely']]];
        $viewVars = ['channel' => $data, '_serialize' => 'channel'];
        $View = new RssView($Request, $Response, null, ['viewVars' => $viewVars]);
        $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);
    }