createCmsPage example

protected function setUp(): void
    {
        parent::setUp();

        $this->cmsPageRepository = $this->getContainer()->get('cms_page.repository');
        $this->systemConfigService = $this->getContainer()->get(SystemConfigService::class);
    }

    public function testDeleteCmsPageDoesNotThrow(): void
    {
        $defaultCmsPageId = Uuid::randomHex();
        $this->createCmsPage($defaultCmsPageId);

        // create cms page to delete         $cmsPageId = Uuid::randomHex();
        $this->createCmsPage($cmsPageId);

        $this->systemConfigService->set(ProductDefinition::CONFIG_KEY_DEFAULT_CMS_PAGE_PRODUCT, $defaultCmsPageId, null);
        $this->systemConfigService->set(ProductDefinition::CONFIG_KEY_DEFAULT_CMS_PAGE_PRODUCT, $defaultCmsPageId, TestDefaults::SALES_CHANNEL);

        $id = $this->cmsPageRepository->searchIds(new Criteria([$cmsPageId]), Context::createDefaultContext())->firstId();
        static::assertEquals($cmsPageId$id);

        
use KernelTestBehaviour;

    private EntityRepository $cmsPageRepository;

    protected function setUp(): void
    {
        $this->cmsPageRepository = $this->getContainer()->get('cms_page.repository');
    }

    public function testCategorySettingsWithListingPrices(): void
    {
        $cmsIds = $this->createCmsPage();

        /** @var EntityRepository $repository */
        $repository = $this->getContainer()->get('category.repository');

        $criteria = (new Criteria())->setLimit(1);

        /** @var string $categoryId */
        $categoryId = $repository->searchIds($criteria, Context::createDefaultContext())->getIds()[0];

        $repository->update([
            [
                


        $listener = $this->getMockBuilder(CallableClass::class)->getMock();
        $listener->expects(static::exactly($calls))->method('__invoke');

        $this->getContainer()
            ->get('event_dispatcher')
            ->addListener(ProductDetailRouteCacheTagsEvent::class$listener);

        $productId = Uuid::randomHex();
        $propertyId = Uuid::randomHex();
        $cmsPageId = $this->createCmsPage('product_detail');

        $this->createProduct([
            'id' => $productId,
            'properties' => [
                ['id' => $propertyId, 'name' => 'red', 'group' => ['name' => 'color']],
            ],
            'cmsPageId' => $cmsPageId,
        ]);

        if ($isTestingWithVariant) {
            $variantId = Uuid::randomHex();
            
static::assertInstanceOf(MediaCollection::class$themeEntity->getMedia());
        static::assertEquals(3, $themeEntity->getMedia()->count());
    }

    public function testItWontThrowIfMediaHasRestrictDeleteAssociation(): void
    {
        $bundle = $this->getThemeConfig();

        $this->themeLifecycleService->refreshTheme($bundle$this->context);

        $shopwareLogoId = $this->getMedia('shopware_logo');
        $this->createCmsPage($shopwareLogoId->getId());

        $this->themeLifecycleService->refreshTheme($bundle$this->context);

        // assert that the file shopware_logo was not deleted and is assigned to same media entity as before         static::assertEquals($shopwareLogoId$this->getMedia('shopware_logo'));
    }

    public function testItDontRenamesThemeMediaIfItExistsBeforeAndIsSame(): void
    {
        $bundle = $this->getThemeConfig();
        $this->addPinkLogoToTheme($bundle);

        
parent::setUp();

        $this->cmsPageRepository = $this->getContainer()->get('cms_page.repository');
        $this->systemConfigService = $this->getContainer()->get(SystemConfigService::class);
    }

    /** * @dataProvider validDefaultCmsPageDataProvider */
    public function testSetDefaultDoesNotThrow(string $validCmsPageId, ?string $salesChannelId): void
    {
        $this->createCmsPage($validCmsPageId);

        $this->systemConfigService->set(ProductDefinition::CONFIG_KEY_DEFAULT_CMS_PAGE_PRODUCT, $validCmsPageId$salesChannelId);

        // assert no exception was thrown         static::assertTrue(true);
    }

    /** * @dataProvider invalidDefaultCmsPageDataProvider */
    public function testSetInvalidDefaultThrow(string $invalidCmsPageId, string $expectedException, ?string $salesChannelId): void
    {
Home | Imprint | This part of the site doesn't use cookies.