Skip to content

Conversation

@dg
Copy link
Member

@dg dg commented May 29, 2014

Allowes to test functions like parse_ini_file():

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

@mishak87
Copy link

This is neat!

@stepansvoboda
Copy link

Super :)

@fprochazka
Copy link
Contributor

👏

@Vrtak-CZ
Copy link
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
Copy link
Contributor

janmarek commented Jun 6, 2014

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

@dg
Copy link
Member Author

dg commented Jun 6, 2014

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

@janmarek
Copy link
Contributor

janmarek commented Jun 6, 2014

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
Copy link
Member Author

dg commented Jun 6, 2014

Ok.

@dg
Copy link
Member Author

dg commented Jun 6, 2014

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