Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
EcomDev_PHPUnit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Open
EcomDev_PHPUnit
Commits
181305ac
Commit
181305ac
authored
Jan 23, 2013
by
Ivan Chepurnyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
! New fx/dp/ex prefixes for test case fixtures/providers/expectations
parent
20b9f742
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
5 deletions
+67
-5
app/code/community/EcomDev/PHPUnit/Model/Yaml/Loader/Abstract.php
.../community/EcomDev/PHPUnit/Model/Yaml/Loader/Abstract.php
+41
-1
app/code/community/EcomDev/PHPUnit/Model/Yaml/Loader/Default.php
...e/community/EcomDev/PHPUnit/Model/Yaml/Loader/Default.php
+6
-1
app/code/community/EcomDev/PHPUnit/Model/Yaml/Loader/Module.php
...de/community/EcomDev/PHPUnit/Model/Yaml/Loader/Module.php
+20
-3
No files found.
app/code/community/EcomDev/PHPUnit/Model/Yaml/Loader/Abstract.php
View file @
181305ac
...
...
@@ -18,6 +18,14 @@
abstract
class
EcomDev_PHPUnit_Model_Yaml_Loader_Abstract
implements
EcomDev_PHPUnit_Model_Yaml_Loader_Interface
{
const
DATA_DIR
=
'_data'
;
protected
$_typeMap
=
array
(
'fixtures'
=>
'fx'
,
'providers'
=>
'dp'
,
'expectations'
=>
'ex'
);
/**
* Resolves YAML file path based on its filename,
* if file is not found, it should return false
...
...
@@ -51,4 +59,36 @@ abstract class EcomDev_PHPUnit_Model_Yaml_Loader_Abstract implements EcomDev_PHP
* @return string
*/
abstract
protected
function
_getFilePath
(
$fileName
,
$relatedClassName
,
$type
);
}
\ No newline at end of file
/**
* Looks in path for possible existent fixture
*
* @param string|array $path
* @param string $fileName
* @param string $type
* @return bool|string
*/
protected
function
_checkFilePath
(
$path
,
$fileName
,
$type
)
{
if
(
is_array
(
$path
))
{
foreach
(
$path
as
$value
)
{
if
(
$filePath
=
$this
->
_checkFilePath
(
$value
,
$fileName
,
$type
))
{
return
$filePath
;
}
}
return
false
;
}
if
(
isset
(
$this
->
_typeMap
[
$type
])
&&
file_exists
(
$filePath
=
$path
.
DS
.
self
::
DATA_DIR
.
DS
.
$this
->
_typeMap
[
$type
]
.
'-'
.
$fileName
))
{
return
$filePath
;
}
if
(
file_exists
(
$filePath
=
$path
.
DS
.
$type
.
DS
.
$fileName
))
{
return
$filePath
;
}
return
false
;
}
}
app/code/community/EcomDev/PHPUnit/Model/Yaml/Loader/Default.php
View file @
181305ac
...
...
@@ -30,6 +30,11 @@ class EcomDev_PHPUnit_Model_Yaml_Loader_Default extends EcomDev_PHPUnit_Model_Ya
{
$reflection
=
EcomDev_Utils_Reflection
::
getReflection
(
$relatedClassName
);
$fileObject
=
new
SplFileInfo
(
$reflection
->
getFileName
());
return
$fileObject
->
getPath
()
.
DS
.
$fileObject
->
getBasename
(
'.php'
)
.
DS
.
$type
.
DS
.
$fileName
;
return
$this
->
_checkFilePath
(
array
(
$fileObject
->
getPath
(),
$fileObject
->
getPath
()
.
DS
.
$fileObject
->
getBasename
(
'.php'
)
),
$fileName
,
$type
);
}
}
\ No newline at end of file
app/code/community/EcomDev/PHPUnit/Model/Yaml/Loader/Module.php
View file @
181305ac
...
...
@@ -28,7 +28,8 @@ class EcomDev_PHPUnit_Model_Yaml_Loader_Module extends EcomDev_PHPUnit_Model_Yam
*/
protected
function
_getFilePath
(
$fileName
,
$relatedClassName
,
$type
)
{
$moduleName
=
EcomDev_PHPUnit_Test_Case_Util
::
getModuleNameByClassName
(
$relatedClassName
);
$moduleName
=
false
;
if
(
preg_match
(
'#^~(?<module>[^/]*)/(?<fileName>.*)$#'
,
$fileName
,
$matches
))
{
$fileName
=
$matches
[
'fileName'
];
if
(
!
empty
(
$matches
[
'module'
]))
{
...
...
@@ -36,7 +37,23 @@ class EcomDev_PHPUnit_Model_Yaml_Loader_Module extends EcomDev_PHPUnit_Model_Yam
}
}
$filePath
=
Mage
::
getModuleDir
(
''
,
$moduleName
)
.
DS
.
'Test'
.
DS
.
$type
.
DS
.
$fileName
;
return
false
;
if
(
!
$moduleName
)
{
try
{
$moduleName
=
EcomDev_PHPUnit_Test_Case_Util
::
getModuleNameByClassName
(
$relatedClassName
);
}
catch
(
RuntimeException
$e
)
{
return
false
;
}
}
$basePath
=
array
();
if
(
$prefixPosition
=
strpos
(
$relatedClassName
,
$moduleName
.
'_Test_'
))
{
$testType
=
substr
(
$relatedClassName
,
$prefixPosition
,
strpos
(
$relatedClassName
,
'_'
,
$prefixPosition
));
$basePath
[]
=
Mage
::
getModuleDir
(
''
,
$moduleName
)
.
DS
.
'Test'
.
DS
.
$testType
;
}
$basePath
[]
=
Mage
::
getModuleDir
(
''
,
$moduleName
)
.
DS
.
'Test'
;
return
$this
->
_checkFilePath
(
$basePath
,
$fileName
,
$type
);
}
}
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