From ab3dfbac9257ea324ab64eddcf472e2b46291a39 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 28 Dec 2013 19:26:18 -0500 Subject: [PATCH] Simplified tests. --- apps/basic/tests/_pages/ContactPage.php | 44 ++----------------- apps/basic/tests/_pages/LoginPage.php | 24 ++-------- apps/basic/tests/functional/ContactCept.php | 2 +- apps/basic/tests/functional/LoginCept.php | 2 +- apps/basic/tests/functional/_pages/ContactPage.php | 51 ---------------------- apps/basic/tests/functional/_pages/LoginPage.php | 30 ------------- 6 files changed, 10 insertions(+), 143 deletions(-) delete mode 100644 apps/basic/tests/functional/_pages/ContactPage.php delete mode 100644 apps/basic/tests/functional/_pages/LoginPage.php diff --git a/apps/basic/tests/_pages/ContactPage.php b/apps/basic/tests/_pages/ContactPage.php index 4fd6fa8..f8a1236 100644 --- a/apps/basic/tests/_pages/ContactPage.php +++ b/apps/basic/tests/_pages/ContactPage.php @@ -9,50 +9,14 @@ class ContactPage extends BasePage public $route = 'site/contact'; /** - * contact form name text field locator - * @var string - */ - public $name = 'input[name="ContactForm[name]"]'; - /** - * contact form email text field locator - * @var string - */ - public $email = 'input[name="ContactForm[email]"]'; - /** - * contact form subject text field locator - * @var string - */ - public $subject = 'input[name="ContactForm[subject]"]'; - /** - * contact form body textarea locator - * @var string - */ - public $body = 'textarea[name="ContactForm[body]"]'; - /** - * contact form verification code text field locator - * @var string - */ - public $verifyCode = 'input[name="ContactForm[verifyCode]"]'; - /** - * contact form submit button - * @var string - */ - public $button = 'button[type=submit]'; - - /** - * * @param array $contactData */ public function submit(array $contactData) { - if (!empty($contactData)) - { - $this->guy->fillField($this->name, $contactData['name']); - $this->guy->fillField($this->email, $contactData['email']); - $this->guy->fillField($this->subject, $contactData['subject']); - $this->guy->fillField($this->body, $contactData['body']); - $this->guy->fillField($this->verifyCode, $contactData['verifyCode']); + $data = []; + foreach ($contactData as $name => $value) { + $data["ContactForm[$name]"] = $value; } - $this->guy->click($this->button); + $this->guy->submitForm('#contact-form', $data); } } diff --git a/apps/basic/tests/_pages/LoginPage.php b/apps/basic/tests/_pages/LoginPage.php index 8493d51..aae5e0f 100644 --- a/apps/basic/tests/_pages/LoginPage.php +++ b/apps/basic/tests/_pages/LoginPage.php @@ -9,30 +9,14 @@ class LoginPage extends BasePage public $route = 'site/login'; /** - * login form username text field locator - * @var string - */ - public $username = 'input[name="LoginForm[username]"]'; - /** - * login form password text field locator - * @var string - */ - public $password = 'input[name="LoginForm[password]"]'; - /** - * login form submit button locator - * @var string - */ - public $button = 'button[type=submit]'; - - /** - * * @param string $username * @param string $password */ public function login($username, $password) { - $this->guy->fillField($this->username, $username); - $this->guy->fillField($this->password, $password); - $this->guy->click($this->button); + $this->guy->submitForm('#login-form', [ + 'LoginForm[username]' => $username, + 'LoginForm[password]' => $password, + ]); } } diff --git a/apps/basic/tests/functional/ContactCept.php b/apps/basic/tests/functional/ContactCept.php index ddc7ca6..14e6197 100644 --- a/apps/basic/tests/functional/ContactCept.php +++ b/apps/basic/tests/functional/ContactCept.php @@ -1,6 +1,6 @@ wantTo('ensure that contact works'); diff --git a/apps/basic/tests/functional/LoginCept.php b/apps/basic/tests/functional/LoginCept.php index 770b823..e5285cd 100644 --- a/apps/basic/tests/functional/LoginCept.php +++ b/apps/basic/tests/functional/LoginCept.php @@ -1,6 +1,6 @@ wantTo('ensure that login works'); diff --git a/apps/basic/tests/functional/_pages/ContactPage.php b/apps/basic/tests/functional/_pages/ContactPage.php deleted file mode 100644 index 0d0eba4..0000000 --- a/apps/basic/tests/functional/_pages/ContactPage.php +++ /dev/null @@ -1,51 +0,0 @@ -guy->submitForm('#contact-form', []); - } else { - $this->guy->submitForm('#contact-form', [ - $this->name => $contactData['name'], - $this->email => $contactData['email'], - $this->subject => $contactData['subject'], - $this->body => $contactData['body'], - $this->verifyCode => $contactData['verifyCode'], - ]); - } - } -} diff --git a/apps/basic/tests/functional/_pages/LoginPage.php b/apps/basic/tests/functional/_pages/LoginPage.php deleted file mode 100644 index 9a8d0ef..0000000 --- a/apps/basic/tests/functional/_pages/LoginPage.php +++ /dev/null @@ -1,30 +0,0 @@ -guy->submitForm('#login-form', [ - $this->username => $username, - $this->password => $password, - ]); - } -}