SlideShare a Scribd company logo
VfsStream effective filesystem mocking Sebastian Marek
Prerequisites ,[object Object]
basic knowledge of PHPUnit
External dependencies ,[object Object]
SOAP
3 rd  party
Filesystem ,[object Object]
Many different ways
Not a dependency REALLY!?
Learning by example <?php class  Config { private  $filename ; public function  __construct($filename) { if  (!is_file($filename)) { throw new  Exception( &quot;Can't set the filename - it doesn't exists!&quot; ); } $this -> filename  = $filename; } public function  fetchConfig() { return  parse_ini_file( $this -> filename ,  true ); } public function  createCacheDir($directory) { if  (!is_dir($directory)) { return  mkdir($directory, 0700,  true ); } return   false ; } }
guerrillas ,[object Object]
prepare upfront http://picasaweb.google.co.uk/catof.airsoft/PartisanRusse#5480348761446205778
guerrillas test case <?php class  ConfigTest  extends  PHPUnit_Framework_TestCase { private  $cacheDir  =  '/tmp/cache' ; private  $configFile  =  '/tmp/config.ini' ; // (...) /** * @covers Config::__construct */ public function  testConstructorSetsConfigFilename() { $config =  new  Config( $this -> configFile ); $this ->assertAttributeEquals( $this -> configFile ,  'filename' , $config); } // (...) }
guerrillas test case <?php class  ConfigTest  extends  PHPUnit_Framework_TestCase { private  $cacheDir  =  '/tmp/cache' ; private  $configFile  =  '/tmp/config.ini' ; // (...) /** * @covers Config::__construct */ public function  testConstructorThrowsExceptionWithInvalidConfigFile() { $configFile =  '/share/usr/config.ini' ; $this ->setExpectedException( 'Exception' ,  &quot;Can't set the filename - it doesn't exists!&quot; ); $config =  new  Config($configFile); } // (...) }
guerrillas test case <?php class  ConfigTest  extends  PHPUnit_Framework_TestCase { private  $cacheDir  =  '/tmp/cache' ; private  $configFile  =  '/tmp/config.ini' ; protected function  setUp() { $content =  &quot; [section1] key1=value1 key2=value3 [section2] key3=value3 &quot; ; file_put_contents( $this -> configFile , $content); if  (!is_dir( $this -> cacheDir )) { mkdir( $this -> cacheDir ); } } // (...) }
guerrillas test case class  ConfigTest  extends  PHPUnit_Framework_TestCase { private  $cacheDir  =  '/tmp/cache' ; private  $configFile  =  '/tmp/config.ini' ; // (...) protected function  tearDown() { if  (is_dir( $this -> cacheDir )) { rmdir( $this -> cacheDir ); } unlink( $this -> configFile ); } // (...) }
Modern warfare vfsStream ,[object Object]
uses php stream wrapper http://picasaweb.google.co.uk/dawson.jerome/MCASMiramarAirShow2007#5121760885155756402
vfsStream installation #> pear channel-discover pear.php-tools.net #> pear install pat/vfsStream-alpha
vfsStream - register <?php require_once  'vfsStream/vfsStream.php' // (...) protected  function  setUp() { vfsStream:: setup ( 'root' ); } // (...)
vfsStream & PHPUnit <?php class  SomeTest  extends  PHPUnit_Framework_TestCase { protected function  setVfsStream() { @ include_once  'vfsStream/vfsStream.php' ; if  (!class_exists( 'vfsStreamWrapper' )) { $this ->markTestSkipped( 'vfsStream is not available - skipping' ); }  else  { vfsStream:: setup ( 'root' ); } } public function  testSomething() { $this ->setVfsStream(); //(...) } }
vfsStream – working with files <?php class  ConfigTest  extends  PHPUnit_Framework_TestCase { /** * @covers Config::__construct */ public function  testConstructorSetsConfigFilename() { $this ->setVfsStream(); vfsStream::newFile( 'config.ini' )->at(vfsStreamWrapper::getRoot()); $config =  new  Config(vfsStream::url( 'root/config.ini' )); $this ->assertAttributeEquals(vfsStream::url( 'root/config.ini' ),  'filename' , $config); } // (...) }
vfsStream – working with files <?php class  ConfigTest  extends  PHPUnit_Framework_TestCase { /** * @covers Config::__construct */ public function  testConstructorThrowsExceptionWithInvalidConfigFile() { $this ->setVfsStream(); $this ->setExpectedException( 'Exception' ,  &quot;Can't set the filename - it doesn't exists!&quot; ); $config =  new  Config(vfsStream::url( 'root/config.ini' )); } // (...) }
vfsStream url <?php // (...) public function dumpVfsStreamUrl () { $this ->setVfsStream(); echo  vfsStream::url( 'root/config.ini' ); // vfs://root/config.ini } // (...) }
vfsStream – working with dirs <?php class  ConfigTest  extends  PHPUnit_Framework_TestCase { /** * @covers Config::createCacheDir */ public function  testCreateCacheDirIfItDoesntExists() { $this ->setVfsStream(); $this ->assertFileNotExists(vfsStream:: url ( 'root/cache' )); vfsStream:: newFile ( 'config.ini' )->at(vfsStreamWrapper:: getRoot ()); $config =  new  Config(vfsStream:: url ( 'root/config.ini' )); $config->createCacheDir(vfsStream:: url ( 'root/cache' )); $this ->assertFileExists(vfsStream:: url ( 'root/cache' )); } // (...) }
vfsStream – working with dirs <?php class  ConfigTest  extends  PHPUnit_Framework_TestCase { /** * @covers Config::createCacheDir */ public function  testDontCreateCacheDirIfItExists() { $this ->setVfsStream(); vfsStream:: newFile ( 'config.ini' )->at(vfsStreamWrapper:: getRoot ()); vfsStream:: newDirectory ( 'cache' )->at(vfsStreamWrapper:: getRoot ()); $this ->assertFileExists(vfsStream:: url ( 'root/cache' )); $config =  new  Config(vfsStream:: url ( 'root/config.ini' )); $result = $config->createCacheDir(vfsStream:: url ( 'root/cache' )); $this ->assertFalse($result); } // (...) }
vfsStream – working with content <?php class  ConfigTest  extends  PHPUnit_Framework_TestCase { /** * @covers Config::fetchConfig */ public function  testFetchConfigReturnsArray() { $this ->setVfsStream(); $content =  << < 'EOT' [section1] key1 = value1 [section2] key2 = value2 [section3] key3 = value3 EOT; vfsStream:: newFile ( 'config.ini' )->withContent($content) ->at(vfsStreamWrapper:: getRoot ()); $config =  new  Config(vfsStream:: url ( 'root/config.ini' )); $result = $config->fetchConfig(); $this ->assertTrue(is_array($result)); $this ->assertEquals(3, count($result)); $this ->assertEquals( array ( 'key1'  =>  'value1' ), $result[ 'section1' ]); $this ->assertEquals( array ( 'key2'  =>  'value2' ), $result[ 'section2' ]); $this ->assertEquals( array ( 'key3'  =>  'value3' ), $result[ 'section3' ]); } }
vfsStream – file perms new  vfsStreamFile( 'app.ini' , 0644); new  vfsStreamDirectory( '/home' , 0755); vfsStream:: newFile ( 'app.ini' , 0640); vfsStream:: newDirectory ( '/tmp/cache' , 0755); $vfsStreamFile->chmod(0664); $vfsStreamDirectory->chmod(0700);
vfsStream – file ownership $vfsStreamFile->chown(vfsStream:: OWNER_USER_2 ); $vfsStreamDirectory->chown(vfsStream:: OWNER_ROOT ); $vfsStreamFile->chgrp(vfsStream:: GROUP_USER_2 ); $vfsStreamDirectory->chgrp(vfsStream:: GROUP_ROOT );
vfsStream – file ownership ,[object Object]
vfsStream:: OWNER_USER_1 // 1
vfsStream:: OWNER_USER_2 // 2 ,[object Object]
vfsStream:: GROUP_USER_1 // 1

More Related Content

What's hot

Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.
Workhorse Computing
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
Bastian Feder
 
Metadata-driven Testing
Metadata-driven TestingMetadata-driven Testing
Metadata-driven Testing
Workhorse Computing
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
Andrew Shitov
 
Bioinformatics p5-bioperlv2014
Bioinformatics p5-bioperlv2014Bioinformatics p5-bioperlv2014
Bioinformatics p5-bioperlv2014
Prof. Wim Van Criekinge
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
Andrew Shitov
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
brian d foy
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
The most exciting features of PHP 7.1
The most exciting features of PHP 7.1The most exciting features of PHP 7.1
The most exciting features of PHP 7.1
Zend by Rogue Wave Software
 
Utility Modules That You Should Know About
Utility Modules That You Should Know AboutUtility Modules That You Should Know About
Utility Modules That You Should Know About
joshua.mcadams
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regex
brian d foy
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
Andrew Shitov
 
Zendcon 2007 Api Design
Zendcon 2007 Api DesignZendcon 2007 Api Design
Zendcon 2007 Api Design
unodelostrece
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
brian d foy
 
Perl5i
Perl5iPerl5i
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
Augusto Pascutti
 
Workshop unittesting
Workshop unittestingWorkshop unittesting
Workshop unittesting
Joshua Thijssen
 
The Magic Of Tie
The Magic Of TieThe Magic Of Tie
The Magic Of Tie
brian d foy
 
PHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look AheadPHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look Ahead
thinkphp
 
Legacy applications - 4Developes konferencja, Piotr Pasich
Legacy applications  - 4Developes konferencja, Piotr PasichLegacy applications  - 4Developes konferencja, Piotr Pasich
Legacy applications - 4Developes konferencja, Piotr Pasich
Piotr Pasich
 

What's hot (20)

Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.Perl6 Regexen: Reduce the line noise in your code.
Perl6 Regexen: Reduce the line noise in your code.
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
Metadata-driven Testing
Metadata-driven TestingMetadata-driven Testing
Metadata-driven Testing
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Bioinformatics p5-bioperlv2014
Bioinformatics p5-bioperlv2014Bioinformatics p5-bioperlv2014
Bioinformatics p5-bioperlv2014
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
The most exciting features of PHP 7.1
The most exciting features of PHP 7.1The most exciting features of PHP 7.1
The most exciting features of PHP 7.1
 
Utility Modules That You Should Know About
Utility Modules That You Should Know AboutUtility Modules That You Should Know About
Utility Modules That You Should Know About
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regex
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
Zendcon 2007 Api Design
Zendcon 2007 Api DesignZendcon 2007 Api Design
Zendcon 2007 Api Design
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
 
Perl5i
Perl5iPerl5i
Perl5i
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
 
Workshop unittesting
Workshop unittestingWorkshop unittesting
Workshop unittesting
 
The Magic Of Tie
The Magic Of TieThe Magic Of Tie
The Magic Of Tie
 
PHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look AheadPHP 5.3 And PHP 6 A Look Ahead
PHP 5.3 And PHP 6 A Look Ahead
 
Legacy applications - 4Developes konferencja, Piotr Pasich
Legacy applications  - 4Developes konferencja, Piotr PasichLegacy applications  - 4Developes konferencja, Piotr Pasich
Legacy applications - 4Developes konferencja, Piotr Pasich
 

Similar to vfsStream - effective filesystem mocking

Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
Tammy Hart
 
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
smueller_sandsmedia
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
Lars Jankowfsky
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
Kris Wallsmith
 
Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit Testing
Mike Lively
 
dcs plus Catalogue 2015
dcs plus Catalogue 2015dcs plus Catalogue 2015
dcs plus Catalogue 2015
dcs plus
 
Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHP
Hari K T
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappers
Positive Hack Days
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery Presentation
Sony Jain
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework apps
Michelangelo van Dam
 
PhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsPhpUnit - The most unknown Parts
PhpUnit - The most unknown Parts
Bastian Feder
 
eZ Publish Cluster Unleashed
eZ Publish Cluster UnleashedeZ Publish Cluster Unleashed
eZ Publish Cluster Unleashed
Bertrand Dunogier
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
Michelangelo van Dam
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
Michelangelo van Dam
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
Nate Abele
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
Gordon Forsythe
 
Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnit
Peter Wilcsinszky
 
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QACreating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
archwisp
 
Getting to The Loop - London Wordpress Meetup July 28th
Getting to The Loop - London Wordpress Meetup  July 28thGetting to The Loop - London Wordpress Meetup  July 28th
Getting to The Loop - London Wordpress Meetup July 28th
Chris Adams
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
jsmith92
 

Similar to vfsStream - effective filesystem mocking (20)

Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
 
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit Testing
 
dcs plus Catalogue 2015
dcs plus Catalogue 2015dcs plus Catalogue 2015
dcs plus Catalogue 2015
 
Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHP
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappers
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery Presentation
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework apps
 
PhpUnit - The most unknown Parts
PhpUnit - The most unknown PartsPhpUnit - The most unknown Parts
PhpUnit - The most unknown Parts
 
eZ Publish Cluster Unleashed
eZ Publish Cluster UnleashedeZ Publish Cluster Unleashed
eZ Publish Cluster Unleashed
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnit
 
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QACreating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
 
Getting to The Loop - London Wordpress Meetup July 28th
Getting to The Loop - London Wordpress Meetup  July 28thGetting to The Loop - London Wordpress Meetup  July 28th
Getting to The Loop - London Wordpress Meetup July 28th
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
 

More from Sebastian Marek

The Journey Towards Continuous Integration
The Journey Towards Continuous IntegrationThe Journey Towards Continuous Integration
The Journey Towards Continuous Integration
Sebastian Marek
 
CodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programmingCodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programming
Sebastian Marek
 
Praktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPlPraktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPl
Sebastian Marek
 
Managing and Monitoring Application Performance
Managing and Monitoring Application PerformanceManaging and Monitoring Application Performance
Managing and Monitoring Application Performance
Sebastian Marek
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software Engineer
Sebastian Marek
 
Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!
Sebastian Marek
 
Test your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practiceTest your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practice
Sebastian Marek
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
Sebastian Marek
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
Sebastian Marek
 
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practicePHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
Sebastian Marek
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software Engineer
Sebastian Marek
 
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
Sebastian Marek
 
Magic behind the numbers - software metrics in practice
Magic behind the numbers - software metrics in practiceMagic behind the numbers - software metrics in practice
Magic behind the numbers - software metrics in practice
Sebastian Marek
 
Back to basics - PHPUnit
Back to basics - PHPUnitBack to basics - PHPUnit
Back to basics - PHPUnit
Sebastian Marek
 
Back to basics - PHP_Codesniffer
Back to basics - PHP_CodesnifferBack to basics - PHP_Codesniffer
Back to basics - PHP_Codesniffer
Sebastian Marek
 
Sonar - the ring to rule them all
Sonar - the ring to rule them allSonar - the ring to rule them all
Sonar - the ring to rule them all
Sebastian Marek
 

More from Sebastian Marek (16)

The Journey Towards Continuous Integration
The Journey Towards Continuous IntegrationThe Journey Towards Continuous Integration
The Journey Towards Continuous Integration
 
CodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programmingCodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programming
 
Praktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPlPraktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPl
 
Managing and Monitoring Application Performance
Managing and Monitoring Application PerformanceManaging and Monitoring Application Performance
Managing and Monitoring Application Performance
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software Engineer
 
Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!
 
Test your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practiceTest your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practice
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
 
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practicePHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software Engineer
 
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
 
Magic behind the numbers - software metrics in practice
Magic behind the numbers - software metrics in practiceMagic behind the numbers - software metrics in practice
Magic behind the numbers - software metrics in practice
 
Back to basics - PHPUnit
Back to basics - PHPUnitBack to basics - PHPUnit
Back to basics - PHPUnit
 
Back to basics - PHP_Codesniffer
Back to basics - PHP_CodesnifferBack to basics - PHP_Codesniffer
Back to basics - PHP_Codesniffer
 
Sonar - the ring to rule them all
Sonar - the ring to rule them allSonar - the ring to rule them all
Sonar - the ring to rule them all
 

Recently uploaded

みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 

Recently uploaded (20)

みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 

vfsStream - effective filesystem mocking

  • 1. VfsStream effective filesystem mocking Sebastian Marek
  • 2.
  • 4.
  • 6. 3 rd party
  • 7.
  • 9. Not a dependency REALLY!?
  • 10. Learning by example <?php class Config { private $filename ; public function __construct($filename) { if (!is_file($filename)) { throw new Exception( &quot;Can't set the filename - it doesn't exists!&quot; ); } $this -> filename = $filename; } public function fetchConfig() { return parse_ini_file( $this -> filename , true ); } public function createCacheDir($directory) { if (!is_dir($directory)) { return mkdir($directory, 0700, true ); } return false ; } }
  • 11.
  • 13. guerrillas test case <?php class ConfigTest extends PHPUnit_Framework_TestCase { private $cacheDir = '/tmp/cache' ; private $configFile = '/tmp/config.ini' ; // (...) /** * @covers Config::__construct */ public function testConstructorSetsConfigFilename() { $config = new Config( $this -> configFile ); $this ->assertAttributeEquals( $this -> configFile , 'filename' , $config); } // (...) }
  • 14. guerrillas test case <?php class ConfigTest extends PHPUnit_Framework_TestCase { private $cacheDir = '/tmp/cache' ; private $configFile = '/tmp/config.ini' ; // (...) /** * @covers Config::__construct */ public function testConstructorThrowsExceptionWithInvalidConfigFile() { $configFile = '/share/usr/config.ini' ; $this ->setExpectedException( 'Exception' , &quot;Can't set the filename - it doesn't exists!&quot; ); $config = new Config($configFile); } // (...) }
  • 15. guerrillas test case <?php class ConfigTest extends PHPUnit_Framework_TestCase { private $cacheDir = '/tmp/cache' ; private $configFile = '/tmp/config.ini' ; protected function setUp() { $content = &quot; [section1] key1=value1 key2=value3 [section2] key3=value3 &quot; ; file_put_contents( $this -> configFile , $content); if (!is_dir( $this -> cacheDir )) { mkdir( $this -> cacheDir ); } } // (...) }
  • 16. guerrillas test case class ConfigTest extends PHPUnit_Framework_TestCase { private $cacheDir = '/tmp/cache' ; private $configFile = '/tmp/config.ini' ; // (...) protected function tearDown() { if (is_dir( $this -> cacheDir )) { rmdir( $this -> cacheDir ); } unlink( $this -> configFile ); } // (...) }
  • 17.
  • 18. uses php stream wrapper http://picasaweb.google.co.uk/dawson.jerome/MCASMiramarAirShow2007#5121760885155756402
  • 19. vfsStream installation #> pear channel-discover pear.php-tools.net #> pear install pat/vfsStream-alpha
  • 20. vfsStream - register <?php require_once 'vfsStream/vfsStream.php' // (...) protected function setUp() { vfsStream:: setup ( 'root' ); } // (...)
  • 21. vfsStream & PHPUnit <?php class SomeTest extends PHPUnit_Framework_TestCase { protected function setVfsStream() { @ include_once 'vfsStream/vfsStream.php' ; if (!class_exists( 'vfsStreamWrapper' )) { $this ->markTestSkipped( 'vfsStream is not available - skipping' ); } else { vfsStream:: setup ( 'root' ); } } public function testSomething() { $this ->setVfsStream(); //(...) } }
  • 22. vfsStream – working with files <?php class ConfigTest extends PHPUnit_Framework_TestCase { /** * @covers Config::__construct */ public function testConstructorSetsConfigFilename() { $this ->setVfsStream(); vfsStream::newFile( 'config.ini' )->at(vfsStreamWrapper::getRoot()); $config = new Config(vfsStream::url( 'root/config.ini' )); $this ->assertAttributeEquals(vfsStream::url( 'root/config.ini' ), 'filename' , $config); } // (...) }
  • 23. vfsStream – working with files <?php class ConfigTest extends PHPUnit_Framework_TestCase { /** * @covers Config::__construct */ public function testConstructorThrowsExceptionWithInvalidConfigFile() { $this ->setVfsStream(); $this ->setExpectedException( 'Exception' , &quot;Can't set the filename - it doesn't exists!&quot; ); $config = new Config(vfsStream::url( 'root/config.ini' )); } // (...) }
  • 24. vfsStream url <?php // (...) public function dumpVfsStreamUrl () { $this ->setVfsStream(); echo vfsStream::url( 'root/config.ini' ); // vfs://root/config.ini } // (...) }
  • 25. vfsStream – working with dirs <?php class ConfigTest extends PHPUnit_Framework_TestCase { /** * @covers Config::createCacheDir */ public function testCreateCacheDirIfItDoesntExists() { $this ->setVfsStream(); $this ->assertFileNotExists(vfsStream:: url ( 'root/cache' )); vfsStream:: newFile ( 'config.ini' )->at(vfsStreamWrapper:: getRoot ()); $config = new Config(vfsStream:: url ( 'root/config.ini' )); $config->createCacheDir(vfsStream:: url ( 'root/cache' )); $this ->assertFileExists(vfsStream:: url ( 'root/cache' )); } // (...) }
  • 26. vfsStream – working with dirs <?php class ConfigTest extends PHPUnit_Framework_TestCase { /** * @covers Config::createCacheDir */ public function testDontCreateCacheDirIfItExists() { $this ->setVfsStream(); vfsStream:: newFile ( 'config.ini' )->at(vfsStreamWrapper:: getRoot ()); vfsStream:: newDirectory ( 'cache' )->at(vfsStreamWrapper:: getRoot ()); $this ->assertFileExists(vfsStream:: url ( 'root/cache' )); $config = new Config(vfsStream:: url ( 'root/config.ini' )); $result = $config->createCacheDir(vfsStream:: url ( 'root/cache' )); $this ->assertFalse($result); } // (...) }
  • 27. vfsStream – working with content <?php class ConfigTest extends PHPUnit_Framework_TestCase { /** * @covers Config::fetchConfig */ public function testFetchConfigReturnsArray() { $this ->setVfsStream(); $content = << < 'EOT' [section1] key1 = value1 [section2] key2 = value2 [section3] key3 = value3 EOT; vfsStream:: newFile ( 'config.ini' )->withContent($content) ->at(vfsStreamWrapper:: getRoot ()); $config = new Config(vfsStream:: url ( 'root/config.ini' )); $result = $config->fetchConfig(); $this ->assertTrue(is_array($result)); $this ->assertEquals(3, count($result)); $this ->assertEquals( array ( 'key1' => 'value1' ), $result[ 'section1' ]); $this ->assertEquals( array ( 'key2' => 'value2' ), $result[ 'section2' ]); $this ->assertEquals( array ( 'key3' => 'value3' ), $result[ 'section3' ]); } }
  • 28. vfsStream – file perms new vfsStreamFile( 'app.ini' , 0644); new vfsStreamDirectory( '/home' , 0755); vfsStream:: newFile ( 'app.ini' , 0640); vfsStream:: newDirectory ( '/tmp/cache' , 0755); $vfsStreamFile->chmod(0664); $vfsStreamDirectory->chmod(0700);
  • 29. vfsStream – file ownership $vfsStreamFile->chown(vfsStream:: OWNER_USER_2 ); $vfsStreamDirectory->chown(vfsStream:: OWNER_ROOT ); $vfsStreamFile->chgrp(vfsStream:: GROUP_USER_2 ); $vfsStreamDirectory->chgrp(vfsStream:: GROUP_ROOT );
  • 30.
  • 32.
  • 35.
  • 36. chmod() , chown() , chgrp(), tempnam() doesn't work with streams
  • 37. no support for fileatime() and filectime()
  • 38. realpath() and touch() does not work with any other URLs than pure filenames
  • 40.
  • 41. skips when vfsStream not installed
  • 43. vfsStream PHPUnit Helper <?php class MyClassTest extends PHPUnit_Framework_TestCase { // (...) /** * - It will skip the test if vfsStream is not installed * - It will register vfsStream in default root directory called 'root' * - creates 'tmp' directory in root directory */ public function testCreateDirectoryInDefaultRootDirectory() { $vfsStreamWrapper = new vfsStreamHelper_Wrapper( $this ); $vfsStreamWrapper->createDirectory( &quot;tmp&quot; ); $this ->assertFileExists(vfsStream:: url ( 'root/tmp' )); } // (...) }
  • 44. vfsStream PHPUnit Helper <?php class MyClassTest extends PHPUnit_Framework_TestCase { // (...) /** * - It will skip the test if vfsStream is not installed * - It will register vfsStream in default root directory called 'root' * - creates empty 'myFile.txt' file in root directory */ public function testCreateEmptyFileInDefaultRootDirectory() { $vfsStreamWrapper = new vfsStreamHelper_Wrapper( $this ); $vfsStreamWrapper->createFile( &quot;myFile.txt&quot; ); $this ->assertFileExists(vfsStream:: url ( 'root/myFile.txt' )); } // (...) }
  • 45. vfsStream PHPUnit Helper <?php class MyClassTest extends PHPUnit_Framework_TestCase { // (...) /** * - It will skip the test if vfsStream is not installed * - It will register vfsStream in root directory called 'myDir' * - creates 'home' directory in root directory */ public function testCreateDirectoryInCustomRootDirectory() { $vfsStreamWrapper = new vfsStreamHelper_Wrapper( $this , 'myDir' ); $vfsStreamWrapper->createDirectory( &quot;home&quot; ); $this ->assertFileExists(vfsStream:: url ( 'myDir/home' )); } // (...) }
  • 46. vfsStream PHPUnit Helper <?php class MyClassTest extends PHPUnit_Framework_TestCase { // (...) /** * - It will skip the test if vfsStream is not installed * - It will register vfsStream in default root directory called 'root' * - creates directory in different possible ways */ public function testDifferentWaysOfCreatingDirectories() { $vfsStreamWrapper = new vfsStreamHelper_Wrapper( $this ); // create a single directory $vfsStreamWrapper->createDirectory( &quot;tmp&quot; ); // create nested directories $vfsStreamWrapper->createDirectory( &quot;home/proofek/downloads&quot; ); // create a directory using vfsStreamHelper_Directory in default root $vfsStreamWrapper->createDirectory( new vfsStreamHelper_Directory( 'etc' )); // create a directory using vfsStreamHelper_Directory in a subdirectory $vfsStreamWrapper->createDirectory( new vfsStreamHelper_Directory( 'init.d' , 'etc' ) ); // (...)
  • 47. vfsStream PHPUnit Helper // (...) // create multiple directories $vfsStreamWrapper->createDirectory( array ( new vfsStreamHelper_Directory( 'user1' , 'home' ), new vfsStreamHelper_Directory( 'user2' , 'home' ), new vfsStreamHelper_Directory( 'usr' ), ) ); } // (...) }
  • 48. vfsStream PHPUnit Helper <?php class MyClassTest extends PHPUnit_Framework_TestCase { // (...) /** * - It will skip the test if vfsStream is not installed * - It will register vfsStream in default root directory called 'root' * - creates files in different possible ways */ public function testDifferentWaysOfCreatingFiles() { $vfsStreamWrapper = new vfsStreamHelper_Wrapper( $this ); // create a single empty file in default root directory $vfsStreamWrapper->createFile( &quot;myFile.txt&quot; ); // create a single empty file using vfsStreamHelper_File in default root $vfsStreamWrapper->createFile( new vfsStreamHelper_File( 'anotherFile.txt' ) ); // create a single file with contents using vfsStreamHelper_File in default root $fileContent = &quot;First line in the fileSecond line in the file&quot; ; $vfsStreamWrapper->createFile( new vfsStreamHelper_File( 'thirdFile.txt' , $fileContent) ); // (...)
  • 49. vfsStream PHPUnit Helper // (...) // create a single file with contents using vfsStreamHelper_File in // a subdirectory $fileContent = &quot;First line in the fileSecond line in the file&quot; ; $vfsStreamWrapper->createDirectory( &quot;tmp&quot; ); $vfsStreamWrapper->createFile( new vfsStreamHelper_File( 'file.txt' , $fileContent, 'tmp' ) ); // create multiple files $vfsStreamWrapper->createDirectory( &quot;etc&quot; ); $vfsStreamWrapper->createFile( array ( new vfsStreamHelper_File( 'file1.txt' , 'some content' , 'etc' ), new vfsStreamHelper_File( 'file2.txt' , null , 'etc' ), new vfsStreamHelper_File( 'file3.txt' ), ) ); } // (...) }
  • 50.
  • 52.
  • 53. github - http://github.com/proofek

Editor's Notes

  1. Not full support Helps test things like is_readable(), is_writable() or is_executable() Default file mode 0666 Default dir mode 0777 Subdirs get parents perms