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

use Magento\FunctionalTestingFramework\AcceptanceTester;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;
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;

/**
 */
class LocatorFunctionTestCest
{
	/**
	 * @Features({"TestModule"})
	 * @Parameter(name = "AcceptanceTester", value="$I")
	 * @param AcceptanceTester $I
	 * @return void
	 * @throws \Exception
	 */
	public function LocatorFunctionTest(AcceptanceTester $I)
	{
		$I->amGoingTo("create entity that has the stepKey: data");
		PersistedObjectHandler::getInstance()->createEntity(
			"data",
			"test",
			"ReplacementPerson",
			[],
			null
		);
		$I->click(Locator::contains("'label'", "'Name'"));
		$I->click(Locator::contains("'label'", "'Name'"));
		$I->click(Locator::find("'img'", ['title' => 'diagram']));
		$I->click(Locator::contains("string", "'Name'"));
		$I->click(Locator::contains("John", "'Name'"));
		$I->click(Locator::contains(PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key', 'test'), "'Name'"));
		$I->click(Locator::contains("string1", "string2"));
		$I->click(Locator::contains("John", "Doe"));
		$I->click(Locator::contains(PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key1', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key2', 'test')));
		$I->click(Locator::contains("string1", "John"));
		$I->click(Locator::contains("string1", PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key1', 'test')));
		$I->click(Locator::contains("John", PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key1', 'test')));
	}
}
