<?php
namespace Magento\AcceptanceTest\_default\Backend;

use Magento\FunctionalTestingFramework\AcceptanceTester;
use \Codeception\Util\Locator;
use Yandex\Allure\Adapter\Annotation\Features;
use Yandex\Allure\Adapter\Annotation\Stories;
use Yandex\Allure\Adapter\Annotation\Title;
use Yandex\Allure\Adapter\Annotation\Description;
use Yandex\Allure\Adapter\Annotation\Parameter;
use Yandex\Allure\Adapter\Annotation\Severity;
use Yandex\Allure\Adapter\Model\SeverityLevel;
use Yandex\Allure\Adapter\Annotation\TestCaseId;

/**
 * @Description("<h3>Test files</h3>verification/TestModule/Test/ParameterArrayTest.xml<br>")
 */
class ParameterArrayTestCest
{
	/**
	 * @var bool
	 */
	private $isSuccess = false;

	/**
	  * @param AcceptanceTester $I
	  * @throws \Exception
	  */
	public function _after(AcceptanceTester $I)
	{
		if ($this->isSuccess) {
			unlink(__FILE__);
		}
	}

	/**
	 * @Features({"TestModule"})
	 * @param AcceptanceTester $I
	 * @return void
	 * @throws \Exception
	 */
	public function ParameterArrayTest(AcceptanceTester $I)
	{
		$I->createEntity("simpleDataKey", "test", "simpleParamData", [], []); // stepKey: simpleDataKey
		$I->searchAndMultiSelectOption("#selector", ["name"]); // stepKey: xmlSimpleReplace
		$I->searchAndMultiSelectOption("#selector", [msq("simpleParamData") . "prename"]); // stepKey: xmlPrefix
		$I->searchAndMultiSelectOption("#selector", ["postname" . msq("simpleParamData")]); // stepKey: xmlSuffix
		$I->searchAndMultiSelectOption("#selector", [$I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: persistSimple
		$I->searchAndMultiSelectOption("#selector", ["name", $I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: persistXmlSimple
		$I->searchAndMultiSelectOption("#selector", ['someKey' => $I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: literalKeyToPersist
		$I->searchAndMultiSelectOption("#selector", ['someKey' => "name"]); // stepKey: literalKeyToStatic
		$I->searchAndMultiSelectOption("#selector", ['someKey' => msq("simpleParamData") . "prename"]); // stepKey: literalKeyToPrefixUnique
		$I->searchAndMultiSelectOption("#selector", ['someKey' => "postname" . msq("simpleParamData")]); // stepKey: literalKeyToSuffixUnique
		$I->unselectOption("#selector", ['foo']); // stepKey: 000
		$I->unselectOption("#selector", ['foo', 'bar']); // stepKey: 001
		$I->unselectOption("#selector", ["name"]); // stepKey: 002
		$I->unselectOption("#selector", [msq("simpleParamData") . "prename"]); // stepKey: 003
		$I->unselectOption("#selector", ["postname" . msq("simpleParamData")]); // stepKey: 004
		$I->unselectOption("#selector", [$I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: 005
		$I->unselectOption("#selector", ["name", $I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: 006
		$I->pressKey("#selector", $I->retrieveEntityField('simpleDataKey', 'name', 'test'), ['ctrl',  'a'],\Facebook\WebDriver\WebDriverKeys::DELETE,$I->retrieveEntityField('simpleDataKey', 'name', 'test')); // stepKey: pressKey001
		$I->pressKey("#selector", ['ctrl',  'a'], 10, 20,\Facebook\WebDriver\WebDriverKeys::DELETE,$I->retrieveEntityField('simpleDataKey', 'name', 'test')); // stepKey: pressKey002
		$I->pressKey("#selector", ['ctrl',  'a'],'new', 10, 20,\Facebook\WebDriver\WebDriverKeys::DELETE,$I->retrieveEntityField('simpleDataKey', 'name', 'test')); // stepKey: pressKey003
		$I->pressKey("#selector", ['ctrl', 'a'],'new', 1, ['ctrl'], ['shift',  'ctrl',  'del'], [$I->retrieveEntityField('simpleDataKey', 'name', 'test'),  'a', "name"]); // stepKey: pressKey004
		$I->pressKey("#selector", ['ctrl', 'a'],'new', 1, ['ctrl'], ['shift',  'ctrl',  'del'], 0, [$I->retrieveEntityField('simpleDataKey', 'name', 'test'), $I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: pressKey005
		$I->pressKey("#selector", ['ctrl', 'a'],'new', 1, ['ctrl'], ['shift',  'ctrl',  'del'], [msq("simpleParamData") . "prename", "postname" . msq("simpleParamData")]); // stepKey: pressKey006
	}

	public function _passed(AcceptanceTester $I)
	{
		// Test passed successfully.
		$this->isSuccess = true;
	}
}
