@ -20,7 +20,7 @@
*
*/
abstract class Test_FileStorage extends UnitTestCase {
abstract class Test_FileStorage extends PHP Unit_Framework_ TestCase {
/**
* @ var OC_Filestorage instance
*/
@ -34,7 +34,7 @@ abstract class Test_FileStorage extends UnitTestCase {
$this -> assertTrue ( $this -> instance -> isReadable ( '/' ), 'Root folder is not readable' );
$this -> assertTrue ( $this -> instance -> is_dir ( '/' ), 'Root folder is not a directory' );
$this -> assertFalse ( $this -> instance -> is_file ( '/' ), 'Root folder is a file' );
$this -> assertEqual ( 'dir' , $this -> instance -> filetype ( '/' ));
$this -> assertEquals ( 'dir' , $this -> instance -> filetype ( '/' ));
//without this, any further testing would be useless, not an acutal requirement for filestorage though
$this -> assertTrue ( $this -> instance -> isUpdatable ( '/' ), 'Root folder is not writable' );
@ -48,8 +48,8 @@ abstract class Test_FileStorage extends UnitTestCase {
$this -> assertTrue ( $this -> instance -> file_exists ( '/folder' ));
$this -> assertTrue ( $this -> instance -> is_dir ( '/folder' ));
$this -> assertFalse ( $this -> instance -> is_file ( '/folder' ));
$this -> assertEqual ( 'dir' , $this -> instance -> filetype ( '/folder' ));
$this -> assertEqual ( 0 , $this -> instance -> filesize ( '/folder' ));
$this -> assertEquals ( 'dir' , $this -> instance -> filetype ( '/folder' ));
$this -> assertEquals ( 0 , $this -> instance -> filesize ( '/folder' ));
$this -> assertTrue ( $this -> instance -> isReadable ( '/folder' ));
$this -> assertTrue ( $this -> instance -> isUpdatable ( '/folder' ));
@ -60,7 +60,7 @@ abstract class Test_FileStorage extends UnitTestCase {
$content [] = $file ;
}
}
$this -> assertEqual ( array ( 'folder' ), $content );
$this -> assertEquals ( array ( 'folder' ), $content );
$this -> assertFalse ( $this -> instance -> mkdir ( '/folder' )); //cant create existing folders
$this -> assertTrue ( $this -> instance -> rmdir ( '/folder' ));
@ -76,7 +76,7 @@ abstract class Test_FileStorage extends UnitTestCase {
$content [] = $file ;
}
}
$this -> assertEqual ( array (), $content );
$this -> assertEquals ( array (), $content );
}
/**
@ -89,31 +89,31 @@ abstract class Test_FileStorage extends UnitTestCase {
//fill a file with string data
$this -> instance -> file_put_contents ( '/lorem.txt' , $sourceText );
$this -> assertFalse ( $this -> instance -> is_dir ( '/lorem.txt' ));
$this -> assertEqual ( $sourceText , $this -> instance -> file_get_contents ( '/lorem.txt' ), 'data returned from file_get_contents is not equal to the source data' );
$this -> assertEquals ( $sourceText , $this -> instance -> file_get_contents ( '/lorem.txt' ), 'data returned from file_get_contents is not equal to the source data' );
//empty the file
$this -> instance -> file_put_contents ( '/lorem.txt' , '' );
$this -> assertEqual ( '' , $this -> instance -> file_get_contents ( '/lorem.txt' ), 'file not emptied' );
$this -> assertEquals ( '' , $this -> instance -> file_get_contents ( '/lorem.txt' ), 'file not emptied' );
}
/**
* test various known mimetypes
*/
public function testMimeType () {
$this -> assertEqual ( 'httpd/unix-directory' , $this -> instance -> getMimeType ( '/' ));
$this -> assertEqual ( false , $this -> instance -> getMimeType ( '/non/existing/file' ));
$this -> assertEquals ( 'httpd/unix-directory' , $this -> instance -> getMimeType ( '/' ));
$this -> assertEquals ( false , $this -> instance -> getMimeType ( '/non/existing/file' ));
$textFile = OC :: $SERVERROOT . '/tests/data/lorem.txt' ;
$this -> instance -> file_put_contents ( '/lorem.txt' , file_get_contents ( $textFile , 'r' ));
$this -> assertEqual ( 'text/plain' , $this -> instance -> getMimeType ( '/lorem.txt' ));
$this -> assertEquals ( 'text/plain' , $this -> instance -> getMimeType ( '/lorem.txt' ));
$pngFile = OC :: $SERVERROOT . '/tests/data/logo-wide.png' ;
$this -> instance -> file_put_contents ( '/logo-wide.png' , file_get_contents ( $pngFile , 'r' ));
$this -> assertEqual ( 'image/png' , $this -> instance -> getMimeType ( '/logo-wide.png' ));
$this -> assertEquals ( 'image/png' , $this -> instance -> getMimeType ( '/logo-wide.png' ));
$svgFile = OC :: $SERVERROOT . '/tests/data/logo-wide.svg' ;
$this -> instance -> file_put_contents ( '/logo-wide.svg' , file_get_contents ( $svgFile , 'r' ));
$this -> assertEqual ( 'image/svg+xml' , $this -> instance -> getMimeType ( '/logo-wide.svg' ));
$this -> assertEquals ( 'image/svg+xml' , $this -> instance -> getMimeType ( '/logo-wide.svg' ));
}
public function testCopyAndMove () {
@ -121,12 +121,12 @@ abstract class Test_FileStorage extends UnitTestCase {
$this -> instance -> file_put_contents ( '/source.txt' , file_get_contents ( $textFile ));
$this -> instance -> copy ( '/source.txt' , '/target.txt' );
$this -> assertTrue ( $this -> instance -> file_exists ( '/target.txt' ));
$this -> assertEqual ( $this -> instance -> file_get_contents ( '/source.txt' ), $this -> instance -> file_get_contents ( '/target.txt' ));
$this -> assertEquals ( $this -> instance -> file_get_contents ( '/source.txt' ), $this -> instance -> file_get_contents ( '/target.txt' ));
$this -> instance -> rename ( '/source.txt' , '/target2.txt' );
$this -> assertTrue ( $this -> instance -> file_exists ( '/target2.txt' ));
$this -> assertFalse ( $this -> instance -> file_exists ( '/source.txt' ));
$this -> assertEqual ( file_get_contents ( $textFile ), $this -> instance -> file_get_contents ( '/target.txt' ));
$this -> assertEquals ( file_get_contents ( $textFile ), $this -> instance -> file_get_contents ( '/target.txt' ));
}
public function testLocal () {
@ -134,7 +134,7 @@ abstract class Test_FileStorage extends UnitTestCase {
$this -> instance -> file_put_contents ( '/lorem.txt' , file_get_contents ( $textFile ));
$localFile = $this -> instance -> getLocalFile ( '/lorem.txt' );
$this -> assertTrue ( file_exists ( $localFile ));
$this -> assertEqual ( file_get_contents ( $localFile ), file_get_contents ( $textFile ));
$this -> assertEquals ( file_get_contents ( $localFile ), file_get_contents ( $textFile ));
$this -> instance -> mkdir ( '/folder' );
$this -> instance -> file_put_contents ( '/folder/lorem.txt' , file_get_contents ( $textFile ));
@ -145,9 +145,9 @@ abstract class Test_FileStorage extends UnitTestCase {
$this -> assertTrue ( is_dir ( $localFolder ));
$this -> assertTrue ( file_exists ( $localFolder . '/lorem.txt' ));
$this -> assertEqual ( file_get_contents ( $localFolder . '/lorem.txt' ), file_get_contents ( $textFile ));
$this -> assertEqual ( file_get_contents ( $localFolder . '/bar.txt' ), 'asd' );
$this -> assertEqual ( file_get_contents ( $localFolder . '/recursive/file.txt' ), 'foo' );
$this -> assertEquals ( file_get_contents ( $localFolder . '/lorem.txt' ), file_get_contents ( $textFile ));
$this -> assertEquals ( file_get_contents ( $localFolder . '/bar.txt' ), 'asd' );
$this -> assertEquals ( file_get_contents ( $localFolder . '/recursive/file.txt' ), 'foo' );
}
public function testStat () {
@ -162,12 +162,12 @@ abstract class Test_FileStorage extends UnitTestCase {
$this -> assertTrue (( $ctimeStart - 1 ) <= $mTime );
$this -> assertTrue ( $mTime <= ( $ctimeEnd + 1 ));
$this -> assertEqual ( filesize ( $textFile ), $this -> instance -> filesize ( '/lorem.txt' ));
$this -> assertEquals ( filesize ( $textFile ), $this -> instance -> filesize ( '/lorem.txt' ));
$stat = $this -> instance -> stat ( '/lorem.txt' );
//only size and mtime are requered in the result
$this -> assertEqual ( $stat [ 'size' ], $this -> instance -> filesize ( '/lorem.txt' ));
$this -> assertEqual ( $stat [ 'mtime' ], $mTime );
$this -> assertEquals ( $stat [ 'size' ], $this -> instance -> filesize ( '/lorem.txt' ));
$this -> assertEquals ( $stat [ 'mtime' ], $mTime );
$mtimeStart = time ();
$supportsTouch = $this -> instance -> touch ( '/lorem.txt' );
@ -181,7 +181,7 @@ abstract class Test_FileStorage extends UnitTestCase {
if ( $this -> instance -> touch ( '/lorem.txt' , 100 ) !== false ) {
$mTime = $this -> instance -> filemtime ( '/lorem.txt' );
$this -> assertEqual ( $mTime , 100 );
$this -> assertEquals ( $mTime , 100 );
}
}
@ -207,7 +207,7 @@ abstract class Test_FileStorage extends UnitTestCase {
$svgFile = OC :: $SERVERROOT . '/tests/data/logo-wide.svg' ;
$this -> instance -> file_put_contents ( '/logo-wide.svg' , file_get_contents ( $svgFile , 'r' ));
$result = $this -> instance -> search ( 'logo' );
$this -> assertEqual ( 2 , count ( $result ));
$this -> assertEquals ( 2 , count ( $result ));
$this -> assertContains ( '/logo-wide.svg' , $result );
$this -> assertContains ( '/logo-wide.png' , $result );
}
@ -229,6 +229,6 @@ abstract class Test_FileStorage extends UnitTestCase {
$fh = $this -> instance -> fopen ( 'foo' , 'r' );
$content = stream_get_contents ( $fh );
$this -> assertEqual ( file_get_contents ( $textFile ), $content );
$this -> assertEquals ( file_get_contents ( $textFile ), $content );
}
}