本文整理汇总了PHP中Magento\Catalog\Test\Fixture\Category类的典型用法代码示例。如果您正苦于以下问题:PHP Category类的具体用法?PHP Category怎么用?PHP Category使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Category类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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.');
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:AssertWidgetRecentlyViewedProducts.php
示例2: 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.');
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:AssertCategoryIsNotActive.php
示例3: __inject
/**
* Inject page end prepare default category
*
* @param Category $initialCategory
* @param CatalogCategoryIndex $catalogCategoryIndex
* @param CatalogCategoryEdit $catalogCategoryEdit
* @return array
*/
public function __inject(Category $initialCategory, CatalogCategoryIndex $catalogCategoryIndex, CatalogCategoryEdit $catalogCategoryEdit)
{
$this->catalogCategoryIndex = $catalogCategoryIndex;
$this->catalogCategoryEdit = $catalogCategoryEdit;
$initialCategory->persist();
return ['initialCategory' => $initialCategory];
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:UpdateCategoryEntityTest.php
示例4: test
/**
* Delete category
*
* @param Category $category
* @return void
*/
public function test(Category $category)
{
$category->persist();
$this->catalogCategoryIndex->open();
$this->catalogCategoryIndex->getTreeCategories()->selectCategory($category);
$this->catalogCategoryEdit->getFormPageActions()->delete();
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:DeleteCategoryEntityTest.php
示例5: 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.');
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:14,代码来源:AssertRewritesEnabled.php
示例6: __prepare
/**
* Prepare data.
*
* @param Category $category
* @param CatalogProductIndex $productGrid
* @param CatalogProductEdit $editProductPage
* @param FixtureFactory $fixtureFactory
* @return void
*/
public function __prepare(Category $category, CatalogProductIndex $productGrid, CatalogProductEdit $editProductPage, FixtureFactory $fixtureFactory)
{
$this->category = $category;
$this->category->persist();
$this->productGrid = $productGrid;
$this->editProductPage = $editProductPage;
$this->fixtureFactory = $fixtureFactory;
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:DuplicateProductEntityTest.php
示例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);
}
开发者ID:kid17,项目名称:magento2,代码行数:14,代码来源:NewCategoryIds.php
示例8: test
/**
* Filtering product in the Frontend via layered navigation.
*
* @param string $configData
* @param Category $category
* @return array
*/
public function test($configData, Category $category)
{
$this->configData = $configData;
// Preconditions
$this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $this->configData])->run();
// Steps
$category->persist();
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:15,代码来源:FilterProductListTest.php
示例9: 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();
}
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:14,代码来源:Tree.php
示例10: processAssert
/**
* Assert that sitemap.xml file contains correct content according to dataset:
* - product url
* - category url
* - CMS page url
*
* @param CatalogProductSimple $product
* @param Category $catalog
* @param CmsPage $cmsPage
* @param Sitemap $sitemap
* @param SitemapIndex $sitemapIndex
* @return void
*/
public function processAssert(CatalogProductSimple $product, Category $catalog, CmsPage $cmsPage, Sitemap $sitemap, SitemapIndex $sitemapIndex)
{
$sitemapIndex->open()->getSitemapGrid()->sortGridByField('sitemap_id');
$filter = ['sitemap_filename' => $sitemap->getSitemapFilename(), 'sitemap_path' => $sitemap->getSitemapPath()];
$sitemapIndex->getSitemapGrid()->search($filter);
$content = file_get_contents($sitemapIndex->getSitemapGrid()->getLinkForGoogle());
$urls = [$_ENV['app_frontend_url'] . $product->getUrlKey() . '.html', $_ENV['app_frontend_url'] . $catalog->getUrlKey() . '.html', $_ENV['app_frontend_url'] . $cmsPage->getIdentifier()];
\PHPUnit_Framework_Assert::assertTrue($this->checkContent($content, $urls), 'Content of file sitemap.xml does not include one or more of next urls:' . implode("\n", $urls));
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:22,代码来源:AssertSitemapContent.php
示例11: 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 find.");
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:AssertCategoryForAssignedProducts.php
示例12: __inject
/**
* Prepare datasets and pages
*
* @param UrlRewriteIndex $urlRewriteIndex
* @param UrlRewriteEdit $urlRewriteEdit
* @param FixtureFactory $fixtureFactory
* @param Category $category
* @return array
*/
public function __inject(UrlRewriteIndex $urlRewriteIndex, UrlRewriteEdit $urlRewriteEdit, FixtureFactory $fixtureFactory, Category $category)
{
$this->urlRewriteIndex = $urlRewriteIndex;
$this->urlRewriteEdit = $urlRewriteEdit;
$category->persist();
$categoryRedirect = $fixtureFactory->createByCode('urlRewrite', ['dataset' => 'default', 'data' => ['target_path' => $category->getUrlKey() . '.html']]);
$categoryRedirect->persist();
return ['categoryRedirect' => $categoryRedirect, 'category' => $category];
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:18,代码来源:UpdateCategoryUrlRewriteEntityTest.php
示例13: 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()]));
}
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:Categories.php
示例14: assertCategoryOnFrontend
/**
* Verify category on the frontend
*
* @param Category $category
*/
protected function assertCategoryOnFrontend(Category $category)
{
//Open created category on frontend
$frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex();
$frontendHomePage->open();
$navigationMenu = $frontendHomePage->getTopmenu();
$navigationMenu->selectCategoryByName($category->getCategoryName());
$this->assertEquals($category->getCategoryName(), $frontendHomePage->getTitleBlock()->getTitle());
}
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:CreateTest.php
示例15: test
/**
* Delete category.
*
* @param Category $category
* @return void
*/
public function test(Category $category)
{
$category->persist();
$this->catalogCategoryIndex->open();
$this->catalogCategoryIndex->getTreeCategories()->selectCategory($category);
if ($this->catalogCategoryEdit->getFormPageActions()->checkDeleteButton()) {
$this->catalogCategoryEdit->getFormPageActions()->delete();
$this->catalogCategoryEdit->getModalBlock()->acceptAlert();
}
}
开发者ID:Zash22,项目名称:magento,代码行数:16,代码来源:DeleteCategoryEntityTest.php
示例16: 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.');
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:20,代码来源:AssertProductNotVisibleInCategory.php
示例17: 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);
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:22,代码来源:AssertCategoryWithCustomStoreOnFrontend.php
示例18: 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';
}
开发者ID:uibar,项目名称:lavinia2,代码行数:18,代码来源:AssertCategoryIsNotActive.php
示例19: __construct
/**
* @constructor
* @param FixtureFactory $fixtureFactory
* @param array $params
* @param array|int $data
*/
public function __construct(FixtureFactory $fixtureFactory, array $params, $data = [])
{
$this->params = $params;
if (isset($data['dataSet']) && $data['dataSet'] !== '-') {
$this->parentCategory = $fixtureFactory->createByCode('category', ['dataSet' => $data['dataSet']]);
if (!$this->parentCategory->hasData('id')) {
$this->parentCategory->persist();
}
$this->data = $this->parentCategory->getId();
} else {
$this->data = $data;
}
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:19,代码来源:ParentId.php
示例20: 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));
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:AssertCategoryBreadcrumbs.php
注:本文中的Magento\Catalog\Test\Fixture\Category类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论