]> source.dussan.org Git - nextcloud-server.git/commitdiff
HHVM Workaround: Do not use Exception from Stream.
authorAndreas Fischer <bantu@owncloud.com>
Fri, 9 Jan 2015 16:01:17 +0000 (17:01 +0100)
committerAndreas Fischer <bantu@owncloud.com>
Fri, 9 Jan 2015 16:01:17 +0000 (17:01 +0100)
Works around https://github.com/facebook/hhvm/issues/2436#issuecomment-69351373

tests/lib/streamwrappers.php

index 9a3b6bc9266908ed251a7d0a2ef6b574bdf2a0ef..2a8c8676c16a04a2126621da15f7abfb7d1c28a9 100644 (file)
@@ -48,20 +48,13 @@ class Test_StreamWrappers extends \Test\TestCase {
                //test callback
                $tmpFile = OC_Helper::TmpFile('.txt');
                $file = 'close://' . $tmpFile;
-               \OC\Files\Stream\Close::registerCallback($tmpFile, array('Test_StreamWrappers', 'closeCallBack'));
+               $actual = false;
+               $callback = function($path) use (&$actual) { $actual = $path; };
+               \OC\Files\Stream\Close::registerCallback($tmpFile, $callback);
                $fh = fopen($file, 'w');
                fwrite($fh, 'asd');
-               try {
-                       fclose($fh);
-                       $this->fail('Expected exception');
-               } catch (Exception $e) {
-                       $path = $e->getMessage();
-                       $this->assertEquals($path, $tmpFile);
-               }
-       }
-
-       public static function closeCallBack($path) {
-               throw new Exception($path);
+               fclose($fh);
+               $this->assertSame($tmpFile, $actual);
        }
 
        public function testOC() {