diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/db_structure.xml | 4 | ||||
-rw-r--r-- | tests/data/db_structure2.xml | 2 | ||||
-rw-r--r-- | tests/lib/db.php | 11 | ||||
-rw-r--r-- | tests/lib/dbschema.php | 14 | ||||
-rw-r--r-- | tests/lib/files/cache/watcher.php | 6 | ||||
-rw-r--r-- | tests/lib/files/mapper.php | 18 | ||||
-rw-r--r-- | tests/lib/files/view.php | 24 | ||||
-rw-r--r-- | tests/lib/geo.php | 4 | ||||
-rw-r--r-- | tests/lib/helper.php | 9 | ||||
-rw-r--r-- | tests/phpunit-autotest.xml | 11 |
10 files changed, 89 insertions, 14 deletions
diff --git a/tests/data/db_structure.xml b/tests/data/db_structure.xml index af2e5ce3439..8f6dc5e2ecd 100644 --- a/tests/data/db_structure.xml +++ b/tests/data/db_structure.xml @@ -9,7 +9,7 @@ <table> - <name>*dbprefix*contacts_addressbooks</name> + <name>*dbprefix*cntcts_addrsbks</name> <declaration> @@ -77,7 +77,7 @@ <table> - <name>*dbprefix*contacts_cards</name> + <name>*dbprefix*cntcts_cards</name> <declaration> diff --git a/tests/data/db_structure2.xml b/tests/data/db_structure2.xml index c1bbb550483..fc6fe0bba7d 100644 --- a/tests/data/db_structure2.xml +++ b/tests/data/db_structure2.xml @@ -9,7 +9,7 @@ <table> - <name>*dbprefix*contacts_addressbooks</name> + <name>*dbprefix*cntcts_addrsbks</name> <declaration> diff --git a/tests/lib/db.php b/tests/lib/db.php index eff01bd9065..afbdb413c3d 100644 --- a/tests/lib/db.php +++ b/tests/lib/db.php @@ -22,8 +22,8 @@ class Test_DB extends PHPUnit_Framework_TestCase { OC_DB::createDbFromStructure(self::$schema_file); $this->test_prefix = $r; - $this->table1 = $this->test_prefix.'contacts_addressbooks'; - $this->table2 = $this->test_prefix.'contacts_cards'; + $this->table1 = $this->test_prefix.'cntcts_addrsbks'; + $this->table2 = $this->test_prefix.'cntcts_cards'; $this->table3 = $this->test_prefix.'vcategory'; } @@ -37,7 +37,7 @@ class Test_DB extends PHPUnit_Framework_TestCase { $result = $query->execute(array('uri_1')); $this->assertTrue((bool)$result); $row = $result->fetchRow(); - $this->assertFalse($row); + $this->assertFalse((bool)$row); //PDO returns false, MDB2 returns null $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)'); $result = $query->execute(array('fullname test', 'uri_1')); $this->assertTrue((bool)$result); @@ -48,9 +48,12 @@ class Test_DB extends PHPUnit_Framework_TestCase { $this->assertArrayHasKey('fullname', $row); $this->assertEquals($row['fullname'], 'fullname test'); $row = $result->fetchRow(); - $this->assertFalse($row); + $this->assertFalse((bool)$row); //PDO returns false, MDB2 returns null } + /** + * @medium + */ public function testNOW() { $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (NOW(),?)'); $result = $query->execute(array('uri_2')); diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php index e20a04ef7fd..59f203993ef 100644 --- a/tests/lib/dbschema.php +++ b/tests/lib/dbschema.php @@ -26,8 +26,8 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase { file_put_contents( self::$schema_file2, $content ); $this->test_prefix = $r; - $this->table1 = $this->test_prefix.'contacts_addressbooks'; - $this->table2 = $this->test_prefix.'contacts_cards'; + $this->table1 = $this->test_prefix.'cntcts_addrsbks'; + $this->table2 = $this->test_prefix.'cntcts_cards'; } public function tearDown() { @@ -36,6 +36,9 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase { } // everything in one test, they depend on each other + /** + * @medium + */ public function testSchema() { $this->doTestSchemaCreating(); $this->doTestSchemaChanging(); @@ -91,13 +94,18 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase { break; case 'pgsql': $sql = "SELECT tablename AS table_name, schemaname AS schema_name " - . "FROM pg_tables WHERE schemaname NOT LIKE 'pg_%' " + . "FROM pg_tables WHERE schemaname NOT LIKE 'pg_%' " . "AND schemaname != 'information_schema' " . "AND tablename = '".$table."'"; $query = OC_DB::prepare($sql); $result = $query->execute(array()); $exists = $result && $result->fetchOne(); break; + case 'oci': + $sql = 'SELECT table_name FROM user_tables WHERE table_name = ?'; + $result = \OC_DB::executeAudited($sql, array($table)); + $exists = (bool)$result->fetchOne(); //oracle uses MDB2 and returns null + break; case 'mssql': $sql = "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{$table}'"; $query = OC_DB::prepare($sql); diff --git a/tests/lib/files/cache/watcher.php b/tests/lib/files/cache/watcher.php index e43c86ed438..749b1ab75a3 100644 --- a/tests/lib/files/cache/watcher.php +++ b/tests/lib/files/cache/watcher.php @@ -29,6 +29,9 @@ class Watcher extends \PHPUnit_Framework_TestCase { } } + /** + * @medium + */ function testWatcher() { $storage = $this->getTestStorage(); $cache = $storage->getCache(); @@ -63,6 +66,9 @@ class Watcher extends \PHPUnit_Framework_TestCase { $this->assertFalse($cache->inCache('folder/bar2.txt')); } + /** + * @medium + */ public function testFileToFolder() { $storage = $this->getTestStorage(); $cache = $storage->getCache(); diff --git a/tests/lib/files/mapper.php b/tests/lib/files/mapper.php index e3859bc0f23..48ae95b7e72 100644 --- a/tests/lib/files/mapper.php +++ b/tests/lib/files/mapper.php @@ -45,8 +45,20 @@ class Mapper extends \PHPUnit_Framework_TestCase { $this->assertEquals('D:/a/b/text', $this->mapper->slugifyPath('D:/a/b/text')); // with double dot - $this->assertEquals('D:/text-text.txt', $this->mapper->slugifyPath('D:/text.text.txt')); - $this->assertEquals('D:/text-text-2.txt', $this->mapper->slugifyPath('D:/text.text.txt', 2)); - $this->assertEquals('D:/a/b/text-text.txt', $this->mapper->slugifyPath('D:/a/b/text.text.txt')); + $this->assertEquals('D:/text.text.txt', $this->mapper->slugifyPath('D:/text.text.txt')); + $this->assertEquals('D:/text.text-2.txt', $this->mapper->slugifyPath('D:/text.text.txt', 2)); + $this->assertEquals('D:/a/b/text.text.txt', $this->mapper->slugifyPath('D:/a/b/text.text.txt')); + + // foldername and filename with periods + $this->assertEquals('D:/folder.name.with.periods', $this->mapper->slugifyPath('D:/folder.name.with.periods')); + $this->assertEquals('D:/folder.name.with.periods/test-2.txt', $this->mapper->slugifyPath('D:/folder.name.with.periods/test.txt', 2)); + $this->assertEquals('D:/folder.name.with.periods/test.txt', $this->mapper->slugifyPath('D:/folder.name.with.periods/test.txt')); + + // foldername and filename with periods and spaces + $this->assertEquals('D:/folder.name.with.peri-ods', $this->mapper->slugifyPath('D:/folder.name.with.peri ods')); + $this->assertEquals('D:/folder.name.with.peri-ods/te-st-2.t-x-t', $this->mapper->slugifyPath('D:/folder.name.with.peri ods/te st.t x t', 2)); + $this->assertEquals('D:/folder.name.with.peri-ods/te-st.t-x-t', $this->mapper->slugifyPath('D:/folder.name.with.peri ods/te st.t x t')); + + } } diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index 01f9a9cca11..830913a91ad 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -33,6 +33,9 @@ class View extends \PHPUnit_Framework_TestCase { } } + /** + * @medium + */ public function testCacheAPI() { $storage1 = $this->getTestStorage(); $storage2 = $this->getTestStorage(); @@ -104,6 +107,9 @@ class View extends \PHPUnit_Framework_TestCase { $this->assertEquals(array(), $rootView->getDirectoryContent('/non/existing')); } + /** + * @medium + */ function testGetPath() { $storage1 = $this->getTestStorage(); $storage2 = $this->getTestStorage(); @@ -127,6 +133,9 @@ class View extends \PHPUnit_Framework_TestCase { $this->assertNull($folderView->getPath($id1)); } + /** + * @medium + */ function testMountPointOverwrite() { $storage1 = $this->getTestStorage(false); $storage2 = $this->getTestStorage(); @@ -170,6 +179,9 @@ class View extends \PHPUnit_Framework_TestCase { $this->assertEquals($textSize, $folderData[0]['size']); } + /** + * @medium + */ function testSearch() { $storage1 = $this->getTestStorage(); $storage2 = $this->getTestStorage(); @@ -217,6 +229,9 @@ class View extends \PHPUnit_Framework_TestCase { $this->assertEquals(3, count($folderView->searchByMime('text'))); } + /** + * @medium + */ function testWatcher() { $storage1 = $this->getTestStorage(); \OC\Files\Filesystem::mount($storage1, array(), '/'); @@ -234,6 +249,9 @@ class View extends \PHPUnit_Framework_TestCase { $this->assertEquals(3, $cachedData['size']); } + /** + * @medium + */ function testCopyBetweenStorages() { $storage1 = $this->getTestStorage(); $storage2 = $this->getTestStorage(); @@ -255,6 +273,9 @@ class View extends \PHPUnit_Framework_TestCase { $this->assertTrue($rootView->file_exists('/substorage/folder/bar.txt')); } + /** + * @medium + */ function testMoveBetweenStorages() { $storage1 = $this->getTestStorage(); $storage2 = $this->getTestStorage(); @@ -271,6 +292,9 @@ class View extends \PHPUnit_Framework_TestCase { $this->assertTrue($rootView->file_exists('anotherfolder/bar.txt')); } + /** + * @medium + */ function testTouch() { $storage = $this->getTestStorage(true, '\Test\Files\TemporaryNoTouch'); diff --git a/tests/lib/geo.php b/tests/lib/geo.php index 82e61608687..2c3611c092e 100644 --- a/tests/lib/geo.php +++ b/tests/lib/geo.php @@ -7,6 +7,10 @@ */ class Test_Geo extends PHPUnit_Framework_TestCase { + + /** + * @medium + */ function testTimezone() { $result = OC_Geo::timezone(3, 3); $expected = 'Africa/Porto-Novo'; diff --git a/tests/lib/helper.php b/tests/lib/helper.php index 336e8f8b3c5..6acb0dfaa6b 100644 --- a/tests/lib/helper.php +++ b/tests/lib/helper.php @@ -67,6 +67,15 @@ class Test_Helper extends PHPUnit_Framework_TestCase { $this->assertEquals($result, $expected); } + function testGetFileNameMimeType() { + $this->assertEquals('text/plain', OC_Helper::getFileNameMimeType('foo.txt')); + $this->assertEquals('image/png', OC_Helper::getFileNameMimeType('foo.png')); + $this->assertEquals('image/png', OC_Helper::getFileNameMimeType('foo.bar.png')); + $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('.png')); + $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('foo')); + $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('')); + } + function testGetStringMimeType() { $result = OC_Helper::getStringMimeType("/data/data.tar.gz"); $expected = 'text/plain; charset=us-ascii'; diff --git a/tests/phpunit-autotest.xml b/tests/phpunit-autotest.xml index e9ee7d8d70d..23b2d6c0060 100644 --- a/tests/phpunit-autotest.xml +++ b/tests/phpunit-autotest.xml @@ -1,5 +1,10 @@ <?xml version="1.0" encoding="utf-8" ?> -<phpunit bootstrap="bootstrap.php"> +<phpunit bootstrap="bootstrap.php" + strict="true" + timeoutForSmallTests="900" + timeoutForMediumTests="900" + timeoutForLargeTests="900" +> <testsuite name='ownCloud'> <directory suffix='.php'>lib/</directory> <file>apps.php</file> @@ -22,6 +27,10 @@ <directory suffix=".php">../apps/user_ldap/l10n</directory> <directory suffix=".php">../apps/user_webdavauth/l10n</directory> <directory suffix=".php">../lib/MDB2</directory> + <directory suffix=".php">../lib/l10n</directory> + <directory suffix=".php">../core/l10n</directory> + <directory suffix=".php">../settings/l10n</directory> + <directory suffix=".php">../tests</directory> </exclude> </whitelist> </filter> |