MutaTesting icon indicating copy to clipboard operation
MutaTesting copied to clipboard

MutaTesting incompatible with vfsStreamWrapper

Open DennisBecker opened this issue 12 years ago • 3 comments

I use vfsStreamWrapper in some test cases to mock the filesystem in unit tests. The tests initialize vfsStreamWrapper properly and all tests run fine in PHPUnit. You can find it at https://github.com/mikey179/vfsStream

When I run MutaTesting on these tests, I get the following error:

PHP Warning:  file_get_contents(): Unable to find the wrapper "vfs" - did you forget to enable it when you configured PHP? in /...../MutaTesting/src/Hal/MutaTesting/Command/RunMutatingCommand.php on line 127

I have created a simple example which runs fine but when I run the whole test suite of my project it is unable to run the tests properly.

mutation testing tool for PHP, by Jean-François Lépine

Executing first run...
  39 tests executed (196 assertions)
  OK
Extracting tested files for each test...

.......................................
Executing mutations...
PHP Warning:  file_get_contents(): Unable to find the wrapper "vfs" - did you forget to enable it when you configured PHP? in /...../MutaTesting/src/Hal/MutaTesting/Command/RunMutatingCommand.php on line 127
PHP Warning:  file_get_contents(vfs://views/test.phtml): failed to open stream: No such file or directory in /...../MutaTesting/src/Hal/MutaTesting/Command/RunMutatingCommand.php on line 127
PHP Warning:  file_get_contents(): Unable to find the wrapper "vfs" - did you forget to enable it when you configured PHP? in /...../MutaTesting/src/Hal/MutaTesting/Command/RunMutatingCommand.php on line 127
PHP Warning:  file_get_contents(vfs://views/test.phtml): failed to open stream: No such file or directory in /...../MutaTesting/src/Hal/MutaTesting/Command/RunMutatingCommand.php on line 127
Killed

This is the small working example:

<?php

namespace test;

use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamWrapper;

class vfsStreamTest extends \PHPUnit_Framework_TestCase
{

    public function setUp()
    {
        if (!class_exists('\org\bovigo\vfs\vfsStreamDirectory')) {
            throw new \Exception('vfsStream is not installed');
        }
    }

    public function testDataIsStored()
    {
        vfsStream::setup('tmp', null, array('data.txt' => 'äöü'));

        $this->assertEquals('äöü', file_get_contents(vfsStream::url('tmp/data.txt')));
    }
}

Any idea what happens that it doesn't work? And why does it try to open vfs://views/test.phtml which gets created in the test class?

DennisBecker avatar Jun 12 '13 10:06 DennisBecker

MutaTesting use its own StreamWrapper for file. I think there is a conflict. I'll see the StreamWrapper used by bovigo...

Halleck45 avatar Jun 14 '13 04:06 Halleck45

@DennisBecker : Hey.. Did you get any solution for this ?

sdhepse avatar Jul 16 '15 18:07 sdhepse

You forgot to register wrapper vfsStreamWrapper::register();

macieklag avatar Apr 16 '19 09:04 macieklag