Changeset 1195
- Timestamp:
- 12/29/07 00:31:17 (9 months ago)
- Files:
-
- trunk/build/vfs/package.php (modified) (1 diff)
- trunk/src/main/php/org/stubbles/vfs/vfsStream.php (modified) (1 diff)
- trunk/src/main/php/org/stubbles/vfs/vfsStreamFile.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/util/cache/stubFileCacheContainerTestCase.php (modified) (7 diffs)
- trunk/src/test/php/org/stubbles/vfs/vfsStreamTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/vfs/package.php
r1193 r1195 44 44 - a call to vfsStreamWrapper::register() will now reset the root to null (implemented because of a hint by David Zülke) 45 45 - added support for is_readable(), is_dir(), is_file() 46 - added vfsStream::newFile() to be able to do $file = vfsStream::newFile("foo.txt")->setContent("bar"); 46 47 ')); 47 48 trunk/src/main/php/org/stubbles/vfs/vfsStream.php
r1189 r1195 43 43 return $path; 44 44 } 45 46 /** 47 * returns a new file with given name 48 * 49 * @param string $name 50 * @return vfsStreamFile 51 */ 52 public static function newFile($name) 53 { 54 return new vfsStreamFile($name); 55 } 45 56 } 46 57 ?> trunk/src/main/php/org/stubbles/vfs/vfsStreamFile.php
r1143 r1195 63 63 * sets the contents of the file 64 64 * 65 * @param string $content 65 * @param string $content 66 * @return vfsStreamFile 66 67 */ 67 68 public function setContent($content) 68 69 { 69 70 $this->content = $content; 71 return $this; 70 72 } 71 73 trunk/src/test/php/net/stubbles/util/cache/stubFileCacheContainerTestCase.php
r1183 r1195 76 76 public function testHas() 77 77 { 78 $foo = new vfsStreamFile('foo.cache'); 79 $foo->setContent('bar'); 80 $this->cacheDirectory->addChild($foo); 78 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->setContent('bar')); 81 79 $this->mockCacheStrategy->setReturnValueAt(0, 'isExpired', false); 82 80 $this->mockCacheStrategy->setReturnValueAt(1, 'isExpired', true); … … 92 90 public function testGet() 93 91 { 94 $foo = new vfsStreamFile('foo.cache'); 95 $foo->setContent('bar'); 96 $this->cacheDirectory->addChild($foo); 92 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->setContent('bar')); 97 93 $this->mockCacheStrategy->setReturnValueAt(0, 'isExpired', false); 98 94 $this->mockCacheStrategy->setReturnValueAt(1, 'isExpired', true); … … 108 104 public function testGetSize() 109 105 { 110 $foo = new vfsStreamFile('foo.cache'); 111 $foo->setContent('bar'); 112 $this->cacheDirectory->addChild($foo); 106 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->setContent('bar')); 113 107 $this->mockCacheStrategy->setReturnValueAt(0, 'isExpired', false); 114 108 $this->mockCacheStrategy->setReturnValueAt(1, 'isExpired', true); … … 124 118 public function testGetUsedSpace() 125 119 { 126 $foo = new vfsStreamFile('foo.cache'); 127 $foo->setContent('bar'); 128 $this->cacheDirectory->addChild($foo); 120 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->setContent('bar')); 129 121 $this->assertEqual($this->cacheContainer->getUsedSpace(), 3); 130 122 $this->mockCacheStrategy->setReturnValueAt(0, 'isCachable', true); … … 138 130 public function testGetKeys() 139 131 { 140 $foo = new vfsStreamFile('foo.cache'); 141 $foo->setContent('bar'); 142 $this->cacheDirectory->addChild($foo); 132 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->setContent('bar')); 143 133 $this->mockCacheStrategy->setReturnValueAt(0, 'isExpired', false); 144 134 $this->assertEqual($this->cacheContainer->getKeys(), array('foo' => 'foo')); … … 158 148 public function testGc() 159 149 { 160 $foo = new vfsStreamFile('foo.cache'); 161 $foo->setContent('bar'); 162 $this->cacheDirectory->addChild($foo); 150 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->setContent('bar')); 163 151 $this->mockCacheStrategy->setReturnValue('shouldRunGc', true); 164 152 $this->mockCacheStrategy->setReturnValueAt(0, 'isExpired', false); … … 207 195 public function testtestKeyContainingDirectorySeperatorAndExistingCacheFile() 208 196 { 209 $foo = new vfsStreamFile('barfoo.cache'); 210 $foo->setContent('bar'); 211 $this->cacheDirectory->addChild($foo); 197 $this->cacheDirectory->addChild(vfsStream::newFile('barfoo.cache')->setContent('bar')); 212 198 $this->assertTrue($this->cacheContainer->has('bar' . DIRECTORY_SEPARATOR . 'foo')); 213 199 $this->assertEqual($this->cacheContainer->get('bar' . DIRECTORY_SEPARATOR . 'foo'), 'bar'); trunk/src/test/php/org/stubbles/vfs/vfsStreamTestCase.php
r1189 r1195 36 36 $this->assertEqual('foo/bar.baz', vfsStream::path('vfs://foo\bar.baz')); 37 37 } 38 39 /** 40 * test to create a new file 41 */ 42 public function testNewFile() 43 { 44 $file = vfsStream::newFile('filename.txt'); 45 $this->assertIsA($file, 'vfsStreamFile'); 46 $this->assertEqual('filename.txt', $file->getName()); 47 } 38 48 } 39 49 ?>
