diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-09-12 21:43:35 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-09-12 21:43:35 +0200 |
commit | c9d26631592ba58d8026a14e7f637cfe835fa15d (patch) | |
tree | b6bc91006e0207a2e2b26ba5d1205853e0ca7fda /tests | |
parent | b9167196fb331d7197210e4a130e03d32d839b8a (diff) | |
parent | c7ca86799b2608609ead7ecd2d84d0bbd47c6548 (diff) | |
download | nextcloud-server-c9d26631592ba58d8026a14e7f637cfe835fa15d.tar.gz nextcloud-server-c9d26631592ba58d8026a14e7f637cfe835fa15d.zip |
Merge branch 'master' into fileapi-foreward
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/db.php | 2 | ||||
-rw-r--r-- | tests/lib/dbschema.php | 2 | ||||
-rw-r--r-- | tests/lib/files/view.php | 31 | ||||
-rw-r--r-- | tests/lib/image.php | 36 | ||||
-rw-r--r-- | tests/lib/util.php | 4 |
5 files changed, 61 insertions, 14 deletions
diff --git a/tests/lib/db.php b/tests/lib/db.php index 51edbf7b309..1977025cf12 100644 --- a/tests/lib/db.php +++ b/tests/lib/db.php @@ -15,7 +15,7 @@ class Test_DB extends PHPUnit_Framework_TestCase { public function setUp() { $dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml'; - $r = '_'.OC_Util::generate_random_bytes('4').'_'; + $r = '_'.OC_Util::generateRandomBytes('4').'_'; $content = file_get_contents( $dbfile ); $content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content ); file_put_contents( self::$schema_file, $content ); diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php index c2e55eabf4b..7de90c047ca 100644 --- a/tests/lib/dbschema.php +++ b/tests/lib/dbschema.php @@ -16,7 +16,7 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase { $dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml'; $dbfile2 = OC::$SERVERROOT.'/tests/data/db_structure2.xml'; - $r = '_'.OC_Util::generate_random_bytes('4').'_'; + $r = '_'.OC_Util::generateRandomBytes('4').'_'; $content = file_get_contents( $dbfile ); $content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content ); file_put_contents( $this->schema_file, $content ); diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index 3bac9e770aa..0de436f570a 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -25,7 +25,7 @@ class View extends \PHPUnit_Framework_TestCase { //login \OC_User::createUser('test', 'test'); - $this->user=\OC_User::getUser(); + $this->user = \OC_User::getUser(); \OC_User::setUserId('test'); \OC\Files\Filesystem::clearMounts(); @@ -326,6 +326,35 @@ class View extends \PHPUnit_Framework_TestCase { } /** + * @medium + */ + function testViewHooks() { + $storage1 = $this->getTestStorage(); + $storage2 = $this->getTestStorage(); + $defaultRoot = \OC\Files\Filesystem::getRoot(); + \OC\Files\Filesystem::mount($storage1, array(), '/'); + \OC\Files\Filesystem::mount($storage2, array(), $defaultRoot . '/substorage'); + \OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook'); + + $rootView = new \OC\Files\View(''); + $subView = new \OC\Files\View($defaultRoot . '/substorage'); + $this->hookPath = null; + + $rootView->file_put_contents('/foo.txt', 'asd'); + $this->assertNull($this->hookPath); + + $subView->file_put_contents('/foo.txt', 'asd'); + $this->assertNotNull($this->hookPath); + $this->assertEquals('/substorage/foo.txt', $this->hookPath); + } + + private $hookPath; + + function dummyHook($params) { + $this->hookPath = $params['path']; + } + + /** * @param bool $scan * @return \OC\Files\Storage\Storage */ diff --git a/tests/lib/image.php b/tests/lib/image.php index 0583c300075..4aba1b0bc61 100644 --- a/tests/lib/image.php +++ b/tests/lib/image.php @@ -7,6 +7,10 @@ */ class Test_Image extends PHPUnit_Framework_TestCase { + public static function tearDownAfterClass() { + unlink(OC::$SERVERROOT.'/tests/data/testimage2.png'); + unlink(OC::$SERVERROOT.'/tests/data/testimage2.jpg'); + } public function testGetMimeTypeForFile() { $mimetype = \OC_Image::getMimeTypeForFile(OC::$SERVERROOT.'/tests/data/testimage.png'); @@ -55,7 +59,6 @@ class Test_Image extends PHPUnit_Framework_TestCase { } public function testMimeType() { - $this->markTestSkipped("When loading from data or base64, imagetype is always image/png, see #4258."); $img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.png'); $this->assertEquals('image/png', $img->mimeType()); @@ -102,35 +105,50 @@ class Test_Image extends PHPUnit_Framework_TestCase { $img->resize(16); $img->save(OC::$SERVERROOT.'/tests/data/testimage2.png'); $this->assertEquals(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage2.png'), $img->data()); + + $img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.jpg'); + $img->resize(128); + $img->save(OC::$SERVERROOT.'/tests/data/testimage2.jpg'); + $this->assertEquals(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage2.jpg'), $img->data()); } public function testData() { - $this->markTestSkipped("\OC_Image->data() converts to png before outputting data, see #4258."); $img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.png'); - $expected = file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.png'); + $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.png')); + ob_start(); + imagepng($raw); + $expected = ob_get_clean(); $this->assertEquals($expected, $img->data()); $img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.jpg'); - $expected = file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'); + $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg')); + ob_start(); + imagejpeg($raw); + $expected = ob_get_clean(); $this->assertEquals($expected, $img->data()); $img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.gif'); - $expected = file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif'); + $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif')); + ob_start(); + imagegif($raw); + $expected = ob_get_clean(); $this->assertEquals($expected, $img->data()); } + /** + * @depends testData + */ public function testToString() { - $this->markTestSkipped("\OC_Image->data() converts to png before outputting data, see #4258."); $img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.png'); - $expected = base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.png')); + $expected = base64_encode($img->data()); $this->assertEquals($expected, (string)$img); $img = new \OC_Image(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg')); - $expected = base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg')); + $expected = base64_encode($img->data()); $this->assertEquals($expected, (string)$img); $img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.gif'); - $expected = base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif')); + $expected = base64_encode($img->data()); $this->assertEquals($expected, (string)$img); } diff --git a/tests/lib/util.php b/tests/lib/util.php index 13aa49c8c6f..d607a3e7725 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -71,8 +71,8 @@ class Test_Util extends PHPUnit_Framework_TestCase { $this->assertTrue(\OC_Util::isInternetConnectionEnabled()); } - function testGenerate_random_bytes() { - $result = strlen(OC_Util::generate_random_bytes(59)); + function testGenerateRandomBytes() { + $result = strlen(OC_Util::generateRandomBytes(59)); $this->assertEquals(59, $result); } |