From 7a85f7576deedcd8be51e2aba05a4dcde0224fb2 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Tue, 20 Feb 2018 17:54:04 +0200 Subject: [PATCH] Unit test for copy() of FileManager --- .../unit/Espo/Core/Utils/File/ManagerTest.php | 20 ++++++++++++++++++- .../Custom/Modules/ExtensionTest/File.json | 1 + .../Custom/Modules/ExtensionTest/File.php | 3 +++ .../Modules/TestModule/SubFolder/Tester.txt | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 tests/unit/testData/FileManager/copy/testCase1/custom/Espo/Custom/Modules/ExtensionTest/File.json create mode 100755 tests/unit/testData/FileManager/copy/testCase1/custom/Espo/Custom/Modules/ExtensionTest/File.php create mode 100755 tests/unit/testData/FileManager/copy/testCase1/custom/Espo/Custom/Modules/TestModule/SubFolder/Tester.txt diff --git a/tests/unit/Espo/Core/Utils/File/ManagerTest.php b/tests/unit/Espo/Core/Utils/File/ManagerTest.php index 9503d9225b..38a1c90a75 100644 --- a/tests/unit/Espo/Core/Utils/File/ManagerTest.php +++ b/tests/unit/Espo/Core/Utils/File/ManagerTest.php @@ -413,5 +413,23 @@ class ManagerTest extends \PHPUnit\Framework\TestCase { $this->assertEquals($result, $this->reflection->invokeMethod('getExistsPath', array($input)) ); } -} + public function testCopyTestCase1() + { + $path = 'tests/unit/testData/FileManager/copy/testCase1'; + $cachePath = $this->cachePath . '/copy/testCase1'; + + $expectedResult = [ + 'custom/Espo/Custom/Modules/ExtensionTest/File.json', + 'custom/Espo/Custom/Modules/ExtensionTest/File.php', + 'custom/Espo/Custom/Modules/TestModule/SubFolder/Tester.txt', + ]; + + $result = $this->object->copy($path, $cachePath, true); + + if ($result) { + $this->assertEquals($expectedResult, $this->object->getFileList($cachePath, true, '', true, true)); + $this->object->removeInDir($cachePath); + } + } +} \ No newline at end of file diff --git a/tests/unit/testData/FileManager/copy/testCase1/custom/Espo/Custom/Modules/ExtensionTest/File.json b/tests/unit/testData/FileManager/copy/testCase1/custom/Espo/Custom/Modules/ExtensionTest/File.json new file mode 100755 index 0000000000..28b2dec2eb --- /dev/null +++ b/tests/unit/testData/FileManager/copy/testCase1/custom/Espo/Custom/Modules/ExtensionTest/File.json @@ -0,0 +1 @@ +["File.json"] \ No newline at end of file diff --git a/tests/unit/testData/FileManager/copy/testCase1/custom/Espo/Custom/Modules/ExtensionTest/File.php b/tests/unit/testData/FileManager/copy/testCase1/custom/Espo/Custom/Modules/ExtensionTest/File.php new file mode 100755 index 0000000000..86301b56eb --- /dev/null +++ b/tests/unit/testData/FileManager/copy/testCase1/custom/Espo/Custom/Modules/ExtensionTest/File.php @@ -0,0 +1,3 @@ +