]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
merge master
authorChristian Weiske <cweiske@cweiske.de>
Mon, 2 May 2011 16:07:15 +0000 (18:07 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 2 May 2011 16:07:15 +0000 (18:07 +0200)
1  2 
.gitignore
data/config.default.php
src/SemanticScuttle/header.php
tests/Api/PostsAddTest.php
tests/TestBaseApi.php
www/bookmarks.php

diff --cc .gitignore
index 6f6d812141b0ca4df23032d9a42e8f319212d8c3,d84d93dbc86fb930b6359eca258d6f6b19fefef5..69eff7d9a2720b841c4bc847e29bdd35c9450ae5
@@@ -1,4 -1,4 +1,5 @@@
  dist/
  build.properties
  package.xml
+ semanticscuttle-dump.sql
 +data/config.unittest.php
Simple merge
Simple merge
index 3c1177f3333d096980499cf6774e6ee1e92e6f29,53aa8e7f17ebb3712181e5940da1907168a13489..24cc600eb19d9e36c4a44f8af5170c54cf355c6d
@@@ -420,213 -406,5 +406,209 @@@ TXT
          $this->assertEquals(1, $data['total']);
          $this->assertEquals($title2, $data['bookmarks'][0]['bTitle']);
      }
 +
 +
 +    /**
 +     * Test that a default privacy setting of 2 (Private) is used in adding
 +     * a bookmark.
 +     */
 +    public function testDefaultPrivacyPrivate()
 +    {
 +        $this->setUnittestConfig(
 +            array('defaults' => array('privacy' => 2))
 +        );
 +        list($req, $uId) = $this->getAuthRequest('?unittestMode=1');
 +        $req->setMethod(HTTP_Request2::METHOD_POST);
 +        $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_addprivate');
 +        $req->addPostParameter('description', 'Test bookmark 1 for default privacy.');
 +        $req->send();
 +        $this->us->setCurrentUserId($uId);
 +        $bms = $this->bs->getBookmarks(0, null, $uId);
 +        $this->assertEquals(1, count($bms['bookmarks']));
 +        $bm = reset($bms['bookmarks']);
 +        $this->assertEquals('2', $bm['bStatus']);
 +    }//end testDefaultPrivacyPrivate
 +
 +
 +    /**
 +     * Test that a default privacy setting of 0 (Public) is used in adding
 +     * a bookmark.
 +     */
 +    public function testDefaultPrivacyPublic()
 +    {
 +        $this->setUnittestConfig(
 +            array('defaults' => array('privacy' => 0))
 +        );
 +        list($req, $uId) = $this->getAuthRequest('?unittestMode=1');
 +        $req->setMethod(HTTP_Request2::METHOD_POST);
 +        $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_addpublic');
 +        $req->addPostParameter('description', 'Test bookmark 1 for default privacy.');
 +        $req->send();
 +        $this->us->setCurrentUserId($uId);
 +        $bms = $this->bs->getBookmarks(0, null, $uId);
 +        $this->assertEquals(1, count($bms['bookmarks']));
 +        $bm = reset($bms['bookmarks']);
 +        $this->assertEquals('0', $bm['bStatus']);
 +    }//end testDefaultPrivacyPublic
 +
 +
 +    /**
 +     * Test that the default privacy setting is used when an existing
 +     * bookmark is updated with edit.php.
 +     */
 +    public function testDefaultPrivacyEdit()
 +    {
 +        $this->setUnittestConfig(
 +            array('defaults' => array('privacy' => 2))
 +        );
 +
 +        list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1');
 +        $cookies = $req->getCookieJar();
 +        $req->setMethod(HTTP_Request2::METHOD_POST);
 +        $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_edit');
 +        $req->addPostParameter('description', 'Test bookmark 2 for default privacy.');
 +        $req->addPostParameter('status', '0');
 +        $res = $req->send();
 +        $this->assertEquals(
 +            200, $res->getStatus(),
 +            'Adding bookmark failed: ' . $res->getBody());
 +        $bms = $this->bs->getBookmarks(0, null, $uId);
 +        $bm  = reset($bms['bookmarks']);
 +        $bmId = $bm['bId'];
 +
 +        $reqUrl = $GLOBALS['unittestUrl'] . 'edit.php/' . $bmId . '?unittestMode=1';
 +        $req2 = new HTTP_Request2($reqUrl, HTTP_Request2::METHOD_POST);
 +        $req2->setCookieJar($cookies);
 +        $req2->addPostParameter('address', 'http://www.example.org/testdefaultprivacyposts_edit');
 +        $req2->addPostParameter('title', 'Test bookmark 2 for default privacy.');
 +        $req2->addPostParameter('submitted', '1');
 +        $res = $req2->send();
 +
 +        $this->assertEquals(302, $res->getStatus(), 'Editing bookmark failed');
 +
 +        $bm = $this->bs->getBookmark($bmId);
 +        $this->assertEquals('2', $bm['bStatus']);
 +    }//end testDefaultPrivacyEdit
 +
 +
 +    /**
 +     * Test that the default privacy setting is used when bookmarks
 +     * are imported from an HTML bookmarks file using importNetscape.php.
 +     */
 +    public function testDefaultPrivacyImportNetscape()
 +    {
 +        $this->setUnittestConfig(
 +            array('defaults' => array('privacy' => 1))
 +        );
 +        list($req, $uId) = $this->getLoggedInRequest();
 +        $req->setMethod(HTTP_Request2::METHOD_POST);
 +        $req->setUrl($GLOBALS['unittestUrl'] . 'importNetscape.php' . '?unittestMode=1');
 +        $req->addUpload('userfile', dirname(__FILE__) . '/../data/BookmarkTest_netscapebookmarks.html');
 +        $res = $req->send();
 +        $this->assertEquals(200, $res->getStatus(), 'Bookmark import failed');
 +
 +        $this->us->setCurrentUserId($uId);
 +        $bms = $this->bs->getBookmarks(0, null, $uId);
 +        $this->assertEquals(3, count($bms['bookmarks']));
 +        $bm = reset($bms['bookmarks']);
 +        $this->assertEquals('1', $bm['bStatus']);
 +    }//end testDefaultPrivacyImportNetscape
 +
 +
 +    /**
 +     * Test that the default privacy setting is used when bookmarks
 +     * are imported from an XML bookmarks file using import.php.
 +     */
 +    public function testDefaultPrivacyImport()
 +    {
 +        $this->setUnittestConfig(
 +            array('defaults' => array('privacy' => 2))
 +        );
 +        list($req, $uId) = $this->getLoggedInRequest();
 +        $req->setMethod(HTTP_Request2::METHOD_POST);
 +        $req->setUrl($GLOBALS['unittestUrl'] . 'import.php' . '?unittestMode=1');
 +        $req->addUpload('userfile', dirname(__FILE__) . '/../data/BookmarkTest_deliciousbookmarks.xml');
 +        $res = $req->send();
 +        $this->assertEquals(302, $res->getStatus(), 'Bookmark import failed');
 +
 +        $this->us->setCurrentUserId($uId);
 +        $bms = $this->bs->getBookmarks(0, null, $uId);
 +        $this->assertEquals(3, count($bms['bookmarks']));
 +        $bm = reset($bms['bookmarks']);
 +        $this->assertEquals('2', $bm['bStatus']);
 +    }//end testDefaultPrivacyImport
 +
 +
 +    /**
 +     * Test that the default privacy setting is selected in the Privacy
 +     * drop-down list when adding a new bookmark, sending the form and
 +     * missing the title and the privacy setting.
 +     */
 +    public function testDefaultPrivacyBookmarksAddMissingTitleMissingPrivacy()
 +    {
 +        $this->setUnittestConfig(
 +            array('defaults' => array('privacy' => 2))
 +        );
 +        list($req, $uId) = $this->getLoggedInRequest();
 +        $cookies = $req->getCookieJar();
 +        $req->setMethod(HTTP_Request2::METHOD_POST);
 +        $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_bookmarksget');
 +        $req->addPostParameter('description', 'Test bookmark 1 for default privacy.');
 +        $req->addPostParameter('status', '0');
 +        $req->send();
 +
 +        $bms = $this->bs->getBookmarks(0, null, $uId);
 +        $this->assertEquals(1, count($bms['bookmarks']));
 +        $user = $this->us->getUser($uId);
 +        $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' . $user['username'] . '?action=get' . '&unittestMode=1';
 +
 +        list($req, $uId) = $this->getAuthRequest('?unittestMode=1');
 +        $req->setMethod(HTTP_Request2::METHOD_POST);
 +        $req->setUrl($reqUrl);
 +        $req->setCookieJar($cookies);
 +        $req->addPostParameter('submitted', '1');
 +        $response = $req->send();
 +        $response_body = $response->getBody();
 +
 +        $x = simplexml_load_string($response_body);
 +        $ns = $x->getDocNamespaces();
 +        $x->registerXPathNamespace('ns', reset($ns));
 +
 +        $elements = $x->xpath('//ns:select[@name="status"]/ns:option[@selected="selected"]');
 +        $this->assertEquals(1, count($elements), 'No selected status option found');
 +        $this->assertEquals(2, (string)$elements[0]['value']);
 +    }//end testDefaultPrivacyBookmarksGet
 +
 +
 +    /**
 +     * Test that the default privacy setting is selected in the Privacy
 +     * drop-down list when a new bookmark is being created.
 +     */
 +    public function testDefaultPrivacyBookmarksAdd()
 +    {
 +        $this->setUnittestConfig(
 +            array('defaults' => array('privacy' => 1))
 +        );
 +        list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1');
 +
 +        $user = $this->us->getUser($uId);
 +        $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/'
 +            . $user['username'] . '?action=add' . '&unittestMode=1';
 +        $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:select[@name="status"]/ns:option[@selected="selected"]');
 +        $this->assertEquals(1, count($elements), 'No selected status option found');
 +        $this->assertEquals(1, (string)$elements[0]['value']);
 +    }//end testDefaultPrivacyBookmarksAdd
 +
 +
  }
- if (PHPUnit_MAIN_METHOD == 'Api_PostsAddTest::main') {
-     Api_PostsAddTest::main();
- }
 -?>
 +?>
Simple merge
index d4fe051f15205055185e4bab7c90002870f8713d,3b1d50afa759f882ed1b09ea4f688dc5d8f4e04e..309200497de7b87dd3d8790628c976e534e3cd64
@@@ -184,10 -187,10 +187,10 @@@ if ($templatename == 'editbookmark.tpl'
                  'bAddress' => stripslashes(POST_ADDRESS),
                  'bDescription' => stripslashes(POST_DESCRIPTION),
                            'bPrivateNote' => stripslashes(POST_PRIVATENOTE),
-                 'tags' => (POST_TAGS ? explode(',', stripslashes(POST_TAGS)) : array()),
+                 'tags' => ($_POST['tags'] ? $_POST['tags'] : array()),
 -                              'bStatus' => 0,
 +                              'bStatus' => $GLOBALS['defaults']['privacy'],
                        );
-                       $tplVars['tags'] = POST_TAGS;
+                       $tplVars['tags'] = $_POST['tags'];
                } else {
                        if(GET_COPYOF != '') {  //copy from bookmarks page
                                $tplVars['row'] = $bookmarkservice->getBookmark(intval(GET_COPYOF), true);