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
0f3ea314
Commit
0f3ea314
authored
Sep 10, 2012
by
Ivan Chepurnyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
! Commit uncomitted VFS wrapper
parent
975e184b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
93 additions
and
0 deletions
+93
-0
app/code/community/EcomDev/PHPUnit/Model/Fixture/Vfs.php
app/code/community/EcomDev/PHPUnit/Model/Fixture/Vfs.php
+93
-0
No files found.
app/code/community/EcomDev/PHPUnit/Model/Fixture/Vfs.php
0 → 100644
View file @
0f3ea314
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2012 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
use
org\bovigo\vfs\vfsStream
as
Stream
;
use
org\bovigo\vfs\vfsStreamWrapper
as
StreamWrapper
;
use
org\bovigo\vfs\visitor\vfsStreamStructureVisitor
as
StreamVisitor
;
/**
* VFS library wrapper, to have simple api for manipulation with virtual fs
*
*
*/
class
EcomDev_PHPUnit_Model_Fixture_Vfs
{
/**
* Current root directory stack of the VFS before apply process were started
*
* @var array
*/
protected
$_currentRoot
=
array
();
/**
* Initializes VFS stream wrapper/
*/
public
function
__construct
()
{
Stream
::
setup
();
}
/**
* Applies VFS directory structure
*
* @param $data
* @param bool $cloneCurrent
*
* @return EcomDev_PHPUnit_Model_Fixture_Vfs
*/
public
function
apply
(
$data
,
$cloneCurrent
=
false
)
{
$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
;
}
/**
* Discards VFS file system changes
*
* @return EcomDev_PHPUnit_Model_Fixture_Vfs
*/
public
function
discard
()
{
if
(
$this
->
_currentRoot
)
{
StreamWrapper
::
setRoot
(
array_pop
(
$this
->
_currentRoot
));
}
return
$this
;
}
/**
* Returns stream wrapper url for operation
* via built-in fs functions
*
* @param string $path
* @return string
*/
public
function
url
(
$path
)
{
return
Stream
::
url
(
$path
);
}
}
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