|
12 | 12 | use League\Flysystem\UnableToMoveFile; |
13 | 13 | use League\Flysystem\UnableToReadFile; |
14 | 14 | use League\Flysystem\UnableToWriteFile; |
| 15 | +use League\Flysystem\Visibility; |
15 | 16 | use phpseclib3\Net\SFTP; |
16 | 17 |
|
17 | 18 | use function class_exists; |
@@ -230,6 +231,37 @@ public function it_can_proactively_close_a_connection(): void |
230 | 231 |
|
231 | 232 | self::assertFalse(static::$connectionProvider->connection->isConnected()); |
232 | 233 | } |
| 234 | + /** |
| 235 | + * @test |
| 236 | + * @fixme Move to FilesystemAdapterTestCase once all adapters pass |
| 237 | + */ |
| 238 | + public function moving_a_file_and_overwriting(): void |
| 239 | + { |
| 240 | + $this->runScenario(function() { |
| 241 | + $adapter = $this->adapter(); |
| 242 | + $adapter->write( |
| 243 | + 'source.txt', |
| 244 | + 'contents to be moved', |
| 245 | + new Config([Config::OPTION_VISIBILITY => Visibility::PUBLIC]) |
| 246 | + ); |
| 247 | + $adapter->write( |
| 248 | + 'destination.txt', |
| 249 | + 'contents to be overwritten', |
| 250 | + new Config([Config::OPTION_VISIBILITY => Visibility::PUBLIC]) |
| 251 | + ); |
| 252 | + $adapter->move('source.txt', 'destination.txt', new Config()); |
| 253 | + $this->assertFalse( |
| 254 | + $adapter->fileExists('source.txt'), |
| 255 | + 'After moving a file should no longer exist in the original location.' |
| 256 | + ); |
| 257 | + $this->assertTrue( |
| 258 | + $adapter->fileExists('destination.txt'), |
| 259 | + 'After moving, a file should be present at the new location.' |
| 260 | + ); |
| 261 | + $this->assertEquals(Visibility::PUBLIC, $adapter->visibility('destination.txt')->visibility()); |
| 262 | + $this->assertEquals('contents to be moved', $adapter->read('destination.txt')); |
| 263 | + }); |
| 264 | + } |
233 | 265 |
|
234 | 266 | private static function connectionProvider(): StubSftpConnectionProvider |
235 | 267 | { |
|
0 commit comments