summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests
diff options
context:
space:
mode:
authorxue <>2007-09-11 02:09:27 +0000
committerxue <>2007-09-11 02:09:27 +0000
commit269c9a0010c2495db961c185e83fd52b33b04d73 (patch)
treea17692a7e974b103ca679606051b20472e9129e1 /tests/FunctionalTests
parentf5fa9b2249423f89f76b24a21d3014234b7f60f6 (diff)
Fixed #692, #700.
Diffstat (limited to 'tests/FunctionalTests')
-rw-r--r--tests/FunctionalTests/tickets/index700.php8
-rw-r--r--tests/FunctionalTests/tickets/protected700/application.xml32
-rw-r--r--tests/FunctionalTests/tickets/protected700/common/BasePage.php68
-rw-r--r--tests/FunctionalTests/tickets/protected700/layout/MainLayout.php12
-rw-r--r--tests/FunctionalTests/tickets/protected700/layout/MainLayout.tpl26
-rw-r--r--tests/FunctionalTests/tickets/protected700/pages/Home.page14
-rw-r--r--tests/FunctionalTests/tickets/protected700/pages/UserLogin.page28
-rw-r--r--tests/FunctionalTests/tickets/protected700/pages/UserLogin.php13
-rw-r--r--tests/FunctionalTests/tickets/protected700/pages/admin/Home.page14
-rw-r--r--tests/FunctionalTests/tickets/protected700/pages/admin/Home2.page14
-rw-r--r--tests/FunctionalTests/tickets/protected700/pages/admin/config.xml11
-rw-r--r--tests/FunctionalTests/tickets/protected700/pages/admin/users/Home.page14
-rw-r--r--tests/FunctionalTests/tickets/protected700/pages/admin/users/Home2.page14
-rw-r--r--tests/FunctionalTests/tickets/protected700/pages/admin/users/config.xml6
-rw-r--r--tests/FunctionalTests/tickets/protected700/pages/config.xml10
-rw-r--r--tests/FunctionalTests/tickets/protected700/pages/content/Home.page14
-rw-r--r--tests/FunctionalTests/tickets/tests/Ticket700TestCase.php72
17 files changed, 370 insertions, 0 deletions
diff --git a/tests/FunctionalTests/tickets/index700.php b/tests/FunctionalTests/tickets/index700.php
new file mode 100644
index 00000000..d35f789f
--- /dev/null
+++ b/tests/FunctionalTests/tickets/index700.php
@@ -0,0 +1,8 @@
+<?php
+
+require_once(dirname(__FILE__).'/../../../framework/prado.php');
+
+$app=new TApplication('protected700/application.xml');
+$app->run();
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/application.xml b/tests/FunctionalTests/tickets/protected700/application.xml
new file mode 100644
index 00000000..cb00aae3
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/application.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<application id="Ticket700Tests" Mode="Debug">
+<paths>
+ <using namespace="Application.common.*" />
+</paths>
+
+<services>
+ <service id="page" class="TPageService" BasePageClass="Application.common.BasePage">
+ <modules>
+ <module id="users" class="System.Security.TUserManager" PasswordMode="Clear">
+ <user name="AdminUser" password="demo" />
+ <user name="NormalUser" password="demo" />
+ <role name="admin" users="AdminUser" />
+ <role name="user" users="NormalUser" />
+ </module>
+ <module id="auth" class="System.Security.TAuthManager" UserManager="users" LoginPage="UserLogin" />
+ </modules>
+
+ <authorization>
+ <allow pages="Home" users="*" />
+ <deny pages="admin.*" users="?" />
+ <deny pages="content.*" users="*" />
+ <allow users="*" />
+ </authorization>
+
+ <pages MasterClass="Application.layout.MainLayout" Param1="Set at app config" Param5="Set at app config">
+ <page id="Home" Param2="Set at app config" />
+ <page id="admin.Home" Param3="Set at app config" Param4="Set at app config" />
+ </pages>
+ </service>
+</services>
+</application>
diff --git a/tests/FunctionalTests/tickets/protected700/common/BasePage.php b/tests/FunctionalTests/tickets/protected700/common/BasePage.php
new file mode 100644
index 00000000..1e40f754
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/common/BasePage.php
@@ -0,0 +1,68 @@
+<?php
+
+class BasePage extends TPage
+{
+ private $_param1='default 1';
+ private $_param2='default 2';
+ private $_param3='default 3';
+ private $_param4='default 4';
+ private $_param5='default 5';
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ $this->Title=$this->PagePath;
+ }
+
+ public function getParam1()
+ {
+ return $this->_param1;
+ }
+
+ public function setParam1($value)
+ {
+ $this->_param1=$value;
+ }
+
+ public function getParam2()
+ {
+ return $this->_param2;
+ }
+
+ public function setParam2($value)
+ {
+ $this->_param2=$value;
+ }
+
+ public function getParam3()
+ {
+ return $this->_param3;
+ }
+
+ public function setParam3($value)
+ {
+ $this->_param3=$value;
+ }
+
+ public function getParam4()
+ {
+ return $this->_param4;
+ }
+
+ public function setParam4($value)
+ {
+ $this->_param4=$value;
+ }
+
+ public function getParam5()
+ {
+ return $this->_param5;
+ }
+
+ public function setParam5($value)
+ {
+ $this->_param5=$value;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/layout/MainLayout.php b/tests/FunctionalTests/tickets/protected700/layout/MainLayout.php
new file mode 100644
index 00000000..3e0a3d19
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/layout/MainLayout.php
@@ -0,0 +1,12 @@
+<?php
+
+class MainLayout extends TTemplateControl
+{
+ public function logout($sender,$param)
+ {
+ $this->Application->getModule('auth')->logout();
+ $this->Response->reload();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/layout/MainLayout.tpl b/tests/FunctionalTests/tickets/protected700/layout/MainLayout.tpl
new file mode 100644
index 00000000..acbfa0e6
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/layout/MainLayout.tpl
@@ -0,0 +1,26 @@
+<html>
+<com:THead />
+<body>
+
+<com:TForm>
+
+<h1><%= $this->Page->Title %></h1>
+
+<com:TContentPlaceHolder ID="Main" />
+
+<hr/>
+<ul>
+<li><a id="pageHome" href="<%=$this->Service->constructUrl('Home')%>">Home</a></li>
+<li><a id="pageAdminHome" href="<%=$this->Service->constructUrl('admin.Home')%>">admin.Home</a></li>
+<li><a id="pageAdminHome2" href="<%=$this->Service->constructUrl('admin.Home2')%>">admin.Home2</a></li>
+<li><a id="pageAdminUsersHome" href="<%=$this->Service->constructUrl('admin.users.Home')%>">admin.users.Home</a></li>
+<li><a id="pageAdminUsersHome2" href="<%=$this->Service->constructUrl('admin.users.Home2')%>">admin.users.Home2</a></li>
+<li><a id="pageContentHome" href="<%=$this->Service->constructUrl('content.Home')%>">content.Home</a></li>
+</ul>
+<hr/>
+<a href="<%=$this->Service->constructUrl('UserLogin')%>">Login</a> |
+<com:TLinkButton ID="Logout" Text="Logout" OnClick="logout" /> (<%= $this->User->Name %>)
+</com:TForm>
+
+</body>
+</html> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/pages/Home.page b/tests/FunctionalTests/tickets/protected700/pages/Home.page
new file mode 100644
index 00000000..7d1c1187
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/pages/Home.page
@@ -0,0 +1,14 @@
+<com:TContent ID="Main">
+
+|Param1: <%= $this->Param1 %>|
+<br/>
+|Param2: <%= $this->Param2 %>|
+<br/>
+|Param3: <%= $this->Param3 %>|
+<br/>
+|Param4: <%= $this->Param4 %>|
+<br/>
+|Param5: <%= $this->Param5 %>|
+<br/>
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/pages/UserLogin.page b/tests/FunctionalTests/tickets/protected700/pages/UserLogin.page
new file mode 100644
index 00000000..07d4ece9
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/pages/UserLogin.page
@@ -0,0 +1,28 @@
+<com:TContent ID="Main" >
+
+ <com:TLabel
+ ForControl="Username"
+ Text="User Name"
+ CssClass="label"/>
+ <com:TTextBox ID="Username"
+ AccessKey="u"
+ ValidationGroup="login"
+ CssClass="textbox"/>
+<br/>
+ <com:TLabel
+ ForControl="Password"
+ Text="Password"
+ CssClass="label"/>
+ <com:TTextBox ID="Password"
+ AccessKey="p"
+ CssClass="textbox"
+ ValidationGroup="login"
+ TextMode="Password"/>
+<br/>
+ <com:TButton ID="LoginButton"
+ OnClick="loginButtonClicked"
+ Text="Login"
+ ValidationGroup="login"
+ CssClass="button"/>
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/pages/UserLogin.php b/tests/FunctionalTests/tickets/protected700/pages/UserLogin.php
new file mode 100644
index 00000000..37258879
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/pages/UserLogin.php
@@ -0,0 +1,13 @@
+<?php
+
+class UserLogin extends BasePage
+{
+ public function loginButtonClicked($sender,$param)
+ {
+ $authManager=$this->Application->getModule('auth');
+ $authManager->login($this->Username->Text,$this->Password->Text);
+ $this->Response->redirect($this->Service->constructUrl('Home'));
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/pages/admin/Home.page b/tests/FunctionalTests/tickets/protected700/pages/admin/Home.page
new file mode 100644
index 00000000..7d1c1187
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/pages/admin/Home.page
@@ -0,0 +1,14 @@
+<com:TContent ID="Main">
+
+|Param1: <%= $this->Param1 %>|
+<br/>
+|Param2: <%= $this->Param2 %>|
+<br/>
+|Param3: <%= $this->Param3 %>|
+<br/>
+|Param4: <%= $this->Param4 %>|
+<br/>
+|Param5: <%= $this->Param5 %>|
+<br/>
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/pages/admin/Home2.page b/tests/FunctionalTests/tickets/protected700/pages/admin/Home2.page
new file mode 100644
index 00000000..7d1c1187
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/pages/admin/Home2.page
@@ -0,0 +1,14 @@
+<com:TContent ID="Main">
+
+|Param1: <%= $this->Param1 %>|
+<br/>
+|Param2: <%= $this->Param2 %>|
+<br/>
+|Param3: <%= $this->Param3 %>|
+<br/>
+|Param4: <%= $this->Param4 %>|
+<br/>
+|Param5: <%= $this->Param5 %>|
+<br/>
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/pages/admin/config.xml b/tests/FunctionalTests/tickets/protected700/pages/admin/config.xml
new file mode 100644
index 00000000..04ac6bdd
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/pages/admin/config.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+ <authorization>
+ <allow pages="Home2" users="*" />
+ <deny pages="users.Home" roles="user" />
+ </authorization>
+ <pages Param2="Set at admin">
+ <page id="users.Home" Param1="Set at admin" Param4="Set at admin" />
+ <page id="Home" Param3="Set at admin" />
+ </pages>
+</configuration> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/pages/admin/users/Home.page b/tests/FunctionalTests/tickets/protected700/pages/admin/users/Home.page
new file mode 100644
index 00000000..7d1c1187
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/pages/admin/users/Home.page
@@ -0,0 +1,14 @@
+<com:TContent ID="Main">
+
+|Param1: <%= $this->Param1 %>|
+<br/>
+|Param2: <%= $this->Param2 %>|
+<br/>
+|Param3: <%= $this->Param3 %>|
+<br/>
+|Param4: <%= $this->Param4 %>|
+<br/>
+|Param5: <%= $this->Param5 %>|
+<br/>
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/pages/admin/users/Home2.page b/tests/FunctionalTests/tickets/protected700/pages/admin/users/Home2.page
new file mode 100644
index 00000000..7d1c1187
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/pages/admin/users/Home2.page
@@ -0,0 +1,14 @@
+<com:TContent ID="Main">
+
+|Param1: <%= $this->Param1 %>|
+<br/>
+|Param2: <%= $this->Param2 %>|
+<br/>
+|Param3: <%= $this->Param3 %>|
+<br/>
+|Param4: <%= $this->Param4 %>|
+<br/>
+|Param5: <%= $this->Param5 %>|
+<br/>
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/pages/admin/users/config.xml b/tests/FunctionalTests/tickets/protected700/pages/admin/users/config.xml
new file mode 100644
index 00000000..175ea5c7
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/pages/admin/users/config.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+ <pages>
+ <page id="Home" Param2="Set at admin.users" />
+ </pages>
+</configuration> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/pages/config.xml b/tests/FunctionalTests/tickets/protected700/pages/config.xml
new file mode 100644
index 00000000..416de43f
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/pages/config.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+ <authorization>
+ <allow pages="content.*" users="*" />
+ </authorization>
+ <pages Param2="Set at root">
+ <page id="users.Home" Param1="Set at admin" Param4="Set at admin" />
+ <page id="Home" Param5="Set at root" />
+ </pages>
+</configuration> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected700/pages/content/Home.page b/tests/FunctionalTests/tickets/protected700/pages/content/Home.page
new file mode 100644
index 00000000..7d1c1187
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected700/pages/content/Home.page
@@ -0,0 +1,14 @@
+<com:TContent ID="Main">
+
+|Param1: <%= $this->Param1 %>|
+<br/>
+|Param2: <%= $this->Param2 %>|
+<br/>
+|Param3: <%= $this->Param3 %>|
+<br/>
+|Param4: <%= $this->Param4 %>|
+<br/>
+|Param5: <%= $this->Param5 %>|
+<br/>
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/tests/Ticket700TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket700TestCase.php
new file mode 100644
index 00000000..e7ff30b3
--- /dev/null
+++ b/tests/FunctionalTests/tickets/tests/Ticket700TestCase.php
@@ -0,0 +1,72 @@
+<?php
+class Ticket700TestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ // page: Home
+ $this->open('tickets/index700.php');
+ $this->clickAndWait('ctl0_Logout');
+ $this->clickAndWait('pageHome');
+ $this->assertTitle("Home");
+ $this->assertTextPresent('|Param1: Set at app config|');
+ $this->assertTextPresent('|Param2: Set at root|');
+ $this->assertTextPresent('|Param3: default 3|');
+ $this->assertTextPresent('|Param4: default 4|');
+ $this->assertTextPresent('|Param5: Set at root|');
+
+ // page: admin.Home
+ $this->clickAndWait('pageAdminHome');
+ $this->assertTitle('UserLogin');
+ $this->type('ctl0_Main_Username','AdminUser');
+ $this->type('ctl0_Main_Password','demo');
+ $this->clickAndWait('ctl0_Main_LoginButton');
+ $this->clickAndWait('pageAdminHome');
+ $this->assertTitle('admin.Home');
+ $this->assertTextPresent('|Param1: Set at app config|');
+ $this->assertTextPresent('|Param2: Set at admin|');
+ $this->assertTextPresent('|Param3: Set at admin|');
+ $this->assertTextPresent('|Param4: Set at app config|');
+ $this->assertTextPresent('|Param5: Set at app config|');
+
+ // page: admin.Home2
+ $this->clickAndWait('pageAdminHome2');
+ $this->assertTitle('admin.Home2');
+ $this->clickAndWait('ctl0_Logout');
+ $this->clickAndWait('pageAdminHome2');
+ $this->assertTitle('admin.Home2');
+
+ // page: admin.users.Home
+ $this->clickAndWait('pageAdminUsersHome');
+ $this->assertTitle('UserLogin');
+ $this->type('ctl0_Main_Username','NormalUser');
+ $this->type('ctl0_Main_Password','demo');
+ $this->clickAndWait('ctl0_Main_LoginButton');
+ $this->clickAndWait('pageAdminUsersHome');
+ $this->assertTitle('UserLogin');
+ $this->type('ctl0_Main_Username','AdminUser');
+ $this->type('ctl0_Main_Password','demo');
+ $this->clickAndWait('ctl0_Main_LoginButton');
+ $this->clickAndWait('pageAdminUsersHome');
+ $this->assertTitle('admin.users.Home');
+ $this->assertTextPresent('|Param1: Set at admin|');
+ $this->assertTextPresent('|Param2: Set at admin.users|');
+ $this->assertTextPresent('|Param3: default 3|');
+ $this->assertTextPresent('|Param4: Set at admin|');
+ $this->assertTextPresent('|Param5: Set at app config|');
+
+ // page: admin.users.Home2
+ $this->clickAndWait('pageAdminUsersHome2');
+ $this->assertTitle('admin.users.Home2');
+
+ // page: content.Home
+ $this->clickAndWait('pageContentHome');
+ $this->assertTitle('content.Home');
+ $this->assertTextPresent('|Param1: Set at app config|');
+ $this->assertTextPresent('|Param2: Set at root|');
+ $this->assertTextPresent('|Param3: default 3|');
+ $this->assertTextPresent('|Param4: default 4|');
+ $this->assertTextPresent('|Param5: Set at app config|');
+ $this->clickAndWait('ctl0_Logout');
+ }
+}
+?> \ No newline at end of file