From 5e524fbca1b58a9a97da3a2240e01a0673e16c3b Mon Sep 17 00:00:00 2001 From: Sebastian Nohn <nohn@users.sourceforge.net> Date: Sat, 28 Oct 2006 16:13:20 +0000 Subject: [PATCH] * introduce basic tests --- tests/gui/README | 21 ++++ tests/gui/SerendipityTestSuite.php | 147 +++++++++++++++++++++++++++ tests/gui/TestConfiguration.php.dist | 10 ++ 3 files changed, 178 insertions(+) create mode 100644 tests/gui/README create mode 100644 tests/gui/SerendipityTestSuite.php create mode 100644 tests/gui/TestConfiguration.php.dist diff --git a/tests/gui/README b/tests/gui/README new file mode 100644 index 00000000..f6687cbc --- /dev/null +++ b/tests/gui/README @@ -0,0 +1,21 @@ +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.) Change TestConfiguration.php to reflect your 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 index 00000000..bf51a66f --- /dev/null +++ b/tests/gui/SerendipityTestSuite.php @@ -0,0 +1,147 @@ +<?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'; + +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 has been successfully installed'); + } + + public function testLoginLogout() + { + $this->open(S9Y_INSTALLDIR); + + $this->assertTitleEquals('s9y Testsuite Testblog'); + $this->assertTextPresent('Blog Administration'); + $this->clickAndWait('link=Open login screen'); + + $this->assertTextPresent('Please enter your credentials below'); + $this->type('serendipity[user]', 'Test User'); + $this->type('serendipity[pass]', 'Test Password2'); + $this->clickAndWait('submit'); + + $this->assertTextPresent('Please enter your credentials below'); + $this->assertTextPresent('You appear to have entered an invalid username or password'); + $this->type('serendipity[user]', 'Test User'); + $this->type('serendipity[pass]', 'Test Password'); + $this->clickAndWait('submit'); + + $this->assertTitleEquals('Serendipity Administration Suite'); + $this->assertTextPresent('Welcome back, John Doe'); + $this->clickAndWait('link=Back to Weblog'); + + $this->assertTitleEquals('s9y Testsuite Testblog'); + $this->assertTextPresent('Blog Administration'); + $this->clickAndWait('link=Open administration'); + + $this->assertTitleEquals('Serendipity Administration Suite'); + $this->assertTextPresent('Welcome back, John Doe'); + $this->clickAndWait('link=Logout'); + + $this->assertTextPresent('Please enter your credentials below'); + $this->clickAndWait('link=Back to Weblog'); + + $this->assertTitleEquals('s9y Testsuite Testblog'); + $this->assertTextPresent('Blog Administration'); + $this->clickAndWait('link=Open login screen'); + + $this->assertTextPresent('Please enter your credentials below'); + } + + public function testCreateContentCategory() { + $this->open(S9Y_INSTALLDIR); + + $this->assertTitleEquals('s9y Testsuite Testblog'); + $this->assertTextPresent('Blog Administration'); + $this->clickAndWait('link=Open login screen'); + + $this->assertTextPresent('Please enter your credentials below'); + $this->type('serendipity[user]', 'Test User'); + $this->type('serendipity[pass]', 'Test Password'); + $this->clickAndWait('submit'); + + $this->assertTitleEquals('Serendipity Administration Suite'); + $this->assertTextPresent('Welcome back, John Doe'); + $this->clickAndWait('link=Categories'); + + $this->clickAndWait('link=Create New Category'); + + $this->assertTextPresent('Create New Category'); + $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 Category'); + + $this->assertTextPresent('Create New Category'); + $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 Category'); + + $this->assertTextPresent('Create New Category'); + $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'); + +# The Sub-Sub-Category-Test is blocked by http://pear.php.net/bugs/bug.php?id=9189 +# +# $this->clickAndWait('link=Create New Category'); +# +# $this->assertTextPresent('Create New Category'); +# $this->select('parent_cat', ' 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'); + } +} +?> diff --git a/tests/gui/TestConfiguration.php.dist b/tests/gui/TestConfiguration.php.dist new file mode 100644 index 00000000..f8dfaae1 --- /dev/null +++ b/tests/gui/TestConfiguration.php.dist @@ -0,0 +1,10 @@ +<?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/'); +?>