ecomdev / phpspec-file-matcher
PHPSpec extension that adds file matcher
Installs: 96
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 2
Open Issues: 0
pkg:composer/ecomdev/phpspec-file-matcher
Requires
- php: >= 5.6
- phpspec/phpspec: ~3.0
Requires (Dev)
README
Allows to match directory/file existence and basic file content match.
Installation
- 
Add composer dependency composer require --dev "ecomdev/phpspec-file-matcher"
- 
Add extension to your PHPSpec configuration extensions: EcomDev\PHPSpec\FileMatcher\Extension: ~ 
Matchers
- 
Directory existence: - shouldCreateDirectory($path)
- shouldBeDirectory($path)
- shouldHaveDirectory($path)
 
- 
File existence: - shouldCreateFile($filePath)
- shouldBeFile($filePath)
- shouldHaveFile($filePath)
 
- 
File content: - shouldCreateFileContent($filePath, $content)
- shouldHaveFile($filePath, $content)
 
Example
<?php namespace spec\Example; use PhpSpec\ObjectBehavior; class FileSpec extends ObjectBehavior { function it_creates_a_file_on_save() { $this->save('file.txt', 'some_nice_content') ->shouldCreateFile('file.txt') ->shouldHaveFileContent('file.txt', 'some_nice_content'); } }