Skip to content

Commit 80dc0e2

Browse files
committed
MC-38416: Stabilize PageBuilder tests on S3
1 parent 28244dd commit 80dc0e2

File tree

1 file changed

+14
-9
lines changed
  • dev/tests/integration/testsuite/Magento/PageBuilder/Controller/Adminhtml/Template

1 file changed

+14
-9
lines changed

dev/tests/integration/testsuite/Magento/PageBuilder/Controller/Adminhtml/Template/SaveTest.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\App\Request\Http as HttpRequest;
1212
use Magento\Framework\Filesystem;
1313
use Magento\Framework\Filesystem\Directory\Write;
14+
use Magento\Framework\Filesystem\DriverInterface;
1415
use Magento\Framework\Image\Adapter\Gd2;
1516
use Magento\Framework\Image\AdapterFactory;
1617
use Magento\Framework\Serialize\Serializer\Json;
@@ -81,7 +82,6 @@ protected function setUp(): void
8182
$this->templateRepository = $this->objectManager->get(TemplateRepositoryInterface::class);
8283

8384
$this->directoryWrite = $this->getMockBuilder(Write::class)
84-
->setMethods(['writeFile', 'getAbsolutePath'])
8585
->disableOriginalConstructor()
8686
->getMock();
8787
$this->filesystem = $this->getMockBuilder(Filesystem::class)
@@ -123,14 +123,19 @@ protected function setUp(): void
123123
*/
124124
public function testSaveAction()
125125
{
126-
// Verify that the system attempts to write the file with the current name
127-
$this->directoryWrite->expects($this->once())
128-
->method('writeFile')
129-
->with(
130-
$this->stringContains('.template-manager/automatedtemplate'),
131-
$this->anything()
132-
);
133-
126+
$this->directoryWrite->expects(self::atLeastOnce())->method('getAbsolutePath')
127+
->with('.template-manager')
128+
->willReturn('absolute/path/.template-manager/');
129+
$this->directoryWrite->expects(self::atLeastOnce())->method('create')
130+
->with('absolute/path/.template-manager/');
131+
$driver = $this->getMockBuilder(DriverInterface::class)
132+
->disableOriginalConstructor()
133+
->getMock();
134+
$this->directoryWrite->expects(self::atLeastOnce())->method('getDriver')
135+
->willReturn($driver);
136+
$this->directoryWrite->expects(self::atLeastOnce())->method('getRelativePath')
137+
->willReturn('.template-manager/automatedtemplate');
138+
$driver->expects(self::atLeastOnce())->method('filePutContents');
134139
$this->imageAdapterFactory->expects($this->once())
135140
->method('create')
136141
->willReturn($this->imageAdapter);

0 commit comments

Comments
 (0)