AdaptersThatCanOverwriteFilesTest.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace League\Flysystem\Adapter;
  3. use League\Flysystem\Filesystem;
  4. use League\Flysystem\Stub\FileOverwritingAdapterStub;
  5. use PHPUnit\Framework\TestCase;
  6. class AdaptersThatCanOverwriteFilesTest extends TestCase
  7. {
  8. /**
  9. * @test
  10. */
  11. public function overwriting_files_with_put()
  12. {
  13. $filesystem = new Filesystem($adapter = new FileOverwritingAdapterStub());
  14. $filesystem->put('path.txt', 'string contents');
  15. $this->assertEquals('path.txt', $adapter->writtenPath);
  16. $this->assertEquals('string contents', $adapter->writtenContents);
  17. }
  18. /**
  19. * @test
  20. */
  21. public function overwriting_files_with_putStream()
  22. {
  23. $filesystem = new Filesystem($adapter = new FileOverwritingAdapterStub());
  24. $stream = tmpfile();
  25. fwrite($stream, 'stream contents');
  26. $filesystem->putStream('path.txt', $stream);
  27. fclose($stream);
  28. $this->assertEquals('path.txt', $adapter->writtenPath);
  29. $this->assertEquals('stream contents', $adapter->writtenContents);
  30. }
  31. }