aboutsummaryrefslogtreecommitdiff
path: root/tests/www/indexTest.php
blob: 18cb75ab662b66e0edc28f86e010de56adbf6990 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
require_once dirname(__FILE__) . '/../prepare.php';
require_once 'HTTP/Request2.php';

class www_indexTest extends TestBaseApi
{
    protected $urlPart = '';

    /**
     * Test that the private rss feed exists when user is setup
     * with a private key and is enabled
     */
    public function testVerifyPrivateRSSLinkExists()
    {
        list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true, true);

        $user = $this->us->getUser($uId);
        $response = $req->send();
        $response_body = $response->getBody();

        $this->assertNotEquals('', $response_body, 'Response is empty');

        $x = simplexml_load_string($response_body);
        $ns = $x->getDocNamespaces();
        $x->registerXPathNamespace('ns', reset($ns));

        $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]');
        $this->assertEquals(2, count($elements), 'Number of Links in Head not correct');
        $this->assertContains('privatekey=', (string)$elements[1]['href']);
    }//end testVerifyPrivateRSSLinkExists



    /**
     * Test that the private RSS link doesn't exists when a user
     * does not have a private key, or the private key is not enabled
     */
    public function testVerifyPrivateRSSLinkDoesNotExist()
    {
        list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true);

        $user = $this->us->getUser($uId);
        $response = $req->send();
        $response_body = $response->getBody();
        $this->assertNotEquals('', $response_body, 'Response is empty');

        $x = simplexml_load_string($response_body);
        $ns = $x->getDocNamespaces();
        $x->registerXPathNamespace('ns', reset($ns));

        $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]');
        $this->assertEquals(1, count($elements), 'Number of Links in Head not correct');
        $this->assertNotContains('privatekey=', (string)$elements[0]['href']);
    }//end testVerifyPrivateRSSLinkDoesNotExist


}//end class www_bookmarksTest
?>