Skip to content

Commit

Permalink
テストケース追加
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Sep 1, 2022
1 parent 0962d62 commit d0023c8
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/Eccube/Tests/Web/Admin/Content/FileControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,46 @@ public function testUploadIgnoreFiles()
unlink($dot);
}

public function testUploadInvalidFileName()
{
$quote = $this->getUserDataDir()."/../'quote'.txt";
touch($quote);

$quotefile = new UploadedFile(
realpath($quote), // file path
"'quote'.txt", // original name
'text/plain', // mimeType
null, // file size
null, // error
true // test mode
);

$crawler = $this->client->request(
'POST',
$this->generateUrl('admin_content_file'),
[
'form' => [
'_token' => 'dummy',
'create_file' => '',
'file' => [$quotefile],
],
'mode' => 'upload',
'now_dir' => '/',
],
['file' => [$quotefile]]
);

$messages = $crawler->filter('p.errormsg')->each(function (Crawler $node) {
return $node->text();
});

$this->assertTrue($this->client->getResponse()->isSuccessful());
$this->assertContains('使用できない文字が含まれています。', $messages);
$this->assertFalse(file_exists($this->getUserDataDir()."/'quote'.txt"));

unlink($quote);
}

protected function getUserDataDir()
{
return __DIR__.'/../../../../../../html/user_data';
Expand Down

0 comments on commit d0023c8

Please sign in to comment.