/** * Assert that products added to wishlist are present on Customers account on backend. * * @param CustomerIndex $customerIndex * @param Customer $customer * @param CustomerIndexEdit $customerIndexEdit * @param InjectableFixture $product * @return void */ public function processAssert(CustomerIndex $customerIndex, Customer $customer, CustomerIndexEdit $customerIndexEdit, InjectableFixture $product) { $customerIndex->open(); $customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); $customerIndexEdit->getCustomerForm()->openTab('wishlist'); /** @var \Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist\Grid $wishlistGrid */ $wishlistGrid = $customerIndexEdit->getCustomerForm()->getTab('wishlist')->getSearchGridBlock(); \PHPUnit_Framework_Assert::assertTrue($wishlistGrid->isRowVisible(['product_name' => $product->getName()]), $product->getName() . " is not visible in customer wishlist on backend."); }
/** * Run update customer test. * * @param Customer $initialCustomer * @param Customer $customer * @param Address $address [optional] * @return void */ public function testUpdateCustomerBackendEntity(Customer $initialCustomer, Customer $customer, Address $address = null) { // Precondition $initialCustomer->persist(); // Steps $filter = ['email' => $initialCustomer->getEmail()]; $this->customerIndexPage->open(); $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter); $this->customerIndexEditPage->getCustomerForm()->updateCustomer($customer, $address); $this->customerIndexEditPage->getPageActionsBlock()->save(); }
/** * @param CustomerInjectable $initialCustomer * @param CustomerInjectable $customer * @param AddressInjectable $address */ public function testUpdateCustomerBackendEntity(CustomerInjectable $initialCustomer, CustomerInjectable $customer, AddressInjectable $address) { // Prepare data $address = $address->hasData() ? $address : null; // Preconditions: $initialCustomer->persist(); // Steps $filter = ['email' => $initialCustomer->getEmail()]; $this->customerIndexPage->open(); $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter); $this->customerIndexEditPage->getCustomerForm()->updateCustomer($customer, $address); $this->customerIndexEditPage->getPageActionsBlock()->save(); }
/** * Asserts all Product Review variables in the reviews grid on customer page * * @param Customer $customer * @param Review $reviewInitial * @param Review $review * @param CustomerIndexEdit $customerIndexEdit * @param CustomerIndex $customerIndex * @param AssertProductReviewInGrid $assertProductReviewInGrid * @return void */ public function processAssert(Customer $customer, Review $reviewInitial, Review $review, CustomerIndexEdit $customerIndexEdit, CustomerIndex $customerIndex, AssertProductReviewInGrid $assertProductReviewInGrid) { /** var CatalogProductSimple $product */ $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); $customerIndex->open(); $customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); $customerIndexEdit->getCustomerForm()->openTab('product_reviews'); $filter = $assertProductReviewInGrid->prepareFilter($product, $this->prepareData($review, $reviewInitial)); /** @var ReviewsGrid $reviewsGrid */ $reviewsGrid = $customerIndexEdit->getCustomerForm()->getTab('product_reviews')->getReviewsGrid(); $reviewsGrid->search($filter); unset($filter['visible_in']); \PHPUnit_Framework_Assert::assertTrue($reviewsGrid->isRowVisible($filter, false), 'Review is absent in Review grid on customer page.'); }
/** * Assert that product is present in grid on customer's wish list tab with configure option and qty * * @param CustomerIndexEdit $customerIndexEdit * @param FixtureInterface $product * @return void */ public function processAssert(CustomerIndexEdit $customerIndexEdit, FixtureInterface $product) { $filter = $this->prepareFilter($product); /** @var Grid $wishlistGrid */ $wishlistGrid = $customerIndexEdit->getCustomerForm()->getTabElement('wishlist')->getSearchGridBlock(); \PHPUnit_Framework_Assert::assertTrue($wishlistGrid->isRowVisible($filter, true, false), 'Product ' . $product->getName() . ' is absent in grid with configure option.'); }
/** * Configure customer wish list on backend. * * @param Customer $customer * @param string $product * @param CustomerIndex $customerIndex * @param CustomerIndexEdit $customerIndexEdit * @return array */ public function test(Customer $customer, $product, CustomerIndex $customerIndex, CustomerIndexEdit $customerIndexEdit) { // Preconditions $product = $this->createProducts($product)[0]; $this->loginCustomer($customer); $this->addToWishlist([$product], true); // Steps $customerIndex->open(); $customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); $customerIndexEdit->getCustomerForm()->openTab('wishlist'); return ['product' => $product]; }
/** * Delete product from customer wishlist on backend * * @param Customer $customer * @param string $product * @param CustomerIndex $customerIndex * @param CustomerIndexEdit $customerIndexEdit * @return array */ public function test(Customer $customer, $product, CustomerIndex $customerIndex, CustomerIndexEdit $customerIndexEdit) { //Preconditions $product = $this->createProducts($product)[0]; $this->loginCustomer($customer); $this->addToWishlist([$product]); //Steps $customerIndex->open(); $customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); $customerForm = $customerIndexEdit->getCustomerForm(); $customerForm->openTab('wishlist'); $filter = ['product_name' => $product->getName()]; $customerForm->getTab('wishlist')->getSearchGridBlock()->searchAndAction($filter, 'Delete'); return ['products' => [$product]]; }
/** * Run update customer test. * * @param Customer $initialCustomer * @param Customer $customer * @param Address|null $address * @param int|null $addressIndexToDelete * @throws \Exception * @return array */ public function testUpdateCustomerBackendEntity(Customer $initialCustomer, Customer $customer, Address $address = null, $addressIndexToDelete = null) { // Precondition $initialCustomer->persist(); $addressToDelete = null; if ($addressIndexToDelete !== null) { $addressToDelete = $initialCustomer->getDataFieldConfig('address')['source']->getAddresses()[$addressIndexToDelete]; } // Steps $filter = ['email' => $initialCustomer->getEmail()]; $this->customerIndexPage->open(); $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter); $this->customerIndexEditPage->getCustomerForm()->updateCustomer($customer, $address, $addressToDelete); $this->customerIndexEditPage->getPageActionsBlock()->save(); return ['customer' => $this->prepareCustomer($customer, $initialCustomer, $address, $addressToDelete), 'addressToDelete' => $addressToDelete]; }
/** * Assert that displayed customer data on edit page(backend) equals passed from fixture. * * @param Customer $customer * @param CustomerIndex $pageCustomerIndex * @param CustomerIndexEdit $pageCustomerIndexEdit * @param Address $address[optional] * @return void */ public function processAssert(Customer $customer, CustomerIndex $pageCustomerIndex, CustomerIndexEdit $pageCustomerIndexEdit, Address $address = null) { $data = []; $filter = []; $data['customer'] = $customer->getData(); if ($address) { $data['addresses'][1] = $address->hasData() ? $address->getData() : []; } else { $data['addresses'] = []; } $filter['email'] = $data['customer']['email']; $pageCustomerIndex->open(); $pageCustomerIndex->getCustomerGridBlock()->searchAndOpen($filter); $dataForm = $pageCustomerIndexEdit->getCustomerForm()->getDataCustomer($customer, $address); $dataDiff = $this->verify($data, $dataForm); \PHPUnit_Framework_Assert::assertTrue(empty($dataDiff), 'Customer data on edit page(backend) not equals to passed from fixture.' . "\nFailed values: " . implode(', ', $dataDiff)); }
/** * Run manage product review test * * @param ReviewInjectable $reviewInitial * @param ReviewInjectable $review * @param CustomerInjectable $customer * @return array */ public function test(ReviewInjectable $reviewInitial, ReviewInjectable $review, CustomerInjectable $customer) { // Preconditions $this->login($customer); /** @var CatalogProductSimple $product */ $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity(); $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $this->catalogProductView->getReviewSummary()->getAddReviewLink()->click(); $this->catalogProductView->getReviewFormBlock()->fill($reviewInitial); $this->catalogProductView->getReviewFormBlock()->submit(); $this->reviewInitial = $reviewInitial; // Steps $this->customerIndex->open(); $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); $this->customerIndexEdit->getCustomerForm()->openTab('product_reviews'); $filter = ['title' => $reviewInitial->getTitle(), 'sku' => $product->getSku()]; $this->customerIndexEdit->getCustomerForm()->getTabElement('product_reviews')->getReviewsGrid()->searchAndOpen($filter); $this->reviewEdit->getReviewForm()->fill($review); $this->reviewEdit->getPageActions()->save(); return ['reviewInitial' => $reviewInitial, 'product' => $product]; }
/** * Delete product from customer wishlist on backend * * @param Browser $browser * @param CustomerInjectable $customer * @param FixtureFactory $fixtureFactory * @param string $product * @return array */ public function test(Browser $browser, CustomerInjectable $customer, FixtureFactory $fixtureFactory, $product) { $this->markTestIncomplete('MAGETWO-27949'); //Preconditions list($fixture, $dataSet) = explode('::', $product); $product = $fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]); $product->persist(); $this->loginCustomer($customer); $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $this->catalogProductView->getViewBlock()->addToWishlist(); //Steps $this->customerIndex->open(); $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); $customerForm = $this->customerIndexEdit->getCustomerForm(); $customerForm->openTab('wishlist'); $filter = ['product_name' => $product->getName()]; $customerForm->getTabElement('wishlist')->getSearchGridBlock()->searchAndDelete($filter); return ['product' => $product]; }