ecomdev / phpspec-file-matcher
PHPSpec 扩展,增加文件匹配器
    2.0.2
    2016-09-15 09:47 UTC
Requires
- php: >= 5.6
- phpspec/phpspec: ~3.0
Requires (Dev)
README
允许匹配目录/文件的存在以及基本文件内容匹配。
安装
- 
添加 composer 依赖 composer require --dev "ecomdev/phpspec-file-matcher"
- 
将扩展添加到您的 PHPSpec 配置 extensions: EcomDev\PHPSpec\FileMatcher\Extension: ~ 
匹配器
- 
目录存在 - shouldCreateDirectory($path)
- shouldBeDirectory($path)
- shouldHaveDirectory($path)
 
- 
文件存在 - shouldCreateFile($filePath)
- shouldBeFile($filePath)
- shouldHaveFile($filePath)
 
- 
文件内容 - shouldCreateFileContent($filePath, $content)
- shouldHaveFile($filePath, $content)
 
示例
<?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'); } }