]> git.mjollnir.org Git - s9y.git/commitdiff
* backport tests, view entry
authornohn <nohn>
Sun, 5 Nov 2006 08:08:24 +0000 (08:08 +0000)
committernohn <nohn>
Sun, 5 Nov 2006 08:08:24 +0000 (08:08 +0000)
docs/NEWS
include/functions_config.inc.php
tests/gui/README [new file with mode: 0644]
tests/gui/SerendipityTestSuite.php [new file with mode: 0644]
tests/gui/TestConfiguration.php.dist [new file with mode: 0644]

index fc9d72cb0dd1e65f29e35e847d3c5df49223495e..90e6ab2ae75985bd51ec71d23fa950ff08d7ee68 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -10,6 +10,8 @@ Version 1.0.3 ()
      - Fix a problem where spartacus did not properly assign configured
        permissions to downloaded directories, thanks to danilo from
        the forums!
+
+     - "View Article" in "Save Entry" dialog (nohn)
                 
 Version 1.0.2 (October 18th, 2006)
 ------------------------------------------------------------------------
index a644088821a3f76004fa1fe23c1d630977da56fa..7a4de1f380c29fea2bc4364f2cc5cd90f97330ce 100644 (file)
@@ -571,7 +571,9 @@ function serendipity_iframe(&$entry, $mode = null, $use_smarty = true) {
                     // it needs to be stored with the new ID.
                     echo '<script type="text/javascript">parent.document.forms[\'serendipityEntry\'][\'serendipity[id]\'].value = "' . $serendipity['lastSavedEntry'] . '";</script>';
                 }
-                echo '<div class="serendipityAdminMsgSuccess">' . ENTRY_SAVED . '</div>';
+                $entrylink = serendipity_archiveURL($res, $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
+                echo '<div class="serendipityAdminMsgSuccess">' . ENTRY_SAVED . ' (<a href="' . $entrylink . '" target="_blank">' . VIEW . '</a
+>)</div>';
             }
             echo '<br style="clear: both" />';
 
diff --git a/tests/gui/README b/tests/gui/README
new file mode 100644 (file)
index 0000000..6fad8cb
--- /dev/null
@@ -0,0 +1,23 @@
+Test setup instructions
+=======================
+
+0.) Optionally Install VMWare Server
+
+1.) Install Java from http://java.sun.com/
+
+2.) Get Selenium RC from http://www.openqa.org/selenium-rc/download.action
+
+3.) Install PHPUnit:
+    # pear install -f http://pear.phpunit.de/get/PHPUnit-3.0.0beta2.tgz
+
+4.) Install PHP Selenium Bindings: 
+    # pear install -f Testing_Selenium
+
+5.) Copy TestConfiguration.php.dist to TestConfiguration.php and
+    change TestConfiguration.php to reflect your Selenium RC
+    configuration.
+
+6.) Run Tests
+    $ phpunit SeleniumTestSuite.php
+
+-- end of file
diff --git a/tests/gui/SerendipityTestSuite.php b/tests/gui/SerendipityTestSuite.php
new file mode 100644 (file)
index 0000000..c0f4c9c
--- /dev/null
@@ -0,0 +1,221 @@
+<?php
+# Copyright (c) 2006, Sebastian Nohn (on behalf the Serendipity Developer Team)
+# All rights reserved.  See LICENSE file for licensing details
+
+ini_set('display_errors', 1);
+
+require_once 'PHPUnit/Framework/TestCase.php';
+require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
+
+require_once 'TestConfiguration.php';
+
+require_once '../../lang/serendipity_lang_'.S9Y_LANG.'.inc.php';
+require_once '../../plugins/serendipity_event_spamblock/lang_'.S9Y_LANG.'.inc.php';
+
+class SerendipityTestSuite extends PHPUnit_Extensions_SeleniumTestCase
+{
+    public function setUp()
+    {
+        if (!SELENIUM_ENABLED) {
+            $this->markTestSkipped(
+              'The Selenium tests are disabled.'
+            );
+        }
+
+        if (!class_exists('Testing_Selenium')) {
+            $this->markTestSkipped(
+              'The PHP bindings for Selenium RC are not installed.'
+            );
+        }
+
+        $this->setHost(SELENIUM_HOST);
+        $this->setPort(SELENIUM_PORT);
+        $this->setBrowser(SELENIUM_BROWSER);
+        $this->setBrowserUrl(S9Y_INSTALLDIR);
+        $this->setTimeout(10000);
+    }
+
+    public function testExpertInstallation()
+    {
+        $this->open(S9Y_INSTALLDIR);
+        $this->assertTextNotPresent(NOT_WRITABLE);
+        $this->clickAndWait('link='.EXPERT_INSTALLATION);
+        $this->select('dbType', 'SQLite');
+        $this->type('user', 'Test User');
+        $this->type('pass', 'Test Password');
+        $this->check('radio_cfg_want_mail_no');
+        $this->select('rewrite', 'Use Apache mod_rewrite');
+        $this->type('blogTitle', 's9y Testsuite Testblog');
+        $this->type('blogDescription', 'The lalaforce is coming to get you!');
+        $this->clickAndWait("//input[@value='".COMPLETE_INSTALLATION."']");
+        $this->assertTextPresent(SERENDIPITY_INSTALLED);
+    }
+
+    public function testLoginLogout()
+    {
+        $this->open(S9Y_INSTALLDIR);
+
+        $this->assertTitleEquals('s9y Testsuite Testblog');
+        $this->assertTextPresent(SUPERUSER);
+        $this->clickAndWait('link='.SUPERUSER_OPEN_LOGIN);
+
+        $this->assertTextPresent(PLEASE_ENTER_CREDENTIALS);
+        $this->type('serendipity[user]', 'Test User');
+        $this->type('serendipity[pass]', 'Test Password2');
+        $this->clickAndWait('submit');
+
+        $this->assertTextPresent(PLEASE_ENTER_CREDENTIALS);
+        $this->assertTextPresent(WRONG_USERNAME_OR_PASSWORD);
+        $this->type('serendipity[user]', 'Test User');
+        $this->type('serendipity[pass]', 'Test Password');      
+        $this->clickAndWait('submit');
+
+        $this->assertTitleEquals(SERENDIPITY_ADMIN_SUITE);
+        $this->assertTextPresent(WELCOME_BACK.' John Doe');
+        $this->clickAndWait('link='.BACK_TO_BLOG);
+
+        $this->assertTitleEquals('s9y Testsuite Testblog');
+        $this->assertTextPresent(SUPERUSER);
+        $this->clickAndWait('link='.SUPERUSER_OPEN_ADMIN);
+
+        $this->assertTitleEquals(SERENDIPITY_ADMIN_SUITE);
+        $this->assertTextPresent(WELCOME_BACK.' John Doe');
+        $this->clickAndWait('link='.LOGOUT);
+
+        $this->assertTextPresent(PLEASE_ENTER_CREDENTIALS);
+        $this->clickAndWait('link='.BACK_TO_BLOG);
+
+        $this->assertTitleEquals('s9y Testsuite Testblog');
+        $this->assertTextPresent(SUPERUSER);
+        $this->clickAndWait('link='.SUPERUSER_OPEN_LOGIN);
+
+        $this->assertTextPresent(PLEASE_ENTER_CREDENTIALS);
+    }
+
+    public function testCreateContentCategory() {
+        $this->open(S9Y_INSTALLDIR);
+
+        $this->assertTitleEquals('s9y Testsuite Testblog');
+        $this->assertTextPresent(SUPERUSER);
+        $this->clickAndWait('link='.SUPERUSER_OPEN_LOGIN);
+
+        $this->assertTextPresent(PLEASE_ENTER_CREDENTIALS);
+        $this->type('serendipity[user]', 'Test User');
+        $this->type('serendipity[pass]', 'Test Password');
+        $this->clickAndWait('submit');
+
+        $this->assertTitleEquals(SERENDIPITY_ADMIN_SUITE);
+        $this->assertTextPresent(WELCOME_BACK.' John Doe');
+        $this->clickAndWait('link='.CATEGORIES);
+
+        $this->clickAndWait('link='.CREATE_NEW_CAT);
+
+        $this->assertTextPresent(CREATE_NEW_CAT);
+        $this->type('serendipity[cat][name]', 'Test Category 001');
+        $this->type('serendipity[cat][description]', 'This is the description for Test Category 001');
+        $this->clickAndWait('SAVE');
+
+        $this->assertTextPresent('Test Category 001');
+        $this->clickAndWait('link='.CREATE_NEW_CAT);
+
+        $this->assertTextPresent(CREATE_NEW_CAT);
+        $this->type('serendipity[cat][name]', 'Test Category 002');
+        $this->type('serendipity[cat][description]', 'This is the description for Test Category 002');
+        $this->clickAndWait('SAVE');
+
+        $this->assertTextPresent('Test Category 002');
+        $this->clickAndWait('link='.CREATE_NEW_CAT);
+
+        $this->assertTextPresent(CREATE_NEW_CAT);
+        $this->select('parent_cat', 'Test Category 001');
+        $this->type('serendipity[cat][name]', 'Test Category 001-1');
+        $this->type('serendipity[cat][description]', 'This is the description for Test Category 001-1');
+        $this->clickAndWait('SAVE');
+
+        $this->assertTextPresent('Test Category 001-1');
+
+        $this->clickAndWait('link='.CREATE_NEW_CAT);
+
+        $this->assertTextPresent(CREATE_NEW_CAT);
+        $this->select('parent_cat', '&nbsp;Test Category 001-1');
+        $this->type('serendipity[cat][name]', 'Test Category 001-1-1');
+        $this->type('serendipity[cat][description]', 'This is the description for Test Category 001-1-1');
+        $this->clickAndWait('SAVE');
+        $this->assertTextPresent('Test Category 001-1-1');
+    }
+
+    public function testCreateSimpleArticle() {
+        $this->open(S9Y_INSTALLDIR);
+
+        $this->assertTitleEquals('s9y Testsuite Testblog');
+        $this->assertTextPresent(SUPERUSER);
+        $this->clickAndWait('link='.SUPERUSER_OPEN_LOGIN);
+
+        $this->assertTextPresent(PLEASE_ENTER_CREDENTIALS);
+        $this->type('serendipity[user]', 'Test User');
+        $this->type('serendipity[pass]', 'Test Password');
+        $this->clickAndWait('submit');
+
+        $this->assertTitleEquals(SERENDIPITY_ADMIN_SUITE);
+        $this->assertTextPresent(WELCOME_BACK.' John Doe');
+        $this->clickAndWait('link='.NEW_ENTRY);
+        
+        $this->assertTextPresent(ENTRY_BODY);
+        $this->type('entryTitle', 'Test Entry 001');
+        $this->type('serendipity[body]', 'Test Body');
+        $this->clickAndWait("//input[@value='- ".SAVE." -']");
+        
+        $this->assertTextPresent(IFRAME_SAVE);
+        $this->clickAndWait('link='.VIEW);
+
+        $this->assertTitleEquals('Test Entry 001 - s9y Testsuite Testblog');
+        $this->assertTextPresent('Test Body');
+        $this->clickAndWait('link='.EDIT_ENTRY);
+
+        $this->assertTextPresent(ENTRY_BODY);
+        $this->type('serendipity[body]', 'New Test Body');
+        $this->clickAndWait("//input[@value='- ".SAVE." -']");
+
+        $this->assertTextPresent(IFRAME_SAVE);
+        $this->clickAndWait('link='.VIEW);
+
+        $this->assertTitleEquals('Test Entry 001 - s9y Testsuite Testblog');
+        $this->assertTextPresent('New Test Body');
+    }
+
+    public function testComment() {
+        $this->open(S9Y_INSTALLDIR);
+
+        $this->assertTitleEquals('s9y Testsuite Testblog');
+        $this->assertTextPresent('Test Entry 001');
+        $this->clickAndWait('link=Test Entry 001');
+
+        $this->assertTitleEquals('Test Entry 001 - s9y Testsuite Testblog');
+        $this->assertTextPresent('New Test Body');
+        $this->assertTextPresent(ADD_COMMENT);
+        $this->clickAndWait("//input[@value='".SUBMIT_COMMENT."']");
+
+        $this->assertTextPresent(sprintf(EMPTY_COMMENT, '', ''));
+        $this->type('serendipity[name]', 'Test Commenter 001');
+        $this->clickAndWait("//input[@value='".SUBMIT_COMMENT."']");
+
+        $this->assertTextPresent(sprintf(EMPTY_COMMENT, '', ''));
+        $this->type('serendipity[comment]', 'Test Comment 001');
+        $this->clickAndWait("//input[@value='".SUBMIT_COMMENT."']");
+        
+        $this->assertTextPresent(COMMENT_ADDED);
+        $this->assertTextPresent('Test Commenter 001');
+        $this->assertTextPresent('Test Comment 001');
+        $this->clickAndWait('link='.ADMIN_FRONTPAGE);
+
+        $this->clickAndWait('link=Test Entry 001');
+
+        $this->type('serendipity[name]', 'Test Commenter 001');
+        $this->type('serendipity[comment]', 'Test Comment 002');
+        $this->clickAndWait("//input[@value='".SUBMIT_COMMENT."']");
+
+        $this->assertTextPresent(PLUGIN_EVENT_SPAMBLOCK_ERROR_IP);
+    }
+}
+?>
diff --git a/tests/gui/TestConfiguration.php.dist b/tests/gui/TestConfiguration.php.dist
new file mode 100644 (file)
index 0000000..d735732
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+# Copyright (c) 2006, Sebastian Nohn (on behalf the Serendipity Developer Team)
+# All rights reserved.  See LICENSE file for licensing details
+
+define('SELENIUM_ENABLED', TRUE);
+define('SELENIUM_HOST',    '172.16.177.130');
+define('SELENIUM_PORT',    4444);
+define('SELENIUM_BROWSER', '*firefox');
+define('S9Y_INSTALLDIR',   'http://example.com/serendipity/');
+define('S9Y_LANG',         'en');
+?>