Skip to content

Commit bd3fe92

Browse files
committed
MC-21630: Controller behavior minor changes
1 parent ce30b12 commit bd3fe92

File tree

1 file changed

+8
-22
lines changed
  • app/code/Magento/ImportExport/Test/Unit/Controller/Adminhtml/Export/File

1 file changed

+8
-22
lines changed

app/code/Magento/ImportExport/Test/Unit/Controller/Adminhtml/Export/File/DownloadTest.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function setUp()
9191
*
9292
* @return void
9393
*/
94-
public function testDownload()
94+
public function testExecute(): void
9595
{
9696
$fileName = 'customer.csv';
9797
$path = 'export/' . $fileName;
@@ -102,48 +102,34 @@ public function testDownload()
102102
$response = $this->createMock(ResponseInterface::class);
103103
$this->fileFactoryMock->expects($this->once())
104104
->method('create')
105-
->with($path, $fileContent, DirectoryList::VAR_DIR)->willReturn($response);
105+
->with($path, $fileContent, DirectoryList::VAR_DIR)
106+
->willReturn($response);
106107

107108
$this->controller->execute();
108109
}
109110

110111
/**
111112
* Check behavior with incorrect filename.
112113
*
113-
* @param string $fileName
114-
* @dataProvider fileNameDataProvider
115114
* @expectedException \Magento\Framework\Exception\LocalizedException
116115
* @expectedExceptionMessage Please provide valid export file name
117116
* @return void
118117
*/
119-
public function testDownloadWithIncorrectFilename(string $fileName)
118+
public function testExecuteWithEmptyFileName(): void
120119
{
121-
$this->requestMock->expects($this->once())->method('getParam')->with('filename')->willReturn($fileName);
120+
$this->requestMock->expects($this->once())->method('getParam')->with('filename')->willReturn('');
122121

123122
$this->controller->execute();
124123
}
125124

126-
/**
127-
* Data provider for testDownloadWithIncorrectFilename.
128-
*
129-
* @return array
130-
*/
131-
public function fileNameDataProvider(): array
132-
{
133-
return [
134-
'Empty parameter' => [''],
135-
'Incorrect Name' => ['../customer.csv'],
136-
];
137-
}
138-
139125
/**
140126
* Check behavior when method throw exception.
141127
*
142128
* @expectedException \Magento\Framework\Exception\LocalizedException
143-
* @expectedExceptionMessage There are no export file with such name
129+
* @expectedExceptionMessage There are no export file with such name customer.csv
144130
* @return void
145131
*/
146-
public function testDownloadWithException()
132+
public function testExecuteWithNonExistanceFile(): void
147133
{
148134
$fileName = 'customer.csv';
149135
$path = 'export/' . $fileName;
@@ -164,7 +150,7 @@ public function testDownloadWithException()
164150
* @param string $path
165151
* @return void
166152
*/
167-
private function processDownloadAction(string $fileName, string $path)
153+
private function processDownloadAction(string $fileName, string $path): void
168154
{
169155
$this->requestMock->expects($this->once())->method('getParam')->with('filename')->willReturn($fileName);
170156
$this->fileSystemMock->expects($this->once())

0 commit comments

Comments
 (0)