作者:andrewhowdenco
项目:m2onk8
/**
* Create customer
*
* @return array
*/
public function run()
{
if ($this->persistCustomer) {
$this->customer->persist();
}
return ['customer' => $this->customer];
}
作者:whoopl
项目:magento2-testin
/**
* Mass assign customer group
*
* @param Customer $customer
* @param CustomerGroup $customerGroup
* @return void
*/
public function test(Customer $customer, CustomerGroup $customerGroup)
{
// Steps
$customerGroup->persist();
$this->customerIndex->open();
$this->customerIndex->getCustomerGridBlock()->massaction([['email' => $customer->getEmail()]], [$this->customersGridActions => $customerGroup->getCustomerGroupCode()]);
}
作者:hientruong9
项目:magento2_installe
/**
* Assertion that tier prices are displayed correctly for specified customer
*
* @param BrowserInterface $browser
* @param CatalogProductView $catalogProductView
* @param FixtureInterface $product
* @param Customer $customer
* @return void
*/
public function processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, FixtureInterface $product, Customer $customer)
{
$customer->persist();
$this->loginCustomer($customer);
$productTierPriceAssert = $this->objectManager->get('Magento\\Catalog\\Test\\Constraint\\AssertProductTierPriceOnProductPage');
$productTierPriceAssert->processAssert($browser, $catalogProductView, $product);
}
作者:pradeep-wagent
项目:magento
/**
* Create customer.
*
* @param Customer $customer
* @param CustomerAccountForgotPassword $forgotPassword
* @return void
*/
public function test(Customer $customer, CustomerAccountForgotPassword $forgotPassword)
{
// Precondition
$customer->persist();
// Steps
$forgotPassword->open();
$forgotPassword->getForgotPasswordForm()->resetForgotPassword($customer);
}
作者:pradeep-wagent
项目:magento
/**
* Prepare VAT ID confguration.
*
* @param ConfigData $vatConfig
* @param string $customerGroup
* @return void
*/
protected function prepareVatConfig(ConfigData $vatConfig, $customerGroup)
{
$groupConfig = ['customer/create_account/viv_domestic_group' => ['value' => $this->vatGroups['valid_domestic_group']->getCustomerGroupId()], 'customer/create_account/viv_intra_union_group' => ['value' => $this->vatGroups['valid_intra_union_group']->getCustomerGroupId()], 'customer/create_account/viv_invalid_group' => ['value' => $this->vatGroups['invalid_group']->getCustomerGroupId()], 'customer/create_account/viv_error_group' => ['value' => $this->vatGroups['error_group']->getCustomerGroupId()]];
$vatConfig = $this->fixtureFactory->createByCode('configData', ['data' => array_replace_recursive($vatConfig->getSection(), $groupConfig)]);
$vatConfig->persist();
$customerData = array_merge($this->customer->getData(), ['group_id' => ['value' => $this->vatGroups[$customerGroup]->getCustomerGroupCode()]], ['address' => ['addresses' => $this->customer->getDataFieldConfig('address')['source']->getAddresses()]]);
$this->customer = $this->fixtureFactory->createByCode('customer', ['data' => $customerData]);
}
作者:Doabilit
项目:magento2de
/**
* Run reset customer password failed test.
* @param Customer $customer
* @param int $attempts
* @return void
*/
public function test(Customer $customer, $attempts)
{
// Steps
$customer->persist();
for ($i = 0; $i < $attempts; $i++) {
$this->forgotPassword->open();
$this->forgotPassword->getForgotPasswordForm()->resetForgotPassword($customer);
}
}
作者:shabbirvividad
项目:magento
/**
* Injection data
*
* @param CustomerAccountCreate $customerAccountCreate
* @param CustomerAccountLogout $customerAccountLogout
* @param CmsIndex $cmsIndex
* @param Customer $customer
* @return array
*/
public function __inject(CustomerAccountCreate $customerAccountCreate, CustomerAccountLogout $customerAccountLogout, CmsIndex $cmsIndex, Customer $customer)
{
$this->customerAccountLogout = $customerAccountLogout;
$this->customerAccountCreate = $customerAccountCreate;
$this->cmsIndex = $cmsIndex;
//Precondition
$customer->persist();
return ['customer' => $customer];
}
作者:andrewhowdenco
项目:m2onk8
/**
* Select customer if it is present in fixture or click create new customer button.
*
* @param CustomerFixture $customer
* @return void
*/
public function selectCustomer(CustomerFixture $customer)
{
if ($customer->hasData('id')) {
$this->searchAndOpen(['email' => $customer->getEmail()]);
} else {
$this->_rootElement->find($this->createNewCustomer)->click();
}
$this->getTemplateBlock()->waitLoader();
}
作者:kidaa3
项目:magento2-platforms
/**
* 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.");
}
作者:kidaa3
项目:magento2-platforms
/**
* Create customer on backend.
*
* @param Customer $customer
* @return void
*/
public function test(Customer $customer)
{
// Precondition
$customer->persist();
// Steps
$this->pageCustomerIndex->open();
$this->pageCustomerIndex->getPageActionsBlock()->addNew();
$this->pageCustomerIndexNew->getCustomerForm()->fillCustomer($customer);
$this->pageCustomerIndexNew->getPageActionsBlock()->save();
}
作者:kidaa3
项目:magento2-platforms
/**
* Create customer with customer group and apply customer group to catalog price rule.
*
* @param CatalogRule $catalogPriceRule
* @param Customer|null $customer
* @return CustomerGroup
*/
public function applyCustomerGroup(CatalogRule $catalogPriceRule, Customer $customer = null)
{
if ($customer !== null) {
$customer->persist();
/** @var \Magento\Customer\Test\Fixture\CustomerGroup $customerGroup */
$customerGroup = $customer->getDataFieldConfig('group_id')['source']->getCustomerGroup();
$catalogPriceRule = $this->fixtureFactory->createByCode('catalogRule', ['data' => array_merge($catalogPriceRule->getData(), ['customer_group_ids' => $customerGroup->getCustomerGroupCode()])]);
}
return $catalogPriceRule;
}
作者:niranjanssie
项目:magento
/**
* New Accounts Report.
*
* @param Customer $customer
* @param array $customersReport
* @return void
*/
public function test(Customer $customer, array $customersReport)
{
// Preconditions
$this->customerIndexPage->open();
$this->customerIndexPage->getCustomerGridBlock()->massaction([], 'Delete', true, 'Select All');
$customer->persist();
// Steps
$this->customerAccounts->open();
$this->customerAccounts->getGridBlock()->searchAccounts($customersReport);
}
作者:shabbirvividad
项目:magento
/**
* Runs Delete Customer Backend Entity test
*
* @param Customer $customer
* @return void
*/
public function testDeleteCustomerBackendEntity(Customer $customer)
{
// Preconditions:
$customer->persist();
// Steps:
$filter = ['email' => $customer->getEmail()];
$this->customerIndexPage->open();
$this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter);
$this->customerIndexEditPage->getPageActionsBlock()->delete();
}
作者:kidaa3
项目:magento2-platforms
/**
* Create product and add it to cart.
*
* @param string $products
* @param Customer $customer
* @return array
*/
public function test($products, Customer $customer)
{
// Precondition
$products = $this->createProducts($products);
$customer->persist();
$this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
$this->addProductsToCart($products);
$this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LogoutCustomerOnFrontendStep', ['customer' => $customer])->run();
return ['products' => $products];
}
作者:pradeep-wagent
项目:magento
/**
* Create Existing Customer account on frontend.
*
* @param Customer $customer
* @return void
*/
public function testCreateExistingCustomer(Customer $customer)
{
// Precondition
$existingCustomer = clone $customer;
$customer->persist();
// Steps
$this->cmsIndex->open();
$this->cmsIndex->getLinksBlock()->openLink('Create an Account');
$this->customerAccountCreate->getRegisterForm()->registerCustomer($existingCustomer);
}
作者:andrewhowdenco
项目:m2onk8
/**
* 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();
}
作者:Doabilit
项目:magento2de
/**
* Fill customer addresses and proceed to next step.
*
* @return void
*/
public function run()
{
$addresses = $this->customer->getDataFieldConfig('address')['source']->getAddresses();
$bindings = [];
foreach ($this->products as $key => $product) {
$productName = $product->getName();
$addressRender = $this->objectManager->create(\Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $addresses[$key], 'type' => 'oneline']);
$bindings[$productName] = $addressRender->render();
}
$this->addresses->getAddressesBlock()->selectAddresses($bindings);
}
作者:kidaa3
项目:magento2-platforms
/**
* Assert that deleted customers address is not displayed on backend during order creation
*
* @param OrderIndex $orderIndex
* @param OrderCreateIndex $orderCreateIndex
* @param Address $deletedAddress
* @param Customer $customer
* @return void
*/
public function processAssert(OrderIndex $orderIndex, OrderCreateIndex $orderCreateIndex, Address $deletedAddress, Customer $customer)
{
$filter = ['email' => $customer->getEmail()];
$orderIndex->open()->getGridPageActions()->addNew();
$orderCreateIndex->getCustomerBlock()->searchAndOpen($filter);
$orderCreateIndex->getStoreBlock()->selectStoreView();
$actualAddresses = $orderCreateIndex->getCreateBlock()->getBillingAddressBlock()->getExistingAddresses();
$addressRenderer = $this->objectManager->create('Magento\\Customer\\Test\\Block\\Address\\Renderer', ['address' => $deletedAddress]);
$addressToSearch = $addressRenderer->render();
\PHPUnit_Framework_Assert::assertFalse(in_array($addressToSearch, $actualAddresses), 'Deleted address is present on backend during order creation');
}
作者:kidaa3
项目:magento2-platforms
/**
* Get all error validation messages for fields.
*
* @param Customer $customer
* @return array
*/
public function getValidationMessages(Customer $customer)
{
$messages = [];
foreach (array_keys($customer->getData()) as $field) {
$element = $this->_rootElement->find(sprintf($this->validationText, str_replace('_', '-', $field)));
if ($element->isVisible()) {
$messages[$field] = $element->getText();
}
}
return $messages;
}
作者:andrewhowdenco
项目:m2onk8
/**
* Runs Delete Customer Address test.
*
* @param Customer $customer
* @return array
*/
public function test(Customer $customer)
{
// Precondition:
$customer->persist();
$addressToDelete = $customer->getDataFieldConfig('address')['source']->getAddresses()[1];
// Steps:
$this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
$this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
$this->customerAccountIndex->getAdditionalAddressBlock()->deleteAdditionalAddress($addressToDelete);
return ['deletedAddress' => $addressToDelete];
}