@@ -300,7 +300,6 @@ |
||
| 300 | 300 | * {@inheritDoc} |
| 301 | 301 | * |
| 302 | 302 | * @param string $path Path to the remote file |
| 303 | - * @param string $file Path to the local file |
|
| 304 | 303 | * @return void |
| 305 | 304 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 306 | 305 | */ |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @param array $config Configuration options |
| 30 | 30 | */ |
| 31 | - public function __construct( array $config ) |
|
| 31 | + public function __construct(array $config) |
|
| 32 | 32 | { |
| 33 | 33 | $this->config = $config; |
| 34 | 34 | |
| 35 | - if( !isset( $config['tempdir'] ) ) { |
|
| 35 | + if (!isset($config['tempdir'])) { |
|
| 36 | 36 | $config['tempdir'] = sys_get_temp_dir(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if( !is_dir( $config['tempdir'] ) && mkdir( $config['tempdir'], 0755, true ) === false ) { |
|
| 40 | - throw new Exception( sprintf( 'Directory "%1$s" could not be created', $config['tempdir'] ) ); |
|
| 39 | + if (!is_dir($config['tempdir']) && mkdir($config['tempdir'], 0755, true) === false) { |
|
| 40 | + throw new Exception(sprintf('Directory "%1$s" could not be created', $config['tempdir'])); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $ds = DIRECTORY_SEPARATOR; |
| 44 | - $this->tempdir = realpath( str_replace( '/', $ds, rtrim( $config['tempdir'], '/' ) ) ) . $ds; |
|
| 44 | + $this->tempdir = realpath(str_replace('/', $ds, rtrim($config['tempdir'], '/'))) . $ds; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | * @return boolean True if directory, false if not |
| 53 | 53 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 54 | 54 | */ |
| 55 | - public function isdir( $path ) |
|
| 55 | + public function isdir($path) |
|
| 56 | 56 | { |
| 57 | - $result = $this->getProvider()->getMetadata( $path ); |
|
| 57 | + $result = $this->getProvider()->getMetadata($path); |
|
| 58 | 58 | |
| 59 | - if( $result['type'] === 'dir' ) { |
|
| 59 | + if ($result['type'] === 'dir') { |
|
| 60 | 60 | return true; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | * @return void |
| 72 | 72 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 73 | 73 | */ |
| 74 | - public function mkdir( $path ) |
|
| 74 | + public function mkdir($path) |
|
| 75 | 75 | { |
| 76 | - if( $this->getProvider()->createDir( $path ) === false ) { |
|
| 77 | - throw new Exception( $path ); |
|
| 76 | + if ($this->getProvider()->createDir($path) === false) { |
|
| 77 | + throw new Exception($path); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | * @return void |
| 87 | 87 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 88 | 88 | */ |
| 89 | - public function rmdir( $path ) |
|
| 89 | + public function rmdir($path) |
|
| 90 | 90 | { |
| 91 | - if( $this->getProvider()->deleteDir( $path ) === false ) { |
|
| 92 | - throw new Exception( $path ); |
|
| 91 | + if ($this->getProvider()->deleteDir($path) === false) { |
|
| 92 | + throw new Exception($path); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | * @return \Iterator|array Iterator over the entries or array with entries |
| 104 | 104 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 105 | 105 | */ |
| 106 | - public function scan( $path = null ) |
|
| 106 | + public function scan($path = null) |
|
| 107 | 107 | { |
| 108 | 108 | $list = array(); |
| 109 | 109 | |
| 110 | - foreach( $this->getProvider()->listContents( $path ) as $entry ) { |
|
| 110 | + foreach ($this->getProvider()->listContents($path) as $entry) { |
|
| 111 | 111 | $list[] = $entry['basename']; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -122,16 +122,16 @@ discard block |
||
| 122 | 122 | * @return integer Size in bytes |
| 123 | 123 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 124 | 124 | */ |
| 125 | - public function size( $path ) |
|
| 125 | + public function size($path) |
|
| 126 | 126 | { |
| 127 | 127 | try { |
| 128 | - $size = $this->getProvider()->getSize( $path ); |
|
| 129 | - } catch( \Exception $e ) { |
|
| 130 | - throw new Exception( $e->getMessage(), 0, $e ); |
|
| 128 | + $size = $this->getProvider()->getSize($path); |
|
| 129 | + } catch (\Exception $e) { |
|
| 130 | + throw new Exception($e->getMessage(), 0, $e); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if( $size === false ) { |
|
| 134 | - throw new Exception( $path ); |
|
| 133 | + if ($size === false) { |
|
| 134 | + throw new Exception($path); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | return $size; |
@@ -145,16 +145,16 @@ discard block |
||
| 145 | 145 | * @return integer Unix time stamp in seconds |
| 146 | 146 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 147 | 147 | */ |
| 148 | - public function time( $path ) |
|
| 148 | + public function time($path) |
|
| 149 | 149 | { |
| 150 | 150 | try { |
| 151 | - $time = $this->getProvider()->getTimestamp( $path ); |
|
| 152 | - } catch( \Exception $e ) { |
|
| 153 | - throw new Exception( $e->getMessage(), 0, $e ); |
|
| 151 | + $time = $this->getProvider()->getTimestamp($path); |
|
| 152 | + } catch (\Exception $e) { |
|
| 153 | + throw new Exception($e->getMessage(), 0, $e); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if( $time === false ) { |
|
| 157 | - throw new Exception( $path ); |
|
| 156 | + if ($time === false) { |
|
| 157 | + throw new Exception($path); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | return $time; |
@@ -168,12 +168,12 @@ discard block |
||
| 168 | 168 | * @return void |
| 169 | 169 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 170 | 170 | */ |
| 171 | - public function rm( $path ) |
|
| 171 | + public function rm($path) |
|
| 172 | 172 | { |
| 173 | 173 | try { |
| 174 | - $this->getProvider()->delete( $path ); |
|
| 175 | - } catch( \Exception $e ) { |
|
| 176 | - throw new Exception( $e->getMessage(), 0, $e ); |
|
| 174 | + $this->getProvider()->delete($path); |
|
| 175 | + } catch (\Exception $e) { |
|
| 176 | + throw new Exception($e->getMessage(), 0, $e); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | * @param string $path Path to the file |
| 185 | 185 | * @return boolean True if it exists, false if not |
| 186 | 186 | */ |
| 187 | - public function has( $path ) |
|
| 187 | + public function has($path) |
|
| 188 | 188 | { |
| 189 | - return $this->getProvider()->has( $path ); |
|
| 189 | + return $this->getProvider()->has($path); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | |
@@ -199,16 +199,16 @@ discard block |
||
| 199 | 199 | * @return string File content |
| 200 | 200 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 201 | 201 | */ |
| 202 | - public function read( $path ) |
|
| 202 | + public function read($path) |
|
| 203 | 203 | { |
| 204 | 204 | try { |
| 205 | - $content = $this->getProvider()->read( $path ); |
|
| 206 | - } catch( \Exception $e ) { |
|
| 207 | - throw new Exception( $e->getMessage(), 0, $e ); |
|
| 205 | + $content = $this->getProvider()->read($path); |
|
| 206 | + } catch (\Exception $e) { |
|
| 207 | + throw new Exception($e->getMessage(), 0, $e); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if( $content === false ) { |
|
| 211 | - throw new Exception( $path ); |
|
| 210 | + if ($content === false) { |
|
| 211 | + throw new Exception($path); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | return $content; |
@@ -222,24 +222,24 @@ discard block |
||
| 222 | 222 | * @return string Path of the local file |
| 223 | 223 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 224 | 224 | */ |
| 225 | - public function readf( $path ) |
|
| 225 | + public function readf($path) |
|
| 226 | 226 | { |
| 227 | - if( ( $filename = tempnam( $this->tempdir, 'ai-' ) ) === false ) { |
|
| 228 | - throw new Exception( sprintf( 'Unable to create file in "%1$s"', $this->tempdir ) ); |
|
| 227 | + if (($filename = tempnam($this->tempdir, 'ai-')) === false) { |
|
| 228 | + throw new Exception(sprintf('Unable to create file in "%1$s"', $this->tempdir)); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if( ( $handle = @fopen( $filename, 'w' ) ) === false ) { |
|
| 232 | - throw new Exception( sprintf( 'Unable to open file "%1$s"', $filename ) ); |
|
| 231 | + if (($handle = @fopen($filename, 'w')) === false) { |
|
| 232 | + throw new Exception(sprintf('Unable to open file "%1$s"', $filename)); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - $stream = $this->reads( $path ); |
|
| 235 | + $stream = $this->reads($path); |
|
| 236 | 236 | |
| 237 | - if( @stream_copy_to_stream( $stream, $handle ) == false ) { |
|
| 238 | - throw new Exception( sprintf( 'Couldn\'t copy stream for "%1$s"', $path ) ); |
|
| 237 | + if (@stream_copy_to_stream($stream, $handle) == false) { |
|
| 238 | + throw new Exception(sprintf('Couldn\'t copy stream for "%1$s"', $path)); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - fclose( $stream ); |
|
| 242 | - fclose( $handle ); |
|
| 241 | + fclose($stream); |
|
| 242 | + fclose($handle); |
|
| 243 | 243 | |
| 244 | 244 | return $filename; |
| 245 | 245 | } |
@@ -254,16 +254,16 @@ discard block |
||
| 254 | 254 | * @return resource File stream descriptor |
| 255 | 255 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 256 | 256 | */ |
| 257 | - public function reads( $path ) |
|
| 257 | + public function reads($path) |
|
| 258 | 258 | { |
| 259 | 259 | try { |
| 260 | - $handle = $this->getProvider()->readStream( $path ); |
|
| 261 | - } catch( \Exception $e ) { |
|
| 262 | - throw new Exception( $e->getMessage(), 0, $e ); |
|
| 260 | + $handle = $this->getProvider()->readStream($path); |
|
| 261 | + } catch (\Exception $e) { |
|
| 262 | + throw new Exception($e->getMessage(), 0, $e); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if( $handle === false ) { |
|
| 266 | - throw new Exception( $path ); |
|
| 265 | + if ($handle === false) { |
|
| 266 | + throw new Exception($path); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | return $handle; |
@@ -280,16 +280,16 @@ discard block |
||
| 280 | 280 | * @return void |
| 281 | 281 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 282 | 282 | */ |
| 283 | - public function write( $path, $content ) |
|
| 283 | + public function write($path, $content) |
|
| 284 | 284 | { |
| 285 | 285 | try { |
| 286 | - $result = $this->getProvider()->put( $path, $content ); |
|
| 287 | - } catch( \Exception $e ) { |
|
| 288 | - throw new Exception( $e->getMessage(), 0, $e ); |
|
| 286 | + $result = $this->getProvider()->put($path, $content); |
|
| 287 | + } catch (\Exception $e) { |
|
| 288 | + throw new Exception($e->getMessage(), 0, $e); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if( $result === false ) { |
|
| 292 | - throw new Exception( $path ); |
|
| 291 | + if ($result === false) { |
|
| 292 | + throw new Exception($path); |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | |
@@ -304,16 +304,16 @@ discard block |
||
| 304 | 304 | * @return void |
| 305 | 305 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 306 | 306 | */ |
| 307 | - public function writef( $path, $local ) |
|
| 307 | + public function writef($path, $local) |
|
| 308 | 308 | { |
| 309 | - if( ( $handle = @fopen( $local, 'r' ) ) === false ) { |
|
| 310 | - throw new Exception( sprintf( 'Unable to open file "%1$s"', $local ) ); |
|
| 309 | + if (($handle = @fopen($local, 'r')) === false) { |
|
| 310 | + throw new Exception(sprintf('Unable to open file "%1$s"', $local)); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - $this->writes( $path, $handle ); |
|
| 313 | + $this->writes($path, $handle); |
|
| 314 | 314 | |
| 315 | - if( is_resource( $handle ) ) { |
|
| 316 | - fclose( $handle ); |
|
| 315 | + if (is_resource($handle)) { |
|
| 316 | + fclose($handle); |
|
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | |
@@ -328,16 +328,16 @@ discard block |
||
| 328 | 328 | * @return void |
| 329 | 329 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 330 | 330 | */ |
| 331 | - public function writes( $path, $stream ) |
|
| 331 | + public function writes($path, $stream) |
|
| 332 | 332 | { |
| 333 | 333 | try { |
| 334 | - $result = $this->getProvider()->putStream( $path, $stream ); |
|
| 335 | - } catch( \Exception $e ) { |
|
| 336 | - throw new Exception( $e->getMessage(), 0, $e ); |
|
| 334 | + $result = $this->getProvider()->putStream($path, $stream); |
|
| 335 | + } catch (\Exception $e) { |
|
| 336 | + throw new Exception($e->getMessage(), 0, $e); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - if( $result === false ) { |
|
| 340 | - throw new Exception( $path ); |
|
| 339 | + if ($result === false) { |
|
| 340 | + throw new Exception($path); |
|
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | |
@@ -350,16 +350,16 @@ discard block |
||
| 350 | 350 | * @return void |
| 351 | 351 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 352 | 352 | */ |
| 353 | - public function move( $from, $to ) |
|
| 353 | + public function move($from, $to) |
|
| 354 | 354 | { |
| 355 | 355 | try { |
| 356 | - $result = $this->getProvider()->rename( $from, $to ); |
|
| 357 | - } catch( \Exception $e ) { |
|
| 358 | - throw new Exception( $e->getMessage(), 0, $e ); |
|
| 356 | + $result = $this->getProvider()->rename($from, $to); |
|
| 357 | + } catch (\Exception $e) { |
|
| 358 | + throw new Exception($e->getMessage(), 0, $e); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - if( $result === false ) { |
|
| 362 | - throw new Exception( sprintf( 'Error moving "%1$s" to "%2$s"', $from, $to ) ); |
|
| 361 | + if ($result === false) { |
|
| 362 | + throw new Exception(sprintf('Error moving "%1$s" to "%2$s"', $from, $to)); |
|
| 363 | 363 | } |
| 364 | 364 | } |
| 365 | 365 | |
@@ -372,16 +372,16 @@ discard block |
||
| 372 | 372 | * @return void |
| 373 | 373 | * @throws \Aimeos\MW\Filesystem\Exception If an error occurs |
| 374 | 374 | */ |
| 375 | - public function copy( $from, $to ) |
|
| 375 | + public function copy($from, $to) |
|
| 376 | 376 | { |
| 377 | 377 | try { |
| 378 | - $result = $this->getProvider()->copy( $from, $to ); |
|
| 379 | - } catch( \Exception $e ) { |
|
| 380 | - throw new Exception( $e->getMessage(), 0, $e ); |
|
| 378 | + $result = $this->getProvider()->copy($from, $to); |
|
| 379 | + } catch (\Exception $e) { |
|
| 380 | + throw new Exception($e->getMessage(), 0, $e); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if( $result === false ) { |
|
| 384 | - throw new Exception( sprintf( 'Error copying "%1$s" to "%2$s"', $from, $to ) ); |
|
| 383 | + if ($result === false) { |
|
| 384 | + throw new Exception(sprintf('Error copying "%1$s" to "%2$s"', $from, $to)); |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
@@ -11,394 +11,394 @@ |
||
| 11 | 11 | |
| 12 | 12 | protected function setUp() |
| 13 | 13 | { |
| 14 | - if( !interface_exists( '\\League\\Flysystem\\FilesystemInterface' ) ) { |
|
| 15 | - $this->markTestSkipped( 'Install Flysystem first' ); |
|
| 14 | + if (!interface_exists('\\League\\Flysystem\\FilesystemInterface')) { |
|
| 15 | + $this->markTestSkipped('Install Flysystem first'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - $this->object = $this->getMockBuilder( '\\Aimeos\\MW\\Filesystem\\FlyNone' ) |
|
| 19 | - ->setConstructorArgs( array( array( 'adapter' => 'FlyNone' ) ) ) |
|
| 20 | - ->setMethods( array( 'getProvider' ) ) |
|
| 18 | + $this->object = $this->getMockBuilder('\\Aimeos\\MW\\Filesystem\\FlyNone') |
|
| 19 | + ->setConstructorArgs(array(array('adapter' => 'FlyNone'))) |
|
| 20 | + ->setMethods(array('getProvider')) |
|
| 21 | 21 | ->getMock(); |
| 22 | 22 | |
| 23 | - $this->mock = $this->getMockBuilder( '\\League\\Flysystem\\FilesystemInterface' ) |
|
| 23 | + $this->mock = $this->getMockBuilder('\\League\\Flysystem\\FilesystemInterface') |
|
| 24 | 24 | ->disableOriginalConstructor() |
| 25 | 25 | ->getMock(); |
| 26 | 26 | |
| 27 | - $this->object->expects( $this->once() )->method( 'getProvider' ) |
|
| 28 | - ->will( $this->returnValue( $this->mock ) ); |
|
| 27 | + $this->object->expects($this->once())->method('getProvider') |
|
| 28 | + ->will($this->returnValue($this->mock)); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | protected function tearDown() |
| 33 | 33 | { |
| 34 | - unset( $this->object, $this->mock ); |
|
| 34 | + unset($this->object, $this->mock); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | public function testIsdir() |
| 39 | 39 | { |
| 40 | - $this->mock->expects( $this->once() )->method( 'getMetadata' ) |
|
| 41 | - ->will( $this->returnValue( array( 'type' => 'dir' ) ) ); |
|
| 40 | + $this->mock->expects($this->once())->method('getMetadata') |
|
| 41 | + ->will($this->returnValue(array('type' => 'dir'))); |
|
| 42 | 42 | |
| 43 | - $this->assertTrue( $this->object->isdir( 'test' ) ); |
|
| 43 | + $this->assertTrue($this->object->isdir('test')); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | public function testIsdirFalse() |
| 48 | 48 | { |
| 49 | - $this->mock->expects( $this->once() )->method( 'getMetadata' ) |
|
| 50 | - ->will( $this->returnValue( array( 'type' => 'file' ) ) ); |
|
| 49 | + $this->mock->expects($this->once())->method('getMetadata') |
|
| 50 | + ->will($this->returnValue(array('type' => 'file'))); |
|
| 51 | 51 | |
| 52 | - $this->assertFalse( $this->object->isdir( 'test' ) ); |
|
| 52 | + $this->assertFalse($this->object->isdir('test')); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | public function testMkdir() |
| 57 | 57 | { |
| 58 | - $this->mock->expects( $this->once() )->method( 'createDir' ) |
|
| 59 | - ->will( $this->returnValue( true ) ); |
|
| 58 | + $this->mock->expects($this->once())->method('createDir') |
|
| 59 | + ->will($this->returnValue(true)); |
|
| 60 | 60 | |
| 61 | - $this->object->mkdir( 'test' ); |
|
| 61 | + $this->object->mkdir('test'); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | public function testMkdirException() |
| 66 | 66 | { |
| 67 | - $this->mock->expects( $this->once() )->method( 'createDir' ) |
|
| 68 | - ->will( $this->returnValue( false ) ); |
|
| 67 | + $this->mock->expects($this->once())->method('createDir') |
|
| 68 | + ->will($this->returnValue(false)); |
|
| 69 | 69 | |
| 70 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 71 | - $this->object->mkdir( 'test' ); |
|
| 70 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 71 | + $this->object->mkdir('test'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | public function testRmdir() |
| 76 | 76 | { |
| 77 | - $this->mock->expects( $this->once() )->method( 'deleteDir' ) |
|
| 78 | - ->will( $this->returnValue( true ) ); |
|
| 77 | + $this->mock->expects($this->once())->method('deleteDir') |
|
| 78 | + ->will($this->returnValue(true)); |
|
| 79 | 79 | |
| 80 | - $this->object->rmdir( 'test' ); |
|
| 80 | + $this->object->rmdir('test'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | public function testRmdirException() |
| 85 | 85 | { |
| 86 | - $this->mock->expects( $this->once() )->method( 'deleteDir' ) |
|
| 87 | - ->will( $this->returnValue( false ) ); |
|
| 86 | + $this->mock->expects($this->once())->method('deleteDir') |
|
| 87 | + ->will($this->returnValue(false)); |
|
| 88 | 88 | |
| 89 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 90 | - $this->object->rmdir( 'test' ); |
|
| 89 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 90 | + $this->object->rmdir('test'); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | public function testScan() |
| 95 | 95 | { |
| 96 | - $this->mock->expects( $this->once() )->method( 'listContents' ) |
|
| 97 | - ->will( $this->returnValue( array( array( 'basename' => 'test' ) ) ) ); |
|
| 96 | + $this->mock->expects($this->once())->method('listContents') |
|
| 97 | + ->will($this->returnValue(array(array('basename' => 'test')))); |
|
| 98 | 98 | |
| 99 | - $this->assertEquals( array( 'test' ), $this->object->scan() ); |
|
| 99 | + $this->assertEquals(array('test'), $this->object->scan()); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | public function testSize() |
| 104 | 104 | { |
| 105 | - $this->mock->expects( $this->once() )->method( 'getSize' ) |
|
| 106 | - ->will( $this->returnValue( 4 ) ); |
|
| 105 | + $this->mock->expects($this->once())->method('getSize') |
|
| 106 | + ->will($this->returnValue(4)); |
|
| 107 | 107 | |
| 108 | - $this->assertEquals( 4, $this->object->size( 'test' ) ); |
|
| 108 | + $this->assertEquals(4, $this->object->size('test')); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
| 112 | 112 | public function testSizeException() |
| 113 | 113 | { |
| 114 | - $this->mock->expects( $this->once() )->method( 'getSize' ) |
|
| 115 | - ->will( $this->returnValue( false ) ); |
|
| 114 | + $this->mock->expects($this->once())->method('getSize') |
|
| 115 | + ->will($this->returnValue(false)); |
|
| 116 | 116 | |
| 117 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 118 | - $this->object->size( 'test' ); |
|
| 117 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 118 | + $this->object->size('test'); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
| 122 | 122 | public function testSizeException2() |
| 123 | 123 | { |
| 124 | - $this->mock->expects( $this->once() )->method( 'getSize' ) |
|
| 125 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 124 | + $this->mock->expects($this->once())->method('getSize') |
|
| 125 | + ->will($this->throwException(new \Exception())); |
|
| 126 | 126 | |
| 127 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 128 | - $this->object->size( 'test' ); |
|
| 127 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 128 | + $this->object->size('test'); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | |
| 132 | 132 | public function testTime() |
| 133 | 133 | { |
| 134 | - $this->mock->expects( $this->once() )->method( 'getTimestamp' ) |
|
| 135 | - ->will( $this->returnValue( 4 ) ); |
|
| 134 | + $this->mock->expects($this->once())->method('getTimestamp') |
|
| 135 | + ->will($this->returnValue(4)); |
|
| 136 | 136 | |
| 137 | - $this->assertEquals( 4, $this->object->time( 'test' ) ); |
|
| 137 | + $this->assertEquals(4, $this->object->time('test')); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | |
| 141 | 141 | public function testTimeException() |
| 142 | 142 | { |
| 143 | - $this->mock->expects( $this->once() )->method( 'getTimestamp' ) |
|
| 144 | - ->will( $this->returnValue( false ) ); |
|
| 143 | + $this->mock->expects($this->once())->method('getTimestamp') |
|
| 144 | + ->will($this->returnValue(false)); |
|
| 145 | 145 | |
| 146 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 147 | - $this->object->time( 'test' ); |
|
| 146 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 147 | + $this->object->time('test'); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | |
| 151 | 151 | public function testTimeException2() |
| 152 | 152 | { |
| 153 | - $this->mock->expects( $this->once() )->method( 'getTimestamp' ) |
|
| 154 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 153 | + $this->mock->expects($this->once())->method('getTimestamp') |
|
| 154 | + ->will($this->throwException(new \Exception())); |
|
| 155 | 155 | |
| 156 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 157 | - $this->object->time( 'test' ); |
|
| 156 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 157 | + $this->object->time('test'); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
| 161 | 161 | public function testRm() |
| 162 | 162 | { |
| 163 | - $this->mock->expects( $this->once() )->method( 'delete' ) |
|
| 164 | - ->will( $this->returnValue( 4 ) ); |
|
| 163 | + $this->mock->expects($this->once())->method('delete') |
|
| 164 | + ->will($this->returnValue(4)); |
|
| 165 | 165 | |
| 166 | - $this->object->rm( 'test' ); |
|
| 166 | + $this->object->rm('test'); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | |
| 170 | 170 | public function testRmException() |
| 171 | 171 | { |
| 172 | - $this->mock->expects( $this->once() )->method( 'delete' ) |
|
| 173 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 172 | + $this->mock->expects($this->once())->method('delete') |
|
| 173 | + ->will($this->throwException(new \Exception())); |
|
| 174 | 174 | |
| 175 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 176 | - $this->object->rm( 'test' ); |
|
| 175 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 176 | + $this->object->rm('test'); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
| 180 | 180 | public function testHas() |
| 181 | 181 | { |
| 182 | - $this->mock->expects( $this->once() )->method( 'has' ) |
|
| 183 | - ->will( $this->returnValue( true ) ); |
|
| 182 | + $this->mock->expects($this->once())->method('has') |
|
| 183 | + ->will($this->returnValue(true)); |
|
| 184 | 184 | |
| 185 | - $result = $this->object->has( 'test' ); |
|
| 185 | + $result = $this->object->has('test'); |
|
| 186 | 186 | |
| 187 | - $this->assertTrue( $result ); |
|
| 187 | + $this->assertTrue($result); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | |
| 191 | 191 | public function testHasFalse() |
| 192 | 192 | { |
| 193 | - $this->mock->expects( $this->once() )->method( 'has' ) |
|
| 194 | - ->will( $this->returnValue( false ) ); |
|
| 193 | + $this->mock->expects($this->once())->method('has') |
|
| 194 | + ->will($this->returnValue(false)); |
|
| 195 | 195 | |
| 196 | - $result = $this->object->has( 'test' ); |
|
| 196 | + $result = $this->object->has('test'); |
|
| 197 | 197 | |
| 198 | - $this->assertFalse( $result ); |
|
| 198 | + $this->assertFalse($result); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | public function testRead() |
| 203 | 203 | { |
| 204 | - $this->mock->expects( $this->once() )->method( 'read' ) |
|
| 205 | - ->will( $this->returnValue( 'value' ) ); |
|
| 204 | + $this->mock->expects($this->once())->method('read') |
|
| 205 | + ->will($this->returnValue('value')); |
|
| 206 | 206 | |
| 207 | - $this->assertEquals( 'value', $this->object->read( 'test' ) ); |
|
| 207 | + $this->assertEquals('value', $this->object->read('test')); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | |
| 211 | 211 | public function testReadException() |
| 212 | 212 | { |
| 213 | - $this->mock->expects( $this->once() )->method( 'read' ) |
|
| 214 | - ->will( $this->returnValue( false ) ); |
|
| 213 | + $this->mock->expects($this->once())->method('read') |
|
| 214 | + ->will($this->returnValue(false)); |
|
| 215 | 215 | |
| 216 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 217 | - $this->object->read( 'test' ); |
|
| 216 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 217 | + $this->object->read('test'); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | |
| 221 | 221 | public function testReadException2() |
| 222 | 222 | { |
| 223 | - $this->mock->expects( $this->once() )->method( 'read' ) |
|
| 224 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 223 | + $this->mock->expects($this->once())->method('read') |
|
| 224 | + ->will($this->throwException(new \Exception())); |
|
| 225 | 225 | |
| 226 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 227 | - $this->object->read( 'test' ); |
|
| 226 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 227 | + $this->object->read('test'); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | |
| 231 | 231 | public function testReadf() |
| 232 | 232 | { |
| 233 | 233 | $file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'flytest'; |
| 234 | - file_put_contents( $file, 'test' ); |
|
| 234 | + file_put_contents($file, 'test'); |
|
| 235 | 235 | |
| 236 | - $this->mock->expects( $this->once() )->method( 'readStream' ) |
|
| 237 | - ->will( $this->returnValue( fopen( $file, 'r' ) ) ); |
|
| 236 | + $this->mock->expects($this->once())->method('readStream') |
|
| 237 | + ->will($this->returnValue(fopen($file, 'r'))); |
|
| 238 | 238 | |
| 239 | - $result = $this->object->readf( 'file' ); |
|
| 239 | + $result = $this->object->readf('file'); |
|
| 240 | 240 | |
| 241 | - $this->assertEquals( 'test', file_get_contents( $result ) ); |
|
| 241 | + $this->assertEquals('test', file_get_contents($result)); |
|
| 242 | 242 | |
| 243 | - unlink( $result ); |
|
| 244 | - unlink( $file ); |
|
| 243 | + unlink($result); |
|
| 244 | + unlink($file); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
| 248 | 248 | public function testReads() |
| 249 | 249 | { |
| 250 | - $this->mock->expects( $this->once() )->method( 'readStream' ) |
|
| 251 | - ->will( $this->returnValue( 1 ) ); |
|
| 250 | + $this->mock->expects($this->once())->method('readStream') |
|
| 251 | + ->will($this->returnValue(1)); |
|
| 252 | 252 | |
| 253 | - $this->assertEquals( 1, $this->object->reads( 'test' ) ); |
|
| 253 | + $this->assertEquals(1, $this->object->reads('test')); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | |
| 257 | 257 | public function testReadsException() |
| 258 | 258 | { |
| 259 | - $this->mock->expects( $this->once() )->method( 'readStream' ) |
|
| 260 | - ->will( $this->returnValue( false ) ); |
|
| 259 | + $this->mock->expects($this->once())->method('readStream') |
|
| 260 | + ->will($this->returnValue(false)); |
|
| 261 | 261 | |
| 262 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 263 | - $this->object->reads( 'test' ); |
|
| 262 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 263 | + $this->object->reads('test'); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
| 267 | 267 | public function testReadsException2() |
| 268 | 268 | { |
| 269 | - $this->mock->expects( $this->once() )->method( 'readStream' ) |
|
| 270 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 269 | + $this->mock->expects($this->once())->method('readStream') |
|
| 270 | + ->will($this->throwException(new \Exception())); |
|
| 271 | 271 | |
| 272 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 273 | - $this->object->reads( 'test' ); |
|
| 272 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 273 | + $this->object->reads('test'); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | |
| 277 | 277 | public function testWrite() |
| 278 | 278 | { |
| 279 | - $this->mock->expects( $this->once() )->method( 'put' ) |
|
| 280 | - ->will( $this->returnValue( true ) ); |
|
| 279 | + $this->mock->expects($this->once())->method('put') |
|
| 280 | + ->will($this->returnValue(true)); |
|
| 281 | 281 | |
| 282 | - $this->object->write( 'test', 'value' ); |
|
| 282 | + $this->object->write('test', 'value'); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | |
| 286 | 286 | public function testWriteException() |
| 287 | 287 | { |
| 288 | - $this->mock->expects( $this->once() )->method( 'put' ) |
|
| 289 | - ->will( $this->returnValue( false ) ); |
|
| 288 | + $this->mock->expects($this->once())->method('put') |
|
| 289 | + ->will($this->returnValue(false)); |
|
| 290 | 290 | |
| 291 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 292 | - $this->object->write( 'test', 'value' ); |
|
| 291 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 292 | + $this->object->write('test', 'value'); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | |
| 296 | 296 | public function testWriteException2() |
| 297 | 297 | { |
| 298 | - $this->mock->expects( $this->once() )->method( 'put' ) |
|
| 299 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 298 | + $this->mock->expects($this->once())->method('put') |
|
| 299 | + ->will($this->throwException(new \Exception())); |
|
| 300 | 300 | |
| 301 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 302 | - $this->object->write( 'test', 'value' ); |
|
| 301 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 302 | + $this->object->write('test', 'value'); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | |
| 306 | 306 | public function testWritef() |
| 307 | 307 | { |
| 308 | 308 | $file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'flytest'; |
| 309 | - file_put_contents( $file, 'test' ); |
|
| 309 | + file_put_contents($file, 'test'); |
|
| 310 | 310 | |
| 311 | - $this->mock->expects( $this->once() )->method( 'putStream' ); |
|
| 311 | + $this->mock->expects($this->once())->method('putStream'); |
|
| 312 | 312 | |
| 313 | - $this->object->writef( 'file', $file ); |
|
| 313 | + $this->object->writef('file', $file); |
|
| 314 | 314 | |
| 315 | - unlink( $file ); |
|
| 315 | + unlink($file); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | public function testWrites() |
| 320 | 320 | { |
| 321 | - $this->mock->expects( $this->once() )->method( 'putStream' ) |
|
| 322 | - ->will( $this->returnValue( true ) ); |
|
| 321 | + $this->mock->expects($this->once())->method('putStream') |
|
| 322 | + ->will($this->returnValue(true)); |
|
| 323 | 323 | |
| 324 | - $this->object->writes( 'test', 1 ); |
|
| 324 | + $this->object->writes('test', 1); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | |
| 328 | 328 | public function testWritesException() |
| 329 | 329 | { |
| 330 | - $this->mock->expects( $this->once() )->method( 'putStream' ) |
|
| 331 | - ->will( $this->returnValue( false ) ); |
|
| 330 | + $this->mock->expects($this->once())->method('putStream') |
|
| 331 | + ->will($this->returnValue(false)); |
|
| 332 | 332 | |
| 333 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 334 | - $this->object->writes( 'test', 2 ); |
|
| 333 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 334 | + $this->object->writes('test', 2); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | |
| 338 | 338 | public function testWritesException2() |
| 339 | 339 | { |
| 340 | - $this->mock->expects( $this->once() )->method( 'putStream' ) |
|
| 341 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 340 | + $this->mock->expects($this->once())->method('putStream') |
|
| 341 | + ->will($this->throwException(new \Exception())); |
|
| 342 | 342 | |
| 343 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 344 | - $this->object->writes( 'test', null ); |
|
| 343 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 344 | + $this->object->writes('test', null); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | |
| 348 | 348 | public function testMove() |
| 349 | 349 | { |
| 350 | - $this->mock->expects( $this->once() )->method( 'rename' ) |
|
| 351 | - ->will( $this->returnValue( true ) ); |
|
| 350 | + $this->mock->expects($this->once())->method('rename') |
|
| 351 | + ->will($this->returnValue(true)); |
|
| 352 | 352 | |
| 353 | - $this->object->move( 'file1', 'file2' ); |
|
| 353 | + $this->object->move('file1', 'file2'); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | |
| 357 | 357 | public function testMoveException() |
| 358 | 358 | { |
| 359 | - $this->mock->expects( $this->once() )->method( 'rename' ) |
|
| 360 | - ->will( $this->returnValue( false ) ); |
|
| 359 | + $this->mock->expects($this->once())->method('rename') |
|
| 360 | + ->will($this->returnValue(false)); |
|
| 361 | 361 | |
| 362 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 363 | - $this->object->move( 'file1', 'file2' ); |
|
| 362 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 363 | + $this->object->move('file1', 'file2'); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | |
| 367 | 367 | public function testMoveException2() |
| 368 | 368 | { |
| 369 | - $this->mock->expects( $this->once() )->method( 'rename' ) |
|
| 370 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 369 | + $this->mock->expects($this->once())->method('rename') |
|
| 370 | + ->will($this->throwException(new \Exception())); |
|
| 371 | 371 | |
| 372 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 373 | - $this->object->move( 'file1', 'file2' ); |
|
| 372 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 373 | + $this->object->move('file1', 'file2'); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | |
| 377 | 377 | public function testCopy() |
| 378 | 378 | { |
| 379 | - $this->mock->expects( $this->once() )->method( 'copy' ) |
|
| 380 | - ->will( $this->returnValue( true ) ); |
|
| 379 | + $this->mock->expects($this->once())->method('copy') |
|
| 380 | + ->will($this->returnValue(true)); |
|
| 381 | 381 | |
| 382 | - $this->object->copy( 'file1', 'file2' ); |
|
| 382 | + $this->object->copy('file1', 'file2'); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | |
| 386 | 386 | public function testCopyException() |
| 387 | 387 | { |
| 388 | - $this->mock->expects( $this->once() )->method( 'copy' ) |
|
| 389 | - ->will( $this->returnValue( false ) ); |
|
| 388 | + $this->mock->expects($this->once())->method('copy') |
|
| 389 | + ->will($this->returnValue(false)); |
|
| 390 | 390 | |
| 391 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 392 | - $this->object->copy( 'file1', 'file2' ); |
|
| 391 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 392 | + $this->object->copy('file1', 'file2'); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
| 396 | 396 | public function testCopyException2() |
| 397 | 397 | { |
| 398 | - $this->mock->expects( $this->once() )->method( 'copy' ) |
|
| 399 | - ->will( $this->throwException( new \Exception() ) ); |
|
| 398 | + $this->mock->expects($this->once())->method('copy') |
|
| 399 | + ->will($this->throwException(new \Exception())); |
|
| 400 | 400 | |
| 401 | - $this->setExpectedException( '\Aimeos\MW\Filesystem\Exception' ); |
|
| 402 | - $this->object->copy( 'file1', 'file2' ); |
|
| 401 | + $this->setExpectedException('\Aimeos\MW\Filesystem\Exception'); |
|
| 402 | + $this->object->copy('file1', 'file2'); |
|
| 403 | 403 | } |
| 404 | 404 | } |