ecomdev / phpspec-file-matcher
PHPSpec extension that adds file matcher
2.0.2
2016-09-15 09:47 UTC
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'); } }