Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
b968402e
Commit
b968402e
authored
Aug 26, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tests for FileHelper
parent
582ff594
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
FileHelperTest.php
tests/unit/framework/helpers/FileHelperTest.php
+22
-2
No files found.
tests/unit/framework/helpers/FileHelperTest.php
View file @
b968402e
...
...
@@ -169,7 +169,7 @@ class FileHelperTest extends TestCase
$this
->
assertFileMode
(
$fileMode
,
$dstDirName
.
DIRECTORY_SEPARATOR
.
$fileName
,
'Copied file has wrong mode!'
);
}
public
function
s
testRemoveDirectory
()
public
function
testRemoveDirectory
()
{
$dirName
=
'test_dir_for_remove'
;
$this
->
createFileStructure
(
array
(
...
...
@@ -189,6 +189,9 @@ class FileHelperTest extends TestCase
FileHelper
::
removeDirectory
(
$dirName
);
$this
->
assertFalse
(
file_exists
(
$dirName
),
'Unable to remove directory!'
);
// should be silent about non-existing directories
FileHelper
::
removeDirectory
(
$basePath
.
DIRECTORY_SEPARATOR
.
'nonExisting'
);
}
public
function
testFindFiles
()
...
...
@@ -272,8 +275,9 @@ class FileHelperTest extends TestCase
{
$basePath
=
$this
->
testFilePath
;
$dirName
=
$basePath
.
DIRECTORY_SEPARATOR
.
'test_dir_level_1'
.
DIRECTORY_SEPARATOR
.
'test_dir_level_2'
;
FileHelper
::
mkdir
(
$dirName
);
$this
->
assertTrue
(
FileHelper
::
mkdir
(
$dirName
),
'FileHelper::mkdir should return true if directory was created!'
);
$this
->
assertTrue
(
file_exists
(
$dirName
),
'Unable to create directory recursively!'
);
$this
->
assertTrue
(
FileHelper
::
mkdir
(
$dirName
),
'FileHelper::mkdir should return true for already existing directories!'
);
}
public
function
testGetMimeTypeByExtension
()
...
...
@@ -292,4 +296,20 @@ class FileHelperTest extends TestCase
$this
->
assertEquals
(
$mimeType
,
FileHelper
::
getMimeTypeByExtension
(
$fileName
,
$magicFile
));
}
}
public
function
testGetMimeType
()
{
$file
=
$this
->
testFilePath
.
DIRECTORY_SEPARATOR
.
'mime_type_test.txt'
;
file_put_contents
(
$file
,
'some text'
);
$this
->
assertEquals
(
'text/plain'
,
FileHelper
::
getMimeType
(
$file
));
$file
=
$this
->
testFilePath
.
DIRECTORY_SEPARATOR
.
'mime_type_test.json'
;
file_put_contents
(
$file
,
'{"a": "b"}'
);
$this
->
assertEquals
(
'text/plain'
,
FileHelper
::
getMimeType
(
$file
));
}
public
function
testNormalizePath
()
{
$this
->
assertEquals
(
DIRECTORY_SEPARATOR
.
'home'
.
DIRECTORY_SEPARATOR
.
'demo'
,
FileHelper
::
normalizePath
(
'/home\demo/'
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment