Changeset 1196
- Timestamp:
- 12/29/07 00:40:53 (6 months ago)
- Files:
-
- trunk/build/vfs/package.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/vfsStreamFileTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/vfs/package.php
r1195 r1196 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 - added vfsStream::newFile() to be able to do $file = vfsStream::newFile("foo.txt")->withContent("bar"); 47 47 ')); 48 48 trunk/src/main/php/org/stubbles/vfs/vfsStreamFile.php
r1195 r1196 61 61 62 62 /** 63 * alias for withContent() 64 * 65 * @param string $content 66 * @return vfsStreamFile 67 * @see withContent() 68 */ 69 public function setContent($content) 70 { 71 return $this->withContent($content); 72 } 73 74 /** 63 75 * sets the contents of the file 64 76 * 65 77 * @param string $content 66 78 * @return vfsStreamFile 79 * @see setContent() 67 80 */ 68 public function setContent($content)81 public function withContent($content) 69 82 { 70 83 $this->content = $content; trunk/src/test/php/net/stubbles/util/cache/stubFileCacheContainerTestCase.php
r1195 r1196 76 76 public function testHas() 77 77 { 78 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')-> setContent('bar'));78 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->withContent('bar')); 79 79 $this->mockCacheStrategy->setReturnValueAt(0, 'isExpired', false); 80 80 $this->mockCacheStrategy->setReturnValueAt(1, 'isExpired', true); … … 90 90 public function testGet() 91 91 { 92 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')-> setContent('bar'));92 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->withContent('bar')); 93 93 $this->mockCacheStrategy->setReturnValueAt(0, 'isExpired', false); 94 94 $this->mockCacheStrategy->setReturnValueAt(1, 'isExpired', true); … … 104 104 public function testGetSize() 105 105 { 106 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')-> setContent('bar'));106 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->withContent('bar')); 107 107 $this->mockCacheStrategy->setReturnValueAt(0, 'isExpired', false); 108 108 $this->mockCacheStrategy->setReturnValueAt(1, 'isExpired', true); … … 118 118 public function testGetUsedSpace() 119 119 { 120 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')-> setContent('bar'));120 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->withContent('bar')); 121 121 $this->assertEqual($this->cacheContainer->getUsedSpace(), 3); 122 122 $this->mockCacheStrategy->setReturnValueAt(0, 'isCachable', true); … … 130 130 public function testGetKeys() 131 131 { 132 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')-> setContent('bar'));132 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->withContent('bar')); 133 133 $this->mockCacheStrategy->setReturnValueAt(0, 'isExpired', false); 134 134 $this->assertEqual($this->cacheContainer->getKeys(), array('foo' => 'foo')); … … 148 148 public function testGc() 149 149 { 150 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')-> setContent('bar'));150 $this->cacheDirectory->addChild(vfsStream::newFile('foo.cache')->withContent('bar')); 151 151 $this->mockCacheStrategy->setReturnValue('shouldRunGc', true); 152 152 $this->mockCacheStrategy->setReturnValueAt(0, 'isExpired', false); … … 195 195 public function testtestKeyContainingDirectorySeperatorAndExistingCacheFile() 196 196 { 197 $this->cacheDirectory->addChild(vfsStream::newFile('barfoo.cache')-> setContent('bar'));197 $this->cacheDirectory->addChild(vfsStream::newFile('barfoo.cache')->withContent('bar')); 198 198 $this->assertTrue($this->cacheContainer->has('bar' . DIRECTORY_SEPARATOR . 'foo')); 199 199 $this->assertEqual($this->cacheContainer->get('bar' . DIRECTORY_SEPARATOR . 'foo'), 'bar'); trunk/src/test/php/org/stubbles/vfs/vfsStreamFileTestCase.php
r1143 r1196 42 42 $this->assertFalse($this->file->appliesTo('bar')); 43 43 $this->assertFalse($this->file->hasChild('bar')); 44 } 45 46 /** 47 * test setting and getting the content of a file 48 */ 49 public function testContent() 50 { 51 $this->assertNull($this->file->getContent()); 52 $this->assertReference($this->file, $this->file->setContent('bar')); 53 $this->assertEqual('bar', $this->file->getContent()); 54 $this->assertReference($this->file, $this->file->withContent('baz')); 55 $this->assertEqual('baz', $this->file->getContent()); 44 56 } 45 57
