<?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;

/**
 * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/PageReplacementTest.xml<br>")
 */
class PageReplacementTestCest
{
	/**
	 * @Features({"TestModule"})
	 * @Parameter(name = "AcceptanceTester", value="$I")
	 * @param AcceptanceTester $I
	 * @return void
	 * @throws \Exception
	 */
	public function PageReplacementTest(AcceptanceTester $I)
	{
		$I->comment("[datakey] create 'simpleData' entity");
		PersistedObjectHandler::getInstance()->createEntity(
			"datakey",
			"test",
			"simpleData",
			[],
			[]
		);

		$I->amOnPage("/page.html"); // stepKey: noParamPage
		$I->amOnPage("/StringLiteral/page.html"); // stepKey: oneParamPageString
		$I->amOnPage("/John/page.html"); // stepKey: oneParamPageData
		$I->amOnPage("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('datakey', 'firstname', 'test') . "/page.html"); // stepKey: oneParamPagePersist
		$I->amOnPage("/StringLiteral1/StringLiteral2.html"); // stepKey: twoParamPageString
		$I->amOnPage("/John/StringLiteral2.html"); // stepKey: twoParamPageStringData
		$I->amOnPage("/John/" . PersistedObjectHandler::getInstance()->retrieveEntityField('datakey', 'firstname', 'test') . ".html"); // stepKey: twoParamPageDataPersist
		$I->amOnPage("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('datakey', 'firstname', 'test') . "/StringLiteral2.html"); // stepKey: twoParamPagePersistString
		$I->amOnPage("/" . getenv("MAGENTO_BACKEND_NAME") . "/backend"); // stepKey: onAdminPage
		$I->amOnPage("/" . getenv("MAGENTO_BACKEND_NAME") . "/StringLiteral/page.html"); // stepKey: oneParamAdminPageString
		$I->amOnUrl("http://myFullUrl.com/"); // stepKey: onExternalPage
	}
}
