Skip to content

added Tester\FileMock#137

Merged
dg merged 1 commit into
nette:masterfrom
dg:pull-filemock
May 29, 2014
Merged

added Tester\FileMock#137
dg merged 1 commit into
nette:masterfrom
dg:pull-filemock

Conversation

@dg

@dg dg commented May 29, 2014

Copy link
Copy Markdown
Member

Allowes to test functions like parse_ini_file():

Assert::same(
    array('key' => 'value'), 
    parse_ini_file(FileMock::create('key=value'))
);

@mishak87

Copy link
Copy Markdown

This is neat!

@stepansvoboda

Copy link
Copy Markdown

Super :)

@fprochazka

Copy link
Copy Markdown
Contributor

👏

@Vrtak-CZ

Copy link
Copy Markdown
Contributor

🆒

dg added a commit that referenced this pull request May 29, 2014
@dg dg merged commit e4a4938 into nette:master May 29, 2014
@dg dg deleted the pull-filemock branch May 29, 2014 14:44
@janmarek

janmarek commented Jun 6, 2014

Copy link
Copy Markdown
Contributor

Why not just use http://vfs.bovigo.org/ ? Is it somehow better?

@dg

dg commented Jun 6, 2014

Copy link
Copy Markdown
Member Author

I did not know vfsStream. It seems powerful, FileMock mocks just single files.

@janmarek

janmarek commented Jun 6, 2014

Copy link
Copy Markdown
Contributor

This problem can't be solved better than what they did in vfsStream. It mostly works, but some functions like realpath can't be mocked.

@dg

dg commented Jun 6, 2014

Copy link
Copy Markdown
Member Author

Ok.

@dg

dg commented Jun 6, 2014

Copy link
Copy Markdown
Member Author

Btw, in PHP exists stream data: which can emulate files too:

$file = 'data:text/plain,'.urlencode('Nette Tester');
echo file_get_contents($file); // Nette Tester

but it doesn't work for example with parse_ini_file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants