/** * Assert that data at the form corresponds to the fixture data * * @param SystemVariable $customVariable * @param SystemVariableIndex $systemVariableIndex * @param SystemVariableNew $systemVariableNew * @param Store $storeOrigin * @param SystemVariable $customVariableOrigin * @return void * * @SuppressWarnings(PHPMD.NPathComplexity) */ public function processAssert(SystemVariable $customVariable, SystemVariableIndex $systemVariableIndex, SystemVariableNew $systemVariableNew, Store $storeOrigin = null, SystemVariable $customVariableOrigin = null) { // Prepare data $data = $customVariableOrigin === null ? $customVariable->getData() : array_merge($customVariableOrigin->getData(), $customVariable->getData()); if ($customVariableOrigin !== null) { $dataOrigin = $data; $dataOrigin['html_value'] = $customVariableOrigin->getHtmlValue(); $dataOrigin['plain_value'] = $customVariableOrigin->getPlainValue(); } else { $dataOrigin = $data; } if ($data['html_value'] == '') { $data['html_value'] = $customVariableOrigin->getHtmlValue(); $data['use_default_value'] = 'Yes'; } $data['plain_value'] = $data['plain_value'] == '' ? $customVariableOrigin->getPlainValue() : $data['plain_value']; // Perform assert $systemVariableIndex->open(); $systemVariableIndex->getSystemVariableGrid()->searchAndOpen(['code' => $data['code']]); $formData = $systemVariableNew->getSystemVariableForm()->getData($customVariable); $errors = $this->verifyData($dataOrigin, $formData); \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); if ($storeOrigin !== null) { $systemVariableNew->getFormPageActions()->selectStoreView($storeOrigin->getName()); $formData = $systemVariableNew->getSystemVariableForm()->getData($customVariable); $errors = $this->verifyData($data, $formData); \PHPUnit_Framework_Assert::assertEmpty($errors, $errors); } }
/** * Delete Custom System Variable Entity test * * @param SystemVariable $customVariable * @return void */ public function test(SystemVariable $customVariable) { // Steps $this->systemVariableIndexPage->open(); $this->systemVariableIndexPage->getGridPageActions()->addNew(); $this->systemVariableNewPage->getSystemVariableForm()->fill($customVariable); $this->systemVariableNewPage->getFormPageActions()->save(); }
/** * Delete Custom System Variable Entity test * * @param SystemVariable $systemVariable * @return void */ public function test(SystemVariable $systemVariable) { // Precondition $systemVariable->persist(); // Steps $filter = ['code' => $systemVariable->getCode(), 'name' => $systemVariable->getName()]; $this->systemVariableIndexPage->open(); $this->systemVariableIndexPage->getSystemVariableGrid()->searchAndOpen($filter); $this->systemVariableNewPage->getFormPageActions()->delete(); }
/** * Update Custom System Variable Entity test * * @param SystemVariable $customVariable * @param SystemVariable $customVariableOrigin * @param Store $storeOrigin * @param $saveAction * @return void */ public function test(SystemVariable $customVariable, SystemVariable $customVariableOrigin, Store $storeOrigin, $saveAction) { $filter = ['code' => $customVariableOrigin->getCode()]; // Steps $this->systemVariableIndexPage->open(); $this->systemVariableIndexPage->getSystemVariableGrid()->searchAndOpen($filter); $this->systemVariableNewPage->getFormPageActions()->selectStoreView($storeOrigin->getData('name')); $this->systemVariableNewPage->getSystemVariableForm()->fill($customVariable); $this->systemVariableNewPage->getFormPageActions()->{$saveAction}(); }
/** * Assert that success delete message is correct after Custom System Variable deleted * * @param SystemVariableIndex $systemVariableIndexPage * @return void */ public function processAssert(SystemVariableIndex $systemVariableIndexPage) { $actualMessage = $systemVariableIndexPage->getMessagesBlock()->getSuccessMessages(); \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_SAVE_MESSAGE, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . self::SUCCESS_SAVE_MESSAGE . "\nActual: " . $actualMessage); }
/** * Assert custom variable is displayed on backend in custom variable grid * * @param SystemVariableIndex $systemVariableIndexNew * @param SystemVariable $customVariable * @return void */ public function processAssert(SystemVariableIndex $systemVariableIndexNew, SystemVariable $customVariable) { $filter = ['code' => $customVariable->getCode(), 'name' => $customVariable->getName()]; $systemVariableIndexNew->open(); \PHPUnit_Framework_Assert::assertTrue($systemVariableIndexNew->getSystemVariableGrid()->isRowVisible($filter), 'Custom Variable with code \'' . $filter['code'] . '\' is absent in Custom Variable grid.'); }