Halleck45 / MutaTesting

mutation testing tool for PHP
MIT License
65 stars 10 forks source link

MutaTesting incompatible with vfsStreamWrapper #7

Closed DennisBecker closed 11 months ago

DennisBecker commented 11 years ago

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?

Halleck45 commented 11 years ago

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

sdhepse commented 9 years ago

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

macieklag commented 5 years ago

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