|
11 | 11 | use Magento\Framework\App\Request\Http as HttpRequest;
|
12 | 12 | use Magento\Framework\Filesystem;
|
13 | 13 | use Magento\Framework\Filesystem\Directory\Write;
|
| 14 | +use Magento\Framework\Filesystem\DriverInterface; |
14 | 15 | use Magento\Framework\Image\Adapter\Gd2;
|
15 | 16 | use Magento\Framework\Image\AdapterFactory;
|
16 | 17 | use Magento\Framework\Serialize\Serializer\Json;
|
@@ -81,7 +82,6 @@ protected function setUp(): void
|
81 | 82 | $this->templateRepository = $this->objectManager->get(TemplateRepositoryInterface::class);
|
82 | 83 |
|
83 | 84 | $this->directoryWrite = $this->getMockBuilder(Write::class)
|
84 |
| - ->setMethods(['writeFile', 'getAbsolutePath']) |
85 | 85 | ->disableOriginalConstructor()
|
86 | 86 | ->getMock();
|
87 | 87 | $this->filesystem = $this->getMockBuilder(Filesystem::class)
|
@@ -123,14 +123,19 @@ protected function setUp(): void
|
123 | 123 | */
|
124 | 124 | public function testSaveAction()
|
125 | 125 | {
|
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'); |
134 | 139 | $this->imageAdapterFactory->expects($this->once())
|
135 | 140 | ->method('create')
|
136 | 141 | ->willReturn($this->imageAdapter);
|
|
0 commit comments