aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/selenium/openbay/SetupTest.php
blob: 831a8910eabc714b6b2be240f44f6ef63aa002fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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() {

	}
}