aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/selenium
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/selenium')
-rw-r--r--tests/phpunit/selenium/catalog/AccountTest.php320
-rw-r--r--tests/phpunit/selenium/catalog/CategoryTest.php39
-rw-r--r--tests/phpunit/selenium/catalog/CheckoutTest.php64
-rw-r--r--tests/phpunit/selenium/catalog/PayPalExpressTest.php173
-rw-r--r--tests/phpunit/selenium/catalog/ProductTest.php79
-rw-r--r--tests/phpunit/selenium/catalog/SagePayDirectTest.php153
-rw-r--r--tests/phpunit/selenium/openbay/SetupTest.php91
7 files changed, 919 insertions, 0 deletions
diff --git a/tests/phpunit/selenium/catalog/AccountTest.php b/tests/phpunit/selenium/catalog/AccountTest.php
new file mode 100644
index 0000000..10edf84
--- /dev/null
+++ b/tests/phpunit/selenium/catalog/AccountTest.php
@@ -0,0 +1,320 @@
+<?php
+
+class CatalogAccountTest extends OpenCartSeleniumTest {
+
+
+ /**
+ * @before
+ */
+ protected function setupTest() {
+ $this->setBrowser('firefox');
+ $this->setBrowserUrl(HTTP_SERVER);
+ }
+
+ /**
+ * @after
+ */
+ protected function completeTest() {
+ $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PORT);
+ $db->query("DELETE FROM " . DB_PREFIX . "customer");
+ $db->query("DELETE FROM " . DB_PREFIX . "address");
+ }
+
+ public function testNewsletterSubscription() {
+ $this->doRegistration();
+
+ $this->url("index.php?route=account/newsletter");
+ $this->byCssSelector('input[value="1"]')->click();
+ $this->byCssSelector('input[value="Continue"]')->click();
+ $this->url("index.php?route=account/newsletter");
+ $element = $this->byCssSelector('input[value="1"]');
+ $this->assertEquals('true', $element->attribute('checked'));
+
+ $this->byCssSelector('input[value="0"]')->click();
+ $this->byCssSelector('input[value="Continue"]')->click();
+ $this->url("index.php?route=account/newsletter");
+ $element = $this->byCssSelector('input[value="0"]');
+ $this->assertEquals('true', $element->attribute('checked'));
+ }
+
+ public function testAddAddress() {
+ $this->doRegistration();
+ $this->url("index.php?route=account/address/add");
+
+ $this->clickOnElement('input-firstname');
+ $this->keys('Firstname');
+
+ $this->clickOnElement('input-lastname');
+ $this->keys('Lastname');
+
+ $this->clickOnElement('input-company');
+ $this->keys('Company');
+
+ $this->clickOnElement('input-address-1');
+ $this->keys('Address 1');
+
+ $this->clickOnElement('input-address-2');
+ $this->keys('Address 2');
+
+ $this->clickOnElement('input-city');
+ $this->keys('City');
+
+ $this->clickOnElement('input-postcode');
+ $this->keys('000 000');
+
+ $this->byCssSelector('#input-country option[value="222"]')->click();
+ $this->byCssSelector('#input-zone option[value="3608"]')->click();
+
+ $this->byCssSelector('input[value="Continue"]')->click();
+
+ $this->waitUntil(function() {
+ if (strpos($this->url(), 'account/address') !== False) {
+ return true;
+ }
+ }, 3000);
+
+ $this->byCssSelector('table.table-hover tr:last-child td:last-child .btn-info')->click();
+
+ $this->waitUntil(function() {
+ if (strpos($this->url(), 'account/address/edit') !== False) {
+ return true;
+ }
+ }, 3000);
+
+ $this->byId('input-firstname')->clear();
+ $this->clickOnElement('input-firstname');
+ $this->keys('Firstname2');
+
+ $this->byId('input-lastname')->clear();
+ $this->clickOnElement('input-lastname');
+ $this->keys('Lastname2');
+
+ $this->byId('input-company')->clear();
+ $this->clickOnElement('input-company');
+ $this->keys('Company2');
+
+ $this->byId('input-address-1')->clear();
+ $this->clickOnElement('input-address-1');
+ $this->keys('Address 12');
+
+ $this->byId('input-address-2')->clear();
+ $this->clickOnElement('input-address-2');
+ $this->keys('Address 22');
+
+ $this->byId('input-city')->clear();
+ $this->clickOnElement('input-city');
+ $this->keys('City2');
+
+ $this->byId('input-postcode')->clear();
+ $this->clickOnElement('input-postcode');
+ $this->keys('999 999');
+
+ $this->byCssSelector('#input-country option[value="223"]')->click();
+
+ $this->waitUntil(function() {
+ if ($this->byCssSelector('#input-zone option[value="3624"]')) {
+ return true;
+ }
+ }, 3000);
+
+ $this->byCssSelector('#input-zone option[value="3624"]')->click();
+
+ $this->byCssSelector('input[value="Continue"]')->click();
+
+ $this->waitUntil(function() {
+ if (strpos($this->url(), 'account/address') !== False) {
+ return true;
+ }
+ }, 3000);
+
+ $this->byCssSelector('table.table-hover tr:last-child td:last-child .btn-info')->click();
+
+ $firstname = $this->byId('input-firstname')->value();
+ $this->assertEquals('Firstname2', $firstname);
+
+ $lastname = $this->byId('input-lastname')->value();
+ $this->assertEquals('Lastname2', $lastname);
+
+ $company = $this->byId('input-company')->value();
+ $this->assertEquals('Company2', $company);
+
+ $address1 = $this->byId('input-address-1')->value();
+ $this->assertEquals('Address 12', $address1);
+
+ $address2 = $this->byId('input-address-2')->value();
+ $this->assertEquals('Address 22', $address2);
+
+ $city = $this->byId('input-city')->value();
+ $this->assertEquals('City2', $city);
+
+ $postcode = $this->byId('input-postcode')->value();
+ $this->assertEquals('999 999', $postcode);
+
+ $country = $this->byId('input-country')->value();
+ $this->assertEquals('223', $country);
+
+ $zone = $this->byId('input-zone')->value();
+ $this->assertEquals('3624', $zone);
+ }
+
+ public function testChangePassword() {
+ $this->doRegistration();
+
+ $this->url("index.php?route=account/password");
+
+ $this->clickOnElement('input-password');
+ $this->keys('new-password');
+
+ $this->clickOnElement('input-confirm');
+ $this->keys('new-password');
+
+ $this->byCssSelector('input[value="Continue"]')->click();
+
+ $this->url('index.php?route=account/logout');
+ $this->url('index.php?route=account/login');
+
+ $this->clickOnElement('input-email');
+ $this->keys('john.smith@example.com');
+
+ $this->clickOnElement('input-password');
+ $this->keys('new-password');
+
+ $this->byCssSelector('input[value="Login"]')->click();
+
+ $this->waitUntil(function(){
+ if (strpos($this->url(), 'account/account') !== False) {
+ return true;
+ }
+ }, 3000);
+ }
+
+ public function testInformationEditing() {
+ $this->doRegistration();
+
+ $this->url("index.php?route=account/edit");
+
+ $this->byId('input-firstname')->clear();
+ $this->clickOnElement('input-firstname');
+ $this->keys('John-New');
+
+ $this->byId('input-lastname')->clear();
+ $this->clickOnElement('input-lastname');
+ $this->keys('Smith-New');
+
+ $this->byId('input-email')->clear();
+ $this->clickOnElement('input-email');
+ $this->keys('john.smith.new@example.com');
+
+ $this->byId('input-telephone')->clear();
+ $this->clickOnElement('input-telephone');
+ $this->keys('000000000');
+
+ $this->byCssSelector('input[value="Continue"]')->click();
+
+ $this->url("index.php?route=account/edit");
+
+ $firstname = $this->byId('input-firstname')->value();
+ $this->assertEquals('John-New', $firstname);
+
+ $lastname = $this->byId('input-lastname')->value();
+ $this->assertEquals('Smith-New', $lastname);
+
+ $email = $this->byId('input-email')->value();
+ $this->assertEquals('john.smith.new@example.com', $email);
+
+ $telephone = $this->byId('input-telephone')->value();
+ $this->assertEquals('000000000', $telephone);
+ }
+
+ public function testLogin() {
+ $this->doRegistration();
+ $this->url('index.php?route=account/logout');
+ $this->url('index.php?route=account/login');
+
+ $this->clickOnElement('input-email');
+ $this->keys('john.smith@example.com');
+
+ $this->clickOnElement('input-password');
+ $this->keys('password123456');
+
+ $this->byCssSelector('input[value="Login"]')->click();
+
+ $this->waitUntil(function(){
+ if (strpos($this->url(), 'account/account') !== False) {
+ return true;
+ }
+ }, 3000);
+ }
+
+ public function testFailedLogin() {
+ $this->doRegistration();
+ $this->url('index.php?route=account/logout');
+ $this->url('index.php?route=account/login');
+
+ $this->clickOnElement('input-email');
+ $this->keys('john.smith@example.com');
+
+ $this->clickOnElement('input-password');
+ $this->keys('incorrect password');
+
+ $this->byCssSelector('input[value="Login"]')->click();
+
+ $this->waitUntil(function(){
+ if (strpos($this->url(), 'account/login') !== False) {
+ return true;
+ }
+ }, 3000);
+
+ $this->byCssSelector('.alert-danger');
+ }
+
+ private function doRegistration() {
+ $this->url('index.php?route=account/register');
+
+ $this->clickOnElement('input-firstname');
+ $this->keys('John');
+
+ $this->clickOnElement('input-lastname');
+ $this->keys('Smith');
+
+ $this->clickOnElement('input-email');
+ $this->keys('john.smith@example.com');
+
+ $this->clickOnElement('input-telephone');
+ $this->keys('0123456789');
+
+ $this->clickOnElement('input-address-1');
+ $this->keys('Address 1');
+
+ $this->clickOnElement('input-address-2');
+ $this->keys('Address 2');
+
+ $this->clickOnElement('input-city');
+ $this->keys('City');
+
+ $this->clickOnElement('input-postcode');
+ $this->keys('000 000');
+
+ $countryElement = $this->byCssSelector('#input-country option[value="222"]');
+ $countryElement->click();
+
+ $countyElement = $this->byCssSelector('#input-zone option[value="3608"]');
+ $countyElement->click();
+
+ $this->clickOnElement('input-password');
+ $this->keys('password123456');
+
+ $this->clickOnElement('input-confirm');
+ $this->keys('password123456');
+
+ $this->byCssSelector('input[name="agree"]')->click();
+
+ $this->byCssSelector('input[value="Continue"]')->click();
+
+ $this->waitUntil(function(){
+ if (strpos($this->url(), 'account/success') !== False) {
+ return true;
+ }
+ }, 3000);
+ }
+}
diff --git a/tests/phpunit/selenium/catalog/CategoryTest.php b/tests/phpunit/selenium/catalog/CategoryTest.php
new file mode 100644
index 0000000..878ecc2
--- /dev/null
+++ b/tests/phpunit/selenium/catalog/CategoryTest.php
@@ -0,0 +1,39 @@
+<?php
+
+class CatalogCategoryTest extends OpenCartSeleniumTest {
+
+
+ /**
+ * @before
+ */
+ protected function setupTest() {
+ $this->setBrowser('firefox');
+ $this->setBrowserUrl(HTTP_SERVER);
+ }
+
+ public function testAddToCartButton() {
+ $this->url('http://opencart.welfordlocal.co.uk/index.php?route=product/category&path=20');
+
+ $addToCartButton = $this->byCssSelector('button[onclick="cart.add(\'28\');"]');
+ $addToCartButton->click();
+
+ $this->url('index.php?route=checkout/cart');
+ $element = $this->byCssSelector('#accordion + br + .row .table-bordered tr:last-child td:last-child');
+ $this->assertEquals('$119.50', $element->text());
+ }
+
+
+ public function testRedirect() {
+ $this->url('http://opencart.welfordlocal.co.uk/index.php?route=product/category&path=20');
+
+ $addToCartButton = $this->byCssSelector('button[onclick="cart.add(\'42\');"]');
+ $addToCartButton->click();
+
+ $this->waitUntil(function(){
+ if (strpos($this->url(), 'product/product') !== False) {
+ return true;
+ }
+ }, 3000);
+ }
+
+}
diff --git a/tests/phpunit/selenium/catalog/CheckoutTest.php b/tests/phpunit/selenium/catalog/CheckoutTest.php
new file mode 100644
index 0000000..8d5583d
--- /dev/null
+++ b/tests/phpunit/selenium/catalog/CheckoutTest.php
@@ -0,0 +1,64 @@
+<?php
+
+class CatalogCheckoutTest extends OpenCartSeleniumTest {
+
+
+ /**
+ * @before
+ */
+ protected function setupTest() {
+ $this->setBrowser('firefox');
+ $this->setBrowserUrl(HTTP_SERVER);
+ }
+
+ public function testUpdateQuantity() {
+ $this->addProductsToCart();
+
+ $element = $this->byCssSelector('.table-bordered tbody tr:last-child input');
+ $this->assertEquals('3', $element->value());
+
+ $element = $this->byCssSelector('.table-bordered tbody tr:first-child input');
+ $this->assertEquals('1', $element->value());
+
+ $element->clear();
+ $element->click();
+ $this->keys('2');
+
+ $this->byCssSelector('.table-bordered tbody tr:first-child button.btn-primary')->click();
+
+ sleep(3);
+
+ $element = $this->byCssSelector('.table-bordered tbody tr:first-child input');
+ $this->assertEquals('2', $element->value());
+
+ $element = $this->byCssSelector('.table-bordered tbody tr:last-child input');
+ $this->assertEquals('3', $element->value());
+ }
+
+ public function testRemoveProduct() {
+ $this->addProductsToCart();
+
+ $element = $this->byCssSelector('form .table-bordered tbody tr:first-child td:nth-child(2)');
+ $this->assertStringStartsWith('MacBook', $element->text());
+
+ $this->byCssSelector('.table-bordered tbody tr:first-child button.btn-danger')->click();
+
+ sleep(3);
+
+ $element = $this->byCssSelector('form .table-bordered tbody tr:first-child td:nth-child(2)');
+ $this->assertStringStartsWith('Sony VAIO', $element->text());
+ }
+
+ private function addProductsToCart() {
+ $this->url('index.php?route=product/product&product_id=43');
+ $this->byId('button-cart')->click();
+
+ $this->url('index.php?route=product/product&product_id=46');
+ $this->byId('input-quantity')->clear();
+ $this->clickOnElement('input-quantity');
+ $this->keys('3');
+ $this->byId('button-cart')->click();
+
+ $this->url('index.php?route=checkout/cart');
+ }
+}
diff --git a/tests/phpunit/selenium/catalog/PayPalExpressTest.php b/tests/phpunit/selenium/catalog/PayPalExpressTest.php
new file mode 100644
index 0000000..8fcc9c5
--- /dev/null
+++ b/tests/phpunit/selenium/catalog/PayPalExpressTest.php
@@ -0,0 +1,173 @@
+<?php
+
+class CatalogPayPalExpressTest extends OpenCartSeleniumTest {
+
+ private $moduleInstalled = false;
+
+ /**
+ * @before
+ */
+ protected function before() {
+ $this->setBrowser('firefox');
+ $this->setBrowserUrl(HTTP_SERVER);
+ }
+
+ public function setUpPage() {
+ if (!$this->moduleInstalled) {
+ $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PORT);
+ $db->query("DROP TABLE IF EXISTS " . DB_PREFIX . "paypal_order");
+ $db->query("DROP TABLE IF EXISTS " . DB_PREFIX . "paypal_order_transaction");
+ $db->query("DELETE l, lr FROM " . DB_PREFIX . "layout l, " . DB_PREFIX . "layout_route lr WHERE l.layout_id = lr.layout_id AND l.`name` = 'Cart'");
+
+ $this->url("admin/");
+
+ $this->byCssSelector('input[name="username"]')->click();
+ $this->keys(ADMIN_USERNAME);
+
+ $this->byCssSelector('input[name="password"]')->click();
+ $this->keys(ADMIN_PASSWORD);
+
+ $this->byCssSelector('button[type="submit"]')->click();
+
+ $this->moduleInstalled = true;
+
+ $this->waitToLoad('Dashboard');
+
+ // Installing the payment module
+ $this->clickOnElement('button-menu');
+
+ $this->waitToAppearAndClick('#extension a');
+ $this->waitToAppearAndClick('#extension li:nth-child(5) a');
+
+ $this->waitToLoad('Payment');
+
+ $i = 1;
+
+ for ( ; ; $i++) {
+ $element = $this->byCssSelector(".table-bordered tbody tr:nth-child($i) td:first-child");
+
+ if ($element->text() == 'PayPal Express Checkout') {
+ break;
+ }
+ }
+
+ $this->waitToAppearAndClick(".table-bordered tbody tr:nth-child($i) td:last-child a.btn-success");
+ $this->waitToAppearAndClick(".table-bordered tbody tr:nth-child($i) td:last-child a.btn-primary");
+
+ $this->waitToLoad('PayPal Express Checkout');
+
+ $this->clickOnElement('entry-username');
+ $this->keys(PP_EXPRESS_API_USERNAME);
+
+ $this->clickOnElement('entry-password');
+ $this->keys(PP_EXPRESS_API_PASSWORD);
+
+ $this->clickOnElement('entry-signature');
+ $this->keys(PP_EXPRESS_API_SIGNATURE);
+
+ $this->byCssSelector('a[href="#tab-general"]')->click();
+
+ $this->waitToAppearAndClick('#input-live-demo option[value="1"]');
+
+ for ($i = 1; ; $i++) {
+ $element = $this->byCssSelector('#input-currency option:nth-child(' . $i . ')');
+
+ if ($element->text() == 'USD') {
+ $element->click();
+ break;
+ }
+ }
+
+ $this->clickOnElement('input-total');
+ $this->keys('0.00');
+
+ $this->byCssSelector('#input-status option[value="1"]')->click();
+
+ $this->byCssSelector('.pull-right button.btn')->click();
+
+ // Adding the Cart Layout
+ $this->waitToAppearAndClick('#system a');
+ $this->waitToAppearAndClick('#system li:nth-child(2) a');
+ $this->waitToAppearAndClick('#system li:nth-child(2) li:first-child a');
+
+ $this->waitToLoad('Layouts');
+ $this->byCssSelector('.fa-plus-circle')->click();
+
+ $this->waitToAppearAndClick('#input-name');
+ $this->keys('Cart');
+
+ $this->byCssSelector('.fa-plus-circle')->click();
+
+ $this->byCssSelector('input[name="layout_route[0][route]"]')->click();
+ $this->keys('checkout/cart');
+
+ $this->byCssSelector('.fa-check-circle')->click();
+
+ // Installing the payment button
+ $this->waitToAppearAndClick('#extension a');
+ $this->waitToAppearAndClick('#extension li:nth-child(3) a');
+
+ $i = 1;
+
+ for ( ; ; $i++) {
+ $element = $this->byCssSelector(".table-bordered tbody tr:nth-child($i) td:first-child");
+
+ if ($element->text() == 'PayPal Express Checkout button') {
+ break;
+ }
+ }
+
+ $this->waitToAppearAndClick(".table-bordered tbody tr:nth-child($i) td:last-child a.btn-success");
+ $this->waitToAppearAndClick(".table-bordered tbody tr:nth-child($i) td:last-child a.btn-primary");
+
+ $this->waitToLoad('PayPal Express Checkout button');
+ $this->byCssSelector('.fa-plus-circle')->click();
+
+ for ($i = 1; ; $i++) {
+ $element = $this->byCssSelector("select[name=\"pp_button_module[0][layout_id]\"] option:nth-child($i)");
+
+ if ($element->text() == 'Cart') {
+ $element->click();
+ break;
+ }
+ }
+
+ $this->byCssSelector('button[title="Save"]')->click();
+ }
+ }
+
+ public function testOneProduct() {
+ $this->url('index.php?route=product/product&product_id=43');
+ $this->clickOnElement('button-cart');
+
+ $this->url('index.php?route=checkout/cart');
+ $this->waitToLoad('Shopping Cart');
+
+ $this->byCssSelector('.pp-express-button')->click();
+
+ $this->waitToLoad("Pay with a PayPal", 30000);
+
+ $this->clickOnElement('login_email');
+ $this->keys(PP_EXPRESS_USERNAME);
+
+ $this->clickOnElement('login_password');
+ $this->keys(PP_EXPRESS_PASSWORD);
+
+ $this->clickOnElement('submitLogin');
+
+ $this->waitToLoad("Review your information", 30000);
+
+ $this->clickOnElement('continue_abovefold');
+
+ $this->waitToLoad("Confirm order", 30000);
+
+ $this->byCssSelector('.pull-right .btn-primary')->click();
+
+ $this->waitToLoad("Your order has been placed!");
+
+ $element = $this->byCssSelector('#content h1');
+
+ $this->assertEquals('Your order has been placed!', $element->text());
+ }
+
+}
diff --git a/tests/phpunit/selenium/catalog/ProductTest.php b/tests/phpunit/selenium/catalog/ProductTest.php
new file mode 100644
index 0000000..5d70b4a
--- /dev/null
+++ b/tests/phpunit/selenium/catalog/ProductTest.php
@@ -0,0 +1,79 @@
+<?php
+
+class CatalogProductTest extends OpenCartSeleniumTest {
+
+
+ /**
+ * @before
+ */
+ protected function setupTest() {
+ $this->setBrowser('firefox');
+ $this->setBrowserUrl(HTTP_SERVER);
+ }
+
+ public function testSearch() {
+ $this->url('index.php?route=common/home');
+ $this->byCssSelector('input[name="search"]')->click();
+ $this->keys('Apple');
+
+ $this->byCssSelector('i.fa-search')->click();
+
+ $this->waitUntil(function() {
+ if (strpos($this->url(), 'product/search') !== False) {
+ return true;
+ }
+ }, 3000);
+
+ $element = $this->byCssSelector('div.caption a');
+ $this->assertTrue(strpos($element->attribute('href'), 'product_id=42') !== False);
+ }
+
+ public function testAddToCartButton() {
+ $this->url('index.php?route=product/product&product_id=43');
+ $this->clickOnElement('button-cart');
+
+ $this->url('index.php?route=checkout/cart');
+ $element = $this->byCssSelector('#accordion + br + .row .table-bordered tr:last-child td:last-child');
+ $this->assertEquals('$589.50', $element->text());
+ }
+
+ public function testQuantityField() {
+ $this->url('index.php?route=product/product&product_id=43');
+ $inputElement = $this->byId('input-quantity');
+ $inputElement->clear();
+
+ $this->clickOnElement('input-quantity');
+ $this->keys('3');
+
+ $this->clickOnElement('button-cart');
+
+ $this->url('index.php?route=checkout/cart');
+ $element = $this->byCssSelector('#accordion + br + .row .table-bordered tr:last-child td:last-child');
+ $this->assertEquals('$1,768.50', $element->text());
+ }
+
+ public function testWishListButton() {
+ $this->url('index.php?route=product/product&product_id=43');
+ $element = $this->byCssSelector('i.fa-heart:last-child');
+ $element->click();
+
+ $this->waitUntil(function() {
+ if ($this->byCssSelector('.alert-success')) {
+ return true;
+ }
+ }, 2000);
+ }
+
+ public function testCompareButton() {
+ $this->url('index.php?route=product/product&product_id=43');
+ $element = $this->byCssSelector('i.fa-exchange');
+ $element->click();
+
+ $this->waitUntil(function() {
+ if ($this->byCssSelector('.alert-success')) {
+ return true;
+ }
+ }, 2000);
+ }
+
+}
diff --git a/tests/phpunit/selenium/catalog/SagePayDirectTest.php b/tests/phpunit/selenium/catalog/SagePayDirectTest.php
new file mode 100644
index 0000000..8e65fe6
--- /dev/null
+++ b/tests/phpunit/selenium/catalog/SagePayDirectTest.php
@@ -0,0 +1,153 @@
+<?php
+
+class CatalogSagePayExpressTest extends OpenCartSeleniumTest {
+
+ private $moduleInstalled = false;
+
+ /**
+ * @before
+ */
+ protected function before() {
+ $this->setBrowser('firefox');
+ $this->setBrowserUrl(HTTP_SERVER);
+ }
+
+ public function setUpPage() {
+ if (!$this->moduleInstalled) {
+ $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PORT);
+ $db->query("DROP TABLE IF EXISTS " . DB_PREFIX . "sagepay_direct_order");
+ $db->query("DROP TABLE IF EXISTS " . DB_PREFIX . "sagepay_direct_order_transaction");
+ $db->query("DROP TABLE IF EXISTS " . DB_PREFIX . "sagepay_direct_order_recurring");
+ $db->query("DROP TABLE IF EXISTS " . DB_PREFIX . "sagepay_direct_card");
+
+ $this->url("admin/");
+
+ $this->byCssSelector('input[name="username"]')->click();
+ $this->keys(ADMIN_USERNAME);
+
+ $this->byCssSelector('input[name="password"]')->click();
+ $this->keys(ADMIN_PASSWORD);
+
+ $this->byCssSelector('button[type="submit"]')->click();
+
+ $this->moduleInstalled = true;
+
+ $this->waitToLoad('Dashboard');
+
+ // Installing the payment module
+ $this->clickOnElement('button-menu');
+
+ $this->waitToAppearAndClick('#extension a');
+ $this->waitToAppearAndClick('#extension li:nth-child(5) a');
+
+ $this->waitToLoad('Payment');
+
+ $i = 1;
+
+ for ( ; ; $i++) {
+ $element = $this->byCssSelector(".table-bordered tbody tr:nth-child($i) td:first-child");
+
+ if ($element->text() == 'SagePay Direct') {
+ break;
+ }
+ }
+
+ $this->waitToAppearAndClick(".table-bordered tbody tr:nth-child($i) td:last-child a.btn-success");
+ $this->waitToAppearAndClick(".table-bordered tbody tr:nth-child($i) td:last-child a.btn-primary");
+
+ $this->waitToLoad('SagePay Direct');
+
+ $this->clickOnElement('sagepay_direct_vendor');
+ $this->keys(SAGEPAY_DIRECT_VENDOR);
+
+ $this->byCssSelector('#input-test option[value="test"]')->click();
+
+ $this->clickOnElement('sagepay_direct_total');
+ $this->keys('0.00');
+
+ // Adding the Cart Layout
+ $this->waitToAppearAndClick('#system a');
+ $this->waitToAppearAndClick('#system li:nth-child(2) a');
+ $this->waitToAppearAndClick('#system li:nth-child(2) li:first-child a');
+
+ $this->waitToLoad('Layouts');
+ $this->byCssSelector('.fa-plus-circle')->click();
+
+ $this->waitToAppearAndClick('#input-name');
+ $this->keys('Cart');
+
+ $this->byCssSelector('.fa-plus-circle')->click();
+
+ $this->byCssSelector('input[name="layout_route[0][route]"]')->click();
+ $this->keys('checkout/cart');
+
+ $this->byCssSelector('.fa-check-circle')->click();
+
+ // Installing the payment button
+ $this->waitToAppearAndClick('#extension a');
+ $this->waitToAppearAndClick('#extension li:nth-child(3) a');
+
+ $i = 1;
+
+ for ( ; ; $i++) {
+ $element = $this->byCssSelector(".table-bordered tbody tr:nth-child($i) td:first-child");
+
+ if ($element->text() == 'PayPal Express Checkout button') {
+ break;
+ }
+ }
+
+ $this->waitToAppearAndClick(".table-bordered tbody tr:nth-child($i) td:last-child a.btn-success");
+ $this->waitToAppearAndClick(".table-bordered tbody tr:nth-child($i) td:last-child a.btn-primary");
+
+ $this->waitToLoad('PayPal Express Checkout button');
+ $this->byCssSelector('.fa-plus-circle')->click();
+
+ for ($i = 1; ; $i++) {
+ $element = $this->byCssSelector("select[name=\"pp_button_module[0][layout_id]\"] option:nth-child($i)");
+
+ if ($element->text() == 'Cart') {
+ $element->click();
+ break;
+ }
+ }
+
+ $this->byCssSelector('button[title="Save"]')->click();
+ }
+ }
+
+ public function testOneProduct() {
+ $this->url('index.php?route=product/product&product_id=43');
+ $this->clickOnElement('button-cart');
+
+ $this->url('index.php?route=checkout/cart');
+ $this->waitToLoad('Shopping Cart');
+
+ $this->byCssSelector('.pp-express-button')->click();
+
+ $this->waitToLoad("Pay with a PayPal", 30000);
+
+ $this->clickOnElement('login_email');
+ $this->keys(PP_EXPRESS_USERNAME);
+
+ $this->clickOnElement('login_password');
+ $this->keys(PP_EXPRESS_PASSWORD);
+
+ $this->clickOnElement('submitLogin');
+
+ $this->waitToLoad("Review your information", 30000);
+
+ $this->clickOnElement('continue_abovefold');
+
+ $this->waitToLoad("Confirm order", 30000);
+
+ $this->byCssSelector('.pull-right .btn-primary')->click();
+
+ $this->waitToLoad("Your order has been placed!");
+
+ $element = $this->byCssSelector('#content h1');
+
+ $this->assertEquals('Your order has been placed!', $element->text());
+ }
+
+}
diff --git a/tests/phpunit/selenium/openbay/SetupTest.php b/tests/phpunit/selenium/openbay/SetupTest.php
new file mode 100644
index 0000000..831a891
--- /dev/null
+++ b/tests/phpunit/selenium/openbay/SetupTest.php
@@ -0,0 +1,91 @@
+<?php
+class OpenbaySetupTest extends OpenCartSeleniumTest {
+ private $moduleInstalled = false;
+
+ /**
+ * @before
+ */
+ protected function before() {
+ $this->setBrowser('firefox');
+ $this->setBrowserUrl(HTTP_SERVER);
+ }
+
+ /**
+ * @after
+ */
+ protected function completeTest() {
+
+ }
+
+ public function testSetup() {
+ if ($this->moduleInstalled === false) {
+ $this->url("admin/");
+
+ $this->byCssSelector('input[name="username"]')->click();
+ $this->keys(ADMIN_USERNAME);
+
+ $this->byCssSelector('input[name="password"]')->click();
+ $this->keys(ADMIN_PASSWORD);
+
+ $this->byCssSelector('button[type="submit"]')->click();
+
+ $this->moduleInstalled = true;
+
+ $this->waitToLoad('Dashboard');
+
+ // Installing the payment module
+ $this->clickOnElement('button-menu');
+
+ $this->waitToAppearAndClick('#extension a');
+ $this->waitToAppearAndClick('#extension li:nth-child(3) a');
+
+ $this->waitToLoad('Modules');
+
+ $i = 1;
+
+ for ( ; ; $i++) {
+ $element = $this->byCssSelector(".table-striped tbody tr:nth-child($i) td:first-child");
+
+ if ($element->text() == 'OpenBay Pro') {
+ break;
+ }
+ }
+
+ $this->waitToAppearAndClick(".table-striped tbody tr:nth-child($i) td:last-child a.btn-success");
+
+ $this->waitToLoad('Modules', 50000);
+
+ // Go to the OpenBay Pro dashboard
+ $this->waitToAppearAndClick('#extension li:nth-child(8) a');
+ $this->waitToAppearAndClick('#extension li:nth-child(8) li:first-child a');
+
+ $this->waitToLoad('OpenBay Pro', 50000);
+
+ $this->byCssSelector('#button-install-ebay')->click();
+
+ $this->waitToLoad('OpenBay Pro', 50000);
+
+ $this->byCssSelector('#button-edit-ebay')->click();
+
+ $this->waitToLoad('Dashboard', 50000);
+
+ $this->byCssSelector('#settings-link')->click();
+
+ $this->waitToLoad('Marketplace settings', 50000);
+
+ $this->byCssSelector('#ebay-status option[value="1"]')->click();
+
+ $this->clickOnElement('ebay-token');
+ $this->keys(OPENBAY_EBAY_TOKEN);
+
+ $this->clickOnElement('ebay-secret');
+ $this->keys(OPENBAY_EBAY_SECRET);
+
+ $this->byCssSelector('button[type="submit"]')->click();
+ }
+ }
+
+ public function installEbay() {
+
+ }
+}