diff options
| author | Mark Pemberton <mpemberton5@gmail.com> | 2011-06-04 00:29:04 -0400 | 
|---|---|---|
| committer | Mark Pemberton <mpemberton5@gmail.com> | 2011-06-04 00:29:04 -0400 | 
| commit | 84e603aa91a303a1419962ff3ff6086710a7b1a9 (patch) | |
| tree | 5d706948d6b28ed8323ebf1c864726c2d7d4eccf /tests | |
| parent | 342d1c3205c2f2ae9d918f66e28e8ffa153c2854 (diff) | |
| download | semanticscuttle-84e603aa91a303a1419962ff3ff6086710a7b1a9.tar.gz semanticscuttle-84e603aa91a303a1419962ff3ff6086710a7b1a9.tar.bz2 | |
Reverted changes of date() to gdate(), added tests to confirm existence of private RSS feed, and finalized changes to the user session usage with rss.php
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Api/PostsAddTest.php | 4 | ||||
| -rw-r--r-- | tests/TestBaseApi.php | 21 | ||||
| -rwxr-xr-x | tests/www/bookmarksTest.php | 27 | 
3 files changed, 43 insertions, 9 deletions
| diff --git a/tests/Api/PostsAddTest.php b/tests/Api/PostsAddTest.php index 2613a87..e6d0531 100644 --- a/tests/Api/PostsAddTest.php +++ b/tests/Api/PostsAddTest.php @@ -111,7 +111,7 @@ TXT;          $this->assertEquals($bmDescription, stripslashes($bm['bDescription']));          $this->assertEquals($bmTags, $bm['tags']);          $this->assertEquals( -            date('Y-m-d H:i:s', strtotime($bmDatetime)), +            gmdate('Y-m-d H:i:s', strtotime($bmDatetime)),              $bm['bDatetime']          );      } @@ -173,7 +173,7 @@ TXT;          $this->assertEquals($bmDescription, stripslashes($bm['bDescription']));          $this->assertEquals($bmTags, $bm['tags']);          $this->assertEquals( -            date('Y-m-d H:i:s', strtotime($bmDatetime)), +            gmdate('Y-m-d H:i:s', strtotime($bmDatetime)),              $bm['bDatetime']          );      } diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php index 20574f3..d8917aa 100644 --- a/tests/TestBaseApi.php +++ b/tests/TestBaseApi.php @@ -164,15 +164,16 @@ class TestBaseApi extends TestBase       *       * Useful for testing HTML pages or ajax URLs.       * -     * @param string $urlSuffix Suffix for the URL -     * @param mixed  $auth      If user authentication is needed (true/false) -     *                          or array with username and password +     * @param string  $urlSuffix Suffix for the URL +     * @param mixed   $auth      If user authentication is needed (true/false) +     *                           or array with username and password +     * @param boolean $privateKey True if to add user with private key       *       * @return array(HTTP_Request2, integer) HTTP request object and user id       *       * @uses getRequest()       */ -    protected function getLoggedInRequest($urlSuffix = null, $auth = true) +    protected function getLoggedInRequest($urlSuffix = null, $auth = true, $privateKey = false)      {          if (is_array($auth)) {              list($username, $password) = $auth; @@ -180,7 +181,13 @@ class TestBaseApi extends TestBase              $username = 'testuser';              $password = 'testpassword';          } -        $uid = $this->addUser($username, $password); +        //include privatekey if requested +        if ($privateKey) { +            $pKey = $this->us->getNewPrivateKey(); +        } else { +            $pKey = null; +        } +        $uid = $this->addUser($username, $password, $pKey);          $req = new HTTP_Request2(              $GLOBALS['unittestUrl'] . '/login.php?unittestMode=1', @@ -234,7 +241,7 @@ class TestBaseApi extends TestBase       */      protected function setUnittestConfig($arConfig)      { -        $str = '<' . "?php\r\n"; +        $str = '<' . "?php\n";          foreach ($arConfig as $name => $value) {              $str .= '$' . $name . ' = '                  . var_export($value, true) . ";\n"; @@ -253,4 +260,4 @@ class TestBaseApi extends TestBase          );      }  } -?>
\ No newline at end of file +?> diff --git a/tests/www/bookmarksTest.php b/tests/www/bookmarksTest.php index df360cc..eaf78bf 100755 --- a/tests/www/bookmarksTest.php +++ b/tests/www/bookmarksTest.php @@ -76,5 +76,32 @@ class www_bookmarksTest extends TestBaseApi          $this->assertEquals(1, (string)$elements[0]['value']);      }//end testDefaultPrivacyBookmarksAdd + +    /** +     * Test that the private RSS link exists when a user +     * has a private key and is enabled +     */ +    public function testVerifyPrivateRSSLinkExists() +    { +        list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true, true); + +        $user = $this->us->getUser($uId); +        $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' +            . $user['username']; +        $req->setUrl($reqUrl); +        $req->setMethod(HTTP_Request2::METHOD_GET); +        $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'); +        $this->assertEquals(5, count($elements), 'Number of Links in Head not correct'); +        $this->assertContains('privatekey=', (string)$elements[4]['href']); +    }//end testVerifyPrivateRSSLinkExists +  }//end class www_bookmarksTest  ?> | 
