本文整理匯總了PHP中Magento\Catalog\Test\Fixture\Category::getName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::getName方法的具體用法?PHP Category::getName怎麽用?PHP Category::getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Catalog\Test\Fixture\Category
的用法示例。
在下文中一共展示了Category::getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: processAssert
/**
* Assert that displayed assigned products on category page equals passed from fixture
*
* @param Category $category
* @param CatalogCategoryView $categoryView
* @param BrowserInterface $browser
* @return void
*/
public function processAssert(Category $category, CatalogCategoryView $categoryView, BrowserInterface $browser)
{
$categoryUrlKey = $category->hasData('url_key') ? strtolower($category->getUrlKey()) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-');
$products = $category->getDataFieldConfig('category_products')['source']->getProducts();
$browser->open($_ENV['app_frontend_url'] . $categoryUrlKey . '.html');
foreach ($products as $productFixture) {
\PHPUnit_Framework_Assert::assertTrue($categoryView->getListProductBlock()->getProductItem($productFixture)->isVisible(), "Products '{$productFixture->getName()}' not found in category '{$category->getName()}'.");
}
}
示例2: processAssert
/**
* Assert that the category is no longer available on the top menu bar
*
* @param CmsIndex $cmsIndex
* @param Category $category
* @param BrowserInterface $browser
* @param CatalogCategoryView $categoryView
* @return void
*/
public function processAssert(CmsIndex $cmsIndex, Category $category, BrowserInterface $browser, CatalogCategoryView $categoryView)
{
$cmsIndex->open();
\PHPUnit_Framework_Assert::assertFalse($cmsIndex->getTopmenu()->isCategoryVisible($category->getName()), 'Category can be accessed from the navigation bar in the frontend.');
$browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html');
\PHPUnit_Framework_Assert::assertEquals($category->getName(), $categoryView->getTitleBlock()->getTitle(), 'Wrong page is displayed.');
if (isset($category->getDataFieldConfig('category_products')['source'])) {
$products = $category->getDataFieldConfig('category_products')['source']->getProducts();
foreach ($products as $productFixture) {
\PHPUnit_Framework_Assert::assertTrue($categoryView->getListProductBlock()->isProductVisible($productFixture->getName()), "Products '{$productFixture->getName()}' not find.");
}
}
}
示例3: processAssert
/**
* Assert that apache redirect works by opening category page and asserting index.php in its url
*
* @param Category $category
* @param CmsIndex $homePage
* @param BrowserInterface $browser
*/
public function processAssert(Category $category, CmsIndex $homePage, BrowserInterface $browser)
{
$category->persist();
$homePage->open();
$homePage->getTopmenu()->selectCategoryByName($category->getName());
\PHPUnit_Framework_Assert::assertTrue(strpos($browser->getUrl(), 'index.php') === false, 'Apache redirect for category does not work.');
}
示例4: processAssert
/**
* Assert that the category cannot be accessed from the navigation bar in the frontend
*
* @param CmsIndex $cmsIndex
* @param Category $category
* @param BrowserInterface $browser
* @return void
*/
public function processAssert(CmsIndex $cmsIndex, Category $category, BrowserInterface $browser)
{
$cmsIndex->open();
\PHPUnit_Framework_Assert::assertFalse($cmsIndex->getTopmenu()->isCategoryVisible($category->getName()), 'Category can be accessed from the navigation bar in the frontend.');
$browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html');
\PHPUnit_Framework_Assert::assertEquals(self::NOT_FOUND_MESSAGE, $cmsIndex->getTitleBlock()->getTitle(), 'Wrong page is displayed.');
}
示例5: checkRecentlyViewedBlockOnCategory
/**
* Check that block Recently Viewed contains product on category page
*
* @param CatalogProductSimple $productSimple
* @param Category $category
* @return void
*/
protected function checkRecentlyViewedBlockOnCategory(CatalogProductSimple $productSimple, Category $category)
{
$this->cmsIndex->open();
$this->cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
$products = $this->catalogCategoryView->getViewBlock()->getProductsFromRecentlyViewedBlock();
\PHPUnit_Framework_Assert::assertTrue(in_array($productSimple->getName(), $products), 'Product' . $productSimple->getName() . ' is absent on Recently Viewed block on Category page.');
}
示例6: isNotDisplayingOnFrontendAssert
/**
* Verify product displaying on frontend
*
* @param FixtureInterface $product
* @return array
*/
protected function isNotDisplayingOnFrontendAssert(FixtureInterface $product)
{
$errors = [];
// Check the product page is not available
// TODO fix initialization url for frontend page
$this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$titleBlock = $this->catalogProductView->getTitleBlock();
if ($titleBlock->getTitle() !== self::NOT_FOUND_MESSAGE) {
$errors[] = '- the headline on the page does not match, the text should be -> "' . self::NOT_FOUND_MESSAGE . '".';
}
$this->cmsIndex->open();
$this->cmsIndex->getSearchBlock()->search($product->getSku());
if ($this->catalogSearchResult->getListProductBlock()->isProductVisible($product->getName())) {
$errors[] = '- successful product search.';
}
$categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0] : $this->category->getName();
$this->cmsIndex->open();
$this->cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
$isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
while (!$isProductVisible && $this->catalogCategoryView->getBottomToolbar()->nextPage()) {
$isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
}
if ($isProductVisible) {
$errors[] = "- product with name '{$product->getName()}' is found in this category.";
}
return $errors;
}
示例7: addNewCategory
/**
* Add new category to product.
*
* @param Category $category
* @return void
*/
public function addNewCategory(Category $category)
{
$data = ['name' => $category->getName(), 'parent_category' => $category->getDataFieldConfig('parent_id')['source']->getParentCategory()->getName()];
$this->openNewCategoryDialog();
$this->_fill($this->dataMapping($data));
$this->_rootElement->find($this->createCategoryButton)->click();
$this->waitForElementNotVisible($this->createCategoryButton);
}
示例8: selectCategory
/**
* Select category by its name.
*
* @param Category|null $category
* @return void
*/
public function selectCategory($category)
{
if ($category != null && $category->hasData('name')) {
$this->_rootElement->find("//a[contains(text(),'{$category->getName()}')]", Locator::SELECTOR_XPATH)->click();
} else {
$this->skipCategorySelection();
}
}
示例9: prepareFullCategoryPath
/**
* Prepare category path.
*
* @param Category $category
* @return array
*/
protected function prepareFullCategoryPath(Category $category)
{
$path = [];
$parentCategory = $category->hasData('parent_id') ? $category->getDataFieldConfig('parent_id')['source']->getParentCategory() : null;
if ($parentCategory !== null) {
$path = $this->prepareFullCategoryPath($parentCategory);
}
return array_filter(array_merge($path, [$category->getName()]));
}
示例10: processAssert
/**
* Assert that product is not visible in the assigned category
*
* @param CatalogCategoryView $catalogCategoryView
* @param CmsIndex $cmsIndex
* @param FixtureInterface $product
* @param Category|null $category
* @return void
*/
public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, FixtureInterface $product, Category $category = null)
{
$categoryName = $category ? $category->getName() : $product->getCategoryIds()[0];
$cmsIndex->open();
$cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
$isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) {
$isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
}
\PHPUnit_Framework_Assert::assertFalse($isProductVisible, 'Product is exist on category page.');
}
示例11: getCategoryUrl
/**
* Get category url to open.
*
* @param Category $category
* @return string
*/
protected function getCategoryUrl(Category $category)
{
$categoryUrlKey = [];
while ($category) {
$categoryUrlKey[] = $category->hasData('url_key') ? strtolower($category->getUrlKey()) : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-');
$category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory();
if (1 == $category->getParentId()) {
$category = null;
}
}
return $_ENV['app_frontend_url'] . implode('/', array_reverse($categoryUrlKey)) . '.html';
}
示例12: processAssert
/**
* Assert that category name is different on different store view.
*
* @param BrowserInterface $browser
* @param CatalogCategoryView $categoryView
* @param Category $category
* @param Category $initialCategory
* @param CmsIndex $cmsIndex
* @return void
*/
public function processAssert(BrowserInterface $browser, CatalogCategoryView $categoryView, Category $category, Category $initialCategory, CmsIndex $cmsIndex)
{
$cmsIndex->open();
$cmsIndex->getLinksBlock()->waitWelcomeMessage();
$browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html');
\PHPUnit_Framework_Assert::assertEquals($initialCategory->getName(), $categoryView->getTitleBlock()->getTitle(), 'Wrong category name is displayed for default store.');
$store = $category->getDataFieldConfig('store_id')['source']->store->getName();
$cmsIndex->getStoreSwitcherBlock()->selectStoreView($store);
$cmsIndex->getLinksBlock()->waitWelcomeMessage();
$browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html');
\PHPUnit_Framework_Assert::assertEquals($category->getName(), $categoryView->getTitleBlock()->getTitle(), 'Wrong category name is displayed for ' . $store);
}
示例13: getBreadcrumbs
/**
* Prepare and return category breadcrumbs.
*
* @param Category $category
* @return string
*/
protected function getBreadcrumbs(Category $category)
{
$breadcrumbs = [];
while ($category) {
$breadcrumbs[] = $category->getName();
$category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory();
if ($category !== null && 1 == $category->getParentId()) {
$category = null;
}
}
$breadcrumbs[] = self::HOME_PAGE;
return implode(' ', array_reverse($breadcrumbs));
}
示例14: processAssert
/**
* Assert that "Add to cart" button is not display on page.
*
* @param InjectableFixture $product
* @param CmsIndex $cmsIndex
* @param CatalogCategoryView $catalogCategoryView
* @param CatalogProductView $catalogProductView
* @param Category $category [optional]
*
* @return void
*/
public function processAssert(InjectableFixture $product, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, Category $category = null)
{
$cmsIndex->open();
$categoryName = $category === null ? $product->getCategoryIds()[0] : $category->getName();
$cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
$isProductVisible = $catalogCategoryView->getListProductBlock()->getProductItem($product)->isVisible();
while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) {
$isProductVisible = $catalogCategoryView->getListProductBlock()->getProductItem($product)->isVisible();
}
\PHPUnit_Framework_Assert::assertTrue($isProductVisible, 'Product is absent on category page.');
\PHPUnit_Framework_Assert::assertFalse($catalogCategoryView->getListProductBlock()->getProductItem($product)->isVisibleAddToCardButton(), "Button 'Add to Card' is present on Category page.");
$catalogCategoryView->getListProductBlock()->getProductItem($product)->open();
\PHPUnit_Framework_Assert::assertFalse($catalogProductView->getViewBlock()->isVisibleAddToCardButton(), "Button 'Add to Card' is present on Product page.");
}
示例15: processAssert
/**
* Assert that product is visible in the assigned category
*
* @param CatalogCategoryView $catalogCategoryView
* @param CmsIndex $cmsIndex
* @param FixtureInterface $product
* @param Category|null $category
* @return void
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, FixtureInterface $product, Category $category = null)
{
$categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0] : $category->getName();
$cmsIndex->open();
$cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
$isProductVisible = $catalogCategoryView->getListProductBlock()->getProductItem($product)->isVisible();
while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) {
$isProductVisible = $catalogCategoryView->getListProductBlock()->getProductItem($product)->isVisible();
}
if ($product->getVisibility() === 'Search' || $this->getStockStatus($product) === 'Out of Stock') {
$isProductVisible = !$isProductVisible;
$this->errorMessage = 'Product found in this category.';
$this->successfulMessage = 'Asserts that the product could not be found in this category.';
}
\PHPUnit_Framework_Assert::assertTrue($isProductVisible, $this->errorMessage);
}