Skip to content

Commit 62a00bc

Browse files
committed
Merge remote-tracking branch 'origin/ACP2E-4308' into PR_2025_12_03_chittima
2 parents 3ffa246 + d6b5139 commit 62a00bc

File tree

1 file changed

+58
-0
lines changed
  • app/code/Magento/Cms/Test/Fixture

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Cms\Test\Fixture;
9+
10+
use Magento\Cms\Api\Data\PageInterface;
11+
use Magento\Cms\Api\PageRepositoryInterface;
12+
use Magento\Framework\DataObject;
13+
use Magento\TestFramework\Fixture\Api\ServiceFactory;
14+
use Magento\TestFramework\Fixture\Data\ProcessorInterface;
15+
use Magento\TestFramework\Fixture\RevertibleDataFixtureInterface;
16+
17+
class Page implements RevertibleDataFixtureInterface
18+
{
19+
private const DEFAULT_DATA = [
20+
PageInterface::IDENTIFIER => 'page%uniqid%',
21+
PageInterface::TITLE => 'Page%uniqid%',
22+
PageInterface::CONTENT => 'PageContent%uniqid%',
23+
PageInterface::CREATION_TIME => null,
24+
PageInterface::UPDATE_TIME => null,
25+
'active' => true
26+
];
27+
28+
/**
29+
* @param ProcessorInterface $dataProcessor
30+
* @param ServiceFactory $serviceFactory
31+
*/
32+
public function __construct(
33+
private readonly ProcessorInterface $dataProcessor,
34+
private readonly ServiceFactory $serviceFactory
35+
) {
36+
}
37+
38+
/**
39+
* {@inheritdoc}
40+
* @param array $data Parameters. Same format as Block::DEFAULT_DATA.
41+
*/
42+
public function apply(array $data = []): ?DataObject
43+
{
44+
$data = $this->dataProcessor->process($this, array_merge(self::DEFAULT_DATA, $data));
45+
$service = $this->serviceFactory->create(PageRepositoryInterface::class, 'save');
46+
47+
return $service->execute(['page' => $data]);
48+
}
49+
50+
/**
51+
* @inheritdoc
52+
*/
53+
public function revert(DataObject $data): void
54+
{
55+
$service = $this->serviceFactory->create(PageRepositoryInterface::class, 'deleteById');
56+
$service->execute(['pageId' => $data->getId()]);
57+
}
58+
}

0 commit comments

Comments
 (0)