[TYPO3-50-general] vfsstream and braindeath

Christoph Blömer chbloemer at gmx.net
Sat Feb 14 10:40:32 CET 2009


Hello,
last night I was writing a unit test for my Virtual File System package. 
I wanted to navigate through the filesystem and check if the correct 
folders and files can be retrieved.
But the tests always failed. A little later i noticed that if files were 
read once they a removed from the vfsstream.
This is a test I wrote to verify the behaviour.
$this->url1 is the root of the vfsstream root.
If it is a normal filesystem the test works.
count($list2) is always 0!!!

    /**
     * @test
     */         
    public function vfsstream(){
        
        $dir = $this->url1;
        $list1 = array();      
        if ($handle = opendir($dir)) {
            while (false !== ($listItem = readdir($handle))) {
                if ($listItem != "." && $listItem != "..") {
                    if(is_file($dir.'/'.$listItem)) {
                        $list1[] = "File:[".$listItem."]";
                    } else if(is_dir($dir.'/'.$listItem)) {
                        $list1[] = "Folder:[".$listItem."]";
                    }
                }
            }
            closedir($handle);
        }

        $list2 = array();        
        if ($handle = opendir($dir)) {
            while (false !== ($listItem = readdir($handle))) {
                if ($listItem != "." && $listItem != "..") {
                    if(is_file($dir.'/'.$listItem)) {
                        $list2[] = "File:[".$listItem."]";
                    } else if(is_dir($dir.'/'.$listItem)) {
                        $list2[] = "Folder:[".$listItem."]";
                    }
                }
            }
            closedir($handle);
        }
        $this->assertEquals(count($list1), count($list2));
}

Any ideas what's wrong or how to prevent this problem?

Greetings
Christoph


More information about the TYPO3-project-5_0-general mailing list