/**
  * Assert that success save message is appeared on the Integrations page
  *
  * @param IntegrationIndex $integrationIndexPage
  * @param Integration $integration
  * @param Integration|null $initialIntegration
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndexPage, Integration $integration, Integration $initialIntegration = null)
 {
     $name = $initialIntegration !== null && !$integration->hasData('name') ? $initialIntegration->getName() : $integration->getName();
     $expectedMessage = sprintf(self::SUCCESS_SAVE_MESSAGE, $name);
     $actualMessage = $integrationIndexPage->getMessagesBlock()->getSuccessMessage();
     \PHPUnit_Framework_Assert::assertEquals($expectedMessage, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . $expectedMessage . "\nActual: " . $actualMessage);
 }
Ejemplo n.º 2
0
 /**
  * Create Integration Entity test.
  *
  * @param Integration $integration
  * @return void
  */
 public function test(Integration $integration)
 {
     // Steps
     $this->integrationIndexPage->open();
     $this->integrationIndexPage->getGridPageActions()->addNew();
     $this->integrationNewPage->getIntegrationForm()->fill($integration);
     $this->integrationNewPage->getFormPageActions()->saveNew();
 }
 /**
  * Assert that pop-up with resources, that were specified for integration are shown
  * after starting activation of integration
  *
  * @param IntegrationIndex $integrationIndex
  * @param Integration $integration
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndex, Integration $integration)
 {
     $fixtureResources = is_array($integration->getResources()) ? $integration->getResources() : [$integration->getResources()];
     $formResources = $integrationIndex->getIntegrationGrid()->getResourcesPopup()->getData();
     $result = $this->verifyResources($formResources['resources'], $fixtureResources);
     \PHPUnit_Framework_Assert::assertEmpty($result, "Integration resources is not correct.\nLog:\n" . $result);
     $integrationIndex->getIntegrationGrid()->getResourcesPopup()->clickAllowButton();
 }
 /**
  * Activate Integration Entity Test.
  *
  * @param Integration $integration
  * @return void
  */
 public function test(Integration $integration)
 {
     // Preconditions
     $integration->persist();
     // Steps
     $filter = ['name' => $integration->getName()];
     $this->integrationIndexPage->open();
     $this->integrationIndexPage->getIntegrationGrid()->searchAndActivate($filter);
 }
 /**
  * Assert that Access tokens was changed correctly after Reauthorize.
  * Checking fields:
  * - Consumer Key;
  * - Consumer Secret;
  * - Access Token;
  * - Access Token Secret.
  *
  * @param IntegrationIndex $integrationIndex
  * @param IntegrationNew $integrationNew
  * @param Integration $integration
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndex, IntegrationNew $integrationNew, Integration $integration)
 {
     $filter = ['name' => $integration->getName()];
     $integrationIndex->open();
     $integrationIndex->getIntegrationGrid()->searchAndOpen($filter);
     $actualData = $integrationNew->getIntegrationForm()->getData();
     $errors = $this->checkTokens($actualData, $integration->getData());
     \PHPUnit_Framework_Assert::assertEmpty($errors, "Integration tokens was changed incorrectly.\nLog:\n" . implode(";\n", $errors));
 }
 /**
  * Assert that integration form filled correctly
  *
  * @param IntegrationIndex $integrationIndexPage
  * @param IntegrationNew $integrationNewPage
  * @param Integration $integration
  * @param Integration|null $initialIntegration
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndexPage, IntegrationNew $integrationNewPage, Integration $integration, Integration $initialIntegration = null)
 {
     $data = $initialIntegration === null ? $integration->getData() : array_merge($initialIntegration->getData(), $integration->getData());
     $filter = ['name' => $data['name']];
     $integrationIndexPage->open();
     $integrationIndexPage->getIntegrationGrid()->searchAndOpen($filter);
     $formData = $integrationNewPage->getIntegrationForm()->getData();
     $dataDiff = $this->verifyForm($formData, $data);
     \PHPUnit_Framework_Assert::assertEmpty($dataDiff, 'Integration form was filled incorrectly.' . "\nLog:\n" . implode(";\n", $dataDiff));
 }
 /**
  * Create Integration Entity with existing name test.
  *
  * @param Integration $integration
  * @return array
  */
 public function test(Integration $integration)
 {
     // Precondition
     $integration->persist();
     // Steps
     $this->integrationIndexPage->open();
     $this->integrationIndexPage->getGridPageActions()->addNew();
     $this->integrationNewPage->getIntegrationForm()->fill($integration);
     $this->integrationNewPage->getFormPageActions()->saveNew();
     return ['integration' => $integration];
 }
 /**
  * Update Integration Entity test.
  *
  * @param Integration $initialIntegration
  * @param Integration $integration
  * @return void
  */
 public function test(Integration $initialIntegration, Integration $integration)
 {
     // Precondition
     $initialIntegration->persist();
     // Steps
     $filter = ['name' => $initialIntegration->getName()];
     $this->integrationIndexPage->open();
     $this->integrationIndexPage->getIntegrationGrid()->searchAndOpen($filter);
     $this->integrationNewPage->getIntegrationForm()->fill($integration);
     $this->integrationNewPage->getFormPageActions()->save();
 }
 /**
  * Assert that there is no integration's been saved message.
  *
  * @param IntegrationIndex $integrationIndex
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndex)
 {
     $noSuccessMessage = false;
     if ($integrationIndex->getMessagesBlock()->isVisible()) {
         try {
             $integrationIndex->getMessagesBlock()->getSuccessMessages();
         } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
             $noSuccessMessage = true;
         }
     } else {
         $noSuccessMessage = true;
     }
     \PHPUnit_Framework_Assert::assertTrue($noSuccessMessage, 'Integration is not saved.');
 }
 /**
  * Assert that pop-up with tokens is shown after clicking on "Allow" button on Resources popup.
  * It contains:
  * - Consumer Key;
  * - Consumer Secret;
  * - Access Token;
  * - Access Token Secret;
  * All fields contain generated values.
  *
  * @param IntegrationIndex $integrationIndex
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndex)
 {
     $errors = [];
     $tokensData = $integrationIndex->getIntegrationGrid()->getTokensPopup()->getData();
     $tokensKeys = array_keys($tokensData);
     $diff = array_diff($this->fields, $tokensKeys);
     if (!empty($diff)) {
         $errors[] = 'Field(s) "' . implode(', ', $diff) . '" is absent in integration tokens.';
     }
     foreach ($tokensData as $key => $value) {
         if (empty($value)) {
             $errors[] = 'Field with key: ' . $key . '" is empty in integration tokens.';
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, "Integration tokens is not correct.\nLog:\n" . implode(";\n", $errors));
     $integrationIndex->getIntegrationGrid()->getTokensPopup()->clickDoneButton();
 }
 /**
  * Test for Reauthorize tokens for the Integration Entity.
  *
  * @param Integration $integration
  * @return array
  */
 public function test(Integration $integration)
 {
     // Precondition
     $integration->persist();
     $filter = ['name' => $integration->getName()];
     $this->integrationIndex->open();
     $this->integrationIndex->getIntegrationGrid()->searchAndActivate($filter);
     $this->integrationIndex->getIntegrationGrid()->getResourcesPopup()->clickAllowButton();
     $tokens = $this->integrationIndex->getIntegrationGrid()->getTokensPopup()->getData();
     $this->integrationIndex->getIntegrationGrid()->getTokensPopup()->clickDoneButton();
     $integration = $this->fixtureFactory->createByCode('integration', ['data' => array_merge($integration->getData(), $tokens)]);
     // Steps
     $this->integrationIndex->getIntegrationGrid()->searchAndReauthorize($filter);
     $this->integrationIndex->getIntegrationGrid()->getResourcesPopup()->clickReauthorizeButton();
     $this->integrationIndex->getIntegrationGrid()->getTokensPopup()->clickDoneButton();
     return ['integration' => $integration];
 }
 /**
  * Run Lock user when creating new integration test.
  *
  * @param Integration $integration
  * @param int $attempts
  * @param User $customAdmin
  * @param string $configData
  * @return void
  */
 public function test(Integration $integration, $attempts, User $customAdmin, $configData = null)
 {
     $this->configData = $configData;
     // Preconditions
     $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $this->configData])->run();
     $customAdmin->persist();
     $this->adminAuthLogin->open();
     $this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
     $this->adminAuthLogin->getLoginBlock()->submit();
     // Steps
     $this->integrationIndexPage->open();
     $this->integrationIndexPage->getGridPageActions()->addNew();
     for ($i = 0; $i < $attempts; $i++) {
         $this->integrationNewPage->getIntegrationForm()->fill($integration);
         $this->integrationNewPage->getFormPageActions()->saveNew();
     }
     // Reload page
     $this->adminAuthLogin->open();
     $this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
     $this->adminAuthLogin->getLoginBlock()->submit();
 }
 /**
  * Assert that success delete message is appeared on the Integrations page
  *
  * @param IntegrationIndex $integrationIndexPage
  * @param Integration $integration
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndexPage, Integration $integration)
 {
     $expectedMessage = sprintf(self::SUCCESS_DELETE_MESSAGE, $integration->getName());
     $actualMessage = $integrationIndexPage->getMessagesBlock()->getSuccessMessages();
     \PHPUnit_Framework_Assert::assertEquals($expectedMessage, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . $expectedMessage . "\nActual: " . $actualMessage);
 }
 /**
  * Assert that an error message is displayed on the Integration page in case current user password is incorrect.
  *
  * @param IntegrationIndex $integrationIndexPage
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndexPage)
 {
     $actualMessage = $integrationIndexPage->getMessagesBlock()->getErrorMessage();
     \PHPUnit_Framework_Assert::assertEquals(self::ERROR_MESSAGE, $actualMessage, 'Wrong error message is displayed.' . "\nExpected: " . self::ERROR_MESSAGE . "\nActual: " . $actualMessage);
 }
 /**
  * Assert error message is displayed in message block.
  *
  * @param IntegrationIndex $integrationIndexPage
  * @param Integration $integration
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndexPage, Integration $integration)
 {
     $expectedMessage = sprintf(self::ERROR_DUPLICATE_INTEGRATION_NAME, $integration->getName());
     $actualMessage = $integrationIndexPage->getMessagesBlock()->getErrorMessages();
     \PHPUnit_Framework_Assert::assertEquals($expectedMessage, $actualMessage, 'Wrong error message is displayed.' . "\nExpected: " . $expectedMessage . "\nActual: " . $actualMessage);
 }
 /**
  * Assert that Integration is not presented in grid and cannot be found using name
  *
  * @param IntegrationIndex $integrationIndexPage
  * @param Integration $integration
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndexPage, Integration $integration)
 {
     $filter = ['name' => $integration->getName()];
     $integrationIndexPage->open();
     \PHPUnit_Framework_Assert::assertFalse($integrationIndexPage->getIntegrationGrid()->isRowVisible($filter), 'Integration \'' . $filter['name'] . '\' is present in Integration grid.');
 }
 /**
  * Assert that success reauthorize message is appeared on the Integrations page.
  *
  * @param IntegrationIndex $integrationIndexPage
  * @param Integration $integration
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndexPage, Integration $integration)
 {
     \PHPUnit_Framework_Assert::assertEquals(sprintf(self::SUCCESS_REAUTHORIZE_MESSAGE, $integration->getName()), $integrationIndexPage->getMessagesBlock()->getSuccessMessage(), "Wrong success message is displayed.");
 }
 /**
  * Assert that data in grid on Integrations page according to fixture by name field
  *
  * @param IntegrationIndex $integrationIndexPage
  * @param Integration $integration
  * @param Integration|null $initialIntegration
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndexPage, Integration $integration, Integration $initialIntegration = null)
 {
     $filter = ['name' => $initialIntegration !== null && !$integration->hasData('name') ? $initialIntegration->getName() : $integration->getName()];
     $integrationIndexPage->open();
     \PHPUnit_Framework_Assert::assertTrue($integrationIndexPage->getIntegrationGrid()->isRowVisible($filter), 'Integration \'' . $filter['name'] . '\' is absent in Integration grid.');
 }