Changeset 1183

Show
Ignore:
Timestamp:
12/25/07 18:14:44 (1 year ago)
Author:
mikey
Message:

moved vfsStreamWrapper::PROTOCOL to vfsStream::SCHEME
added new vfsStream::url() method to assist in creating correct vfsStream urls

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/org/stubbles/vfs/examples/ExampleTestCaseWithVfsStream.php

    r1148 r1183  
    88 */ 
    99require_once 'PHPUnit/Framework.php'; 
    10 require_once 'vfsStream/vfsStreamWrapper.php'; 
     10require_once 'vfsStream/vfsStream.php'; 
    1111require_once 'Example.php'; 
    1212/** 
     
    3434        $example = new Example('id'); 
    3535        $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('id')); 
    36         $example->setDirectory(vfsStreamWrapper::PROTOCOL . '://exampleDir'); 
     36        $example->setDirectory(vfsStream::url('exampleDir')); 
    3737        $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('id')); 
    3838    } 
  • trunk/src/main/php/org/stubbles/vfs/vfsStreamWrapper.php

    r1143 r1183  
    1717{ 
    1818    /** 
    19      * url scheme 
    20      */ 
    21     const PROTOCOL = 'vfs'; 
    22     /** 
    2319     * switch whether class has already been registered as stream wrapper or not 
    2420     * 
     
    5652        } 
    5753 
    58         if (stream_wrapper_register(self::PROTOCOL, __CLASS__) == false) { 
    59             throw new vfsStreamException('A handler has already been registered for the ' . self::PROTOCOL . ' protocol.'); 
     54        if (stream_wrapper_register(vfsStream::SCHEME, __CLASS__) == false) { 
     55            throw new vfsStreamException('A handler has already been registered for the ' . vfsStream::SCHEME . ' protocol.'); 
    6056        } 
    6157 
     
    9187    protected static function parsePath($path) 
    9288    { 
    93         $path = substr($path, strlen(self::PROTOCOL . '://')); 
     89        $path = substr($path, strlen(vfsStream::SCHEME . '://')); 
    9490        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); 
    9591        return $path; 
  • trunk/src/test/php/net/stubbles/util/cache/stubFileCacheContainerTestCase.php

    r1143 r1183  
    99stubClassLoader::load('net.stubbles.util.cache.stubFileCacheContainer'); 
    1010Mock::generate('stubCacheStrategy'); 
    11 require_once TEST_SRC_PATH . '/../main/php/org/stubbles/vfs/vfsStreamWrapper.php'; 
     11require_once TEST_SRC_PATH . '/../main/php/org/stubbles/vfs/vfsStream.php'; 
    1212/** 
    1313 * Tests for net.stubbles.util.cache.stubFileCacheContainer. 
     
    4747        $this->cacheContainer    = new stubFileCacheContainer('id'); 
    4848        $this->cacheContainer->setStrategy($this->mockCacheStrategy); 
    49         $this->cacheContainer->setCacheDirectory(vfsStreamWrapper::PROTOCOL . '://cache'); 
     49        $this->cacheContainer->setCacheDirectory(vfsStream::url('cache')); 
    5050        $this->cacheDirectory    = vfsStreamWrapper::getRoot()->getChild('id'); 
    5151    } 
  • trunk/src/test/php/org/stubbles/vfs/run.php

    r1143 r1183  
    2626        $testSuite->addTestFile($testFilePath . '/vfsStreamFileTestCase.php'); 
    2727        $testSuite->addTestFile($testFilePath . '/vfsStreamDirectoryTestCase.php'); 
     28        $testSuite->addTestFile($testFilePath . '/vfsStreamTestCase.php'); 
    2829        $testSuite->addTestFile($testFilePath . '/vfsStreamWrapperTestCase.php'); 
    2930        if (PHP_SAPI == 'cli') { 
  • trunk/src/test/php/org/stubbles/vfs/vfsStreamWrapperTestCase.php

    r1143 r1183  
    77 * @subpackage  test 
    88 */ 
    9 require_once SRC_PATH . '/main/php/org/stubbles/vfs/vfsStreamWrapper.php'; 
     9require_once SRC_PATH . '/main/php/org/stubbles/vfs/vfsStream.php'; 
    1010Mock::generate('vfsStreamContent'); 
    1111/** 
     
    7171    public function setUp() 
    7272    { 
    73         $this->fooURL  = vfsStreamWrapper::PROTOCOL . '://foo'
    74         $this->barURL  = vfsStreamWrapper::PROTOCOL . '://foo/bar'
    75         $this->baz1URL = vfsStreamWrapper::PROTOCOL . '://foo/bar/baz1'
    76         $this->baz2URL = vfsStreamWrapper::PROTOCOL . '://foo/baz2'
     73        $this->fooURL  = vfsStream::url('foo')
     74        $this->barURL  = vfsStream::url('foo/bar')
     75        $this->baz1URL = vfsStream::url('foo/bar/baz1')
     76        $this->baz2URL = vfsStream::url('foo/baz2')
    7777        $this->foo     = new vfsStreamDirectory('foo'); 
    7878        $this->foo->setFilemtime(100); 
     
    164164        $this->assertTrue(file_exists($this->baz2URL)); 
    165165        $this->assertFalse(file_exists($this->fooURL . '/another')); 
    166         $this->assertFalse(file_exists(vfsStreamWrapper::PROTOCOL . '://another')); 
     166        $this->assertFalse(file_exists(vfsStream::url('another'))); 
    167167    } 
    168168 
     
    190190        $this->assertEqual($this->foo->getChildren(), array()); 
    191191        $this->assertFalse(unlink($this->fooURL . '/another')); 
    192         $this->assertFalse(unlink(vfsStreamWrapper::PROTOCOL . '://another')); 
     192        $this->assertFalse(unlink(vfsStream::url('another'))); 
    193193        $this->assertEqual($this->foo->getChildren(), array()); 
    194194        $this->assertTrue(unlink($this->fooURL)); 
     
    202202    public function testMkdirNoNewRoot() 
    203203    { 
    204         $this->assertFalse(mkdir(vfsStreamWrapper::PROTOCOL . '://another')); 
     204        $this->assertFalse(mkdir(vfsStream::url('another'))); 
    205205        $this->assertEqual(count($this->foo->getChildren()), 2); 
    206206        $this->assertReference($this->foo, vfsStreamWrapper::getRoot());