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
33605b7d
Commit
33605b7d
authored
Jan 09, 2013
by
Ivan Chepurnyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
! Vfs fix
parent
d1015750
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
17 deletions
+35
-17
app/code/community/EcomDev/PHPUnit/Model/Fixture.php
app/code/community/EcomDev/PHPUnit/Model/Fixture.php
+3
-4
app/code/community/EcomDev/PHPUnit/Model/Fixture/Processor/Vfs.php
...community/EcomDev/PHPUnit/Model/Fixture/Processor/Vfs.php
+12
-1
app/code/community/EcomDev/PHPUnit/Model/Fixture/Vfs.php
app/code/community/EcomDev/PHPUnit/Model/Fixture/Vfs.php
+20
-11
app/code/community/EcomDev/PHPUnit/Test/Case.php
app/code/community/EcomDev/PHPUnit/Test/Case.php
+0
-1
No files found.
app/code/community/EcomDev/PHPUnit/Model/Fixture.php
View file @
33605b7d
...
...
@@ -720,7 +720,7 @@ class EcomDev_PHPUnit_Model_Fixture
return
$this
->
_vfs
;
}
if
(
is_dir
(
Mage
::
getBaseDir
(
'lib'
)
.
DS
.
'vfsStream'
.
DS
.
'main
'
))
{
if
(
is_dir
(
Mage
::
getBaseDir
(
'lib'
)
.
DS
.
'vfsStream'
.
DS
.
'src
'
))
{
spl_autoload_register
(
array
(
$this
,
'vfsAutoload'
),
true
,
true
);
$this
->
_vfs
=
Mage
::
getModel
(
'ecomdev_phpunit/fixture_vfs'
);
return
$this
->
_vfs
;
...
...
@@ -740,12 +740,11 @@ class EcomDev_PHPUnit_Model_Fixture
*/
public
function
vfsAutoload
(
$className
)
{
if
(
strpos
(
$className
,
'
vfs'
)
!==
0
)
{
if
(
strpos
(
$className
,
'
org\\bovigo\\vfs'
)
===
false
)
{
return
false
;
}
$fileName
=
'vfsStream'
.
DS
.
'src'
.
DS
.
'main'
.
DS
.
'php'
.
DS
$fileName
=
'vfsStream'
.
DS
.
'src'
.
DS
.
'main'
.
DS
.
'php'
.
DS
.
strtr
(
trim
(
$className
,
'\\'
),
'\\'
,
DS
)
.
'.php'
;
return
include
$fileName
;
...
...
app/code/community/EcomDev/PHPUnit/Model/Fixture/Processor/Vfs.php
View file @
33605b7d
...
...
@@ -19,6 +19,8 @@
class
EcomDev_PHPUnit_Model_Fixture_Processor_Vfs
implements
EcomDev_PHPUnit_Model_Fixture_Processor_Interface
{
const
STORAGE_KEY
=
'vfs'
;
/**
* Does nothing
*
...
...
@@ -41,7 +43,15 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Vfs implements EcomDev_PHPUnit_Mod
*/
public
function
apply
(
array
$data
,
$key
,
EcomDev_PHPUnit_Model_Fixture_Interface
$fixture
)
{
$fixture
->
getVfs
()
->
apply
(
$data
,
$fixture
->
isScopeLocal
());
if
(
$fixture
->
isScopeLocal
()
&&
(
$parentData
=
$fixture
->
getStorageData
(
self
::
STORAGE_KEY
,
EcomDev_PHPUnit_Model_Fixture_Interface
::
SCOPE_SHARED
)))
{
$data
=
array_merge_recursive
(
$parentData
,
$data
);
}
$fixture
->
getVfs
()
->
apply
(
$data
);
$fixture
->
setStorageData
(
self
::
STORAGE_KEY
,
$data
);
return
$this
;
}
...
...
@@ -57,6 +67,7 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Vfs implements EcomDev_PHPUnit_Mod
public
function
discard
(
array
$data
,
$key
,
EcomDev_PHPUnit_Model_Fixture_Interface
$fixture
)
{
$fixture
->
getVfs
()
->
discard
();
$fixture
->
setStorageData
(
self
::
STORAGE_KEY
,
null
);
return
$this
;
}
}
\ No newline at end of file
app/code/community/EcomDev/PHPUnit/Model/Fixture/Vfs.php
View file @
33605b7d
...
...
@@ -17,6 +17,7 @@
*/
use
org\bovigo\vfs\vfsStream
as
Stream
;
use
org\bovigo\vfs\vfsStreamDirectory
as
StreamDirectory
;
use
org\bovigo\vfs\vfsStreamWrapper
as
StreamWrapper
;
use
org\bovigo\vfs\visitor\vfsStreamStructureVisitor
as
StreamVisitor
;
...
...
@@ -30,7 +31,7 @@ class EcomDev_PHPUnit_Model_Fixture_Vfs
/**
* Current root directory stack of the VFS before apply process were started
*
* @var
array
* @var
StreamDirectory[]
*/
protected
$_currentRoot
=
array
();
...
...
@@ -50,18 +51,9 @@ class EcomDev_PHPUnit_Model_Fixture_Vfs
*
* @return EcomDev_PHPUnit_Model_Fixture_Vfs
*/
public
function
apply
(
$data
,
$cloneCurrent
=
false
)
public
function
apply
(
$data
)
{
$this
->
_currentRoot
[]
=
StreamWrapper
::
getRoot
();
StreamWrapper
::
setRoot
(
Stream
::
newDirectory
(
uniqid
(
'root'
)));
if
(
$cloneCurrent
)
{
$visitor
=
new
StreamVisitor
();
$visitor
->
visitDirectory
(
end
(
$this
->
_currentRoot
));
if
(
$visitor
->
getStructure
())
{
Stream
::
create
(
$visitor
->
getStructure
());
}
}
Stream
::
create
(
$data
);
return
$this
;
}
...
...
@@ -79,6 +71,23 @@ class EcomDev_PHPUnit_Model_Fixture_Vfs
return
$this
;
}
/**
* Dump current files structure
*
* @return array
*/
public
function
dump
()
{
$currentRoot
=
StreamWrapper
::
getRoot
();
if
(
!
$currentRoot
)
{
return
array
();
}
$visitor
=
new
StreamVisitor
();
$visitor
->
visit
(
$currentRoot
);
return
$visitor
->
getStructure
();
}
/**
* Returns stream wrapper url for operation
* via built-in fs functions
...
...
app/code/community/EcomDev/PHPUnit/Test/Case.php
View file @
33605b7d
...
...
@@ -597,7 +597,6 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase
* Retrieves fixture model singleton
*
* @return EcomDev_PHPUnit_Model_Fixture
* @deprecated since 0.3.0
*/
protected
static
function
getFixture
()
{
...
...
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