Permalink
Browse files

initial implementation for issue #15 in order to have same behaviour …

…with PHP 5.2 and 5.3, but without real support of the single stream methods
  • Loading branch information...
mikey179 committed Jul 21, 2011
1 parent 46d01dd commit ef1012201821164a82be6a10666d1d1e53f26647
@@ -457,6 +457,36 @@ public function stream_lock($operation)
return true;
}
+ /**
+ * sets options on the stream
+ *
+ * @param int $option key of option to set
+ * @param int $arg1
+ * @param int $arg2
+ * @return bool
+ * @since 0.10.0
+ * @see https://github.com/mikey179/vfsStream/issues/15
+ * @see http://www.php.net/manual/streamwrapper.stream-set-option.php
+ */
+ public function stream_set_option($option, $arg1, $arg2)
+ {
+ switch ($option) {
+ case STREAM_OPTION_BLOCKING:
+ // break omitted
+
+ case STREAM_OPTION_READ_TIMEOUT:
+ // break omitted
+
+ case STREAM_OPTION_WRITE_BUFFER:
+ // break omitted
+
+ default:
+ // nothing to do here
+ }
+
+ return false;
+ }
+
/**
* remove the data under the given path
*
@@ -0,0 +1,77 @@
+<?php
+/**
+ * Test for stream_set_option() implementation.
+ *
+ * @package bovigo_vfs
+ * @subpackage test
+ */
+require_once 'org/bovigo/vfs/vfsStream.php';
+require_once 'PHPUnit/Framework.php';
+/**
+ * Test for stream_set_option() implementation.
+ *
+ * @package bovigo_vfs
+ * @subpackage test
+ * @since 0.10.0
+ * @see https://github.com/mikey179/vfsStream/issues/15
+ * @group issue_15
+ */
+class vfsStreamWrapperSetOptionTestCase extends PHPUnit_Framework_TestCase
+{
+ /**
+ * root directory
+ *
+ * @var vfsStreamContainer
+ */
+ protected $root;
+
+ /**
+ * set up test environment
+ */
+ public function setUp()
+ {
+ $this->root = vfsStream::setup();
+ vfsStream::newFile('foo.txt')->at($this->root);
+ }
+
+ /**
+ * @test
+ */
+ public function setBlockingDoesNotWork()
+ {
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
+ $this->assertFalse(stream_set_blocking($fp, 1));
+ fclose($fp);
+ }
+
+ /**
+ * @test
+ */
+ public function removeBlockingDoesNotWork()
+ {
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
+ $this->assertFalse(stream_set_blocking($fp, 0));
+ fclose($fp);
+ }
+
+ /**
+ * @test
+ */
+ public function setTimeoutDoesNotWork()
+ {
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
+ $this->assertFalse(stream_set_timeout($fp, 1));
+ fclose($fp);
+ }
+
+ /**
+ * @test
+ */
+ public function setWriteBufferDoesNotWork()
+ {
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
+ $this->assertEquals(-1, stream_set_write_buffer($fp, 512));
+ fclose($fp);
+ }
+}
+?>

0 comments on commit ef10122

Please sign in to comment.