StreamedCopyPolyfilTests.php 908 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace League\Flysystem\Adapter;
  3. use League\Flysystem\Stub\StreamedCopyStub;
  4. use PHPUnit\Framework\TestCase;
  5. class StreamedCopyPolyfilTests extends TestCase
  6. {
  7. public function testReadFail()
  8. {
  9. $copy = new StreamedCopyStub(false, null);
  10. $this->assertFalse($copy->copy('from', 'to'));
  11. }
  12. public function testWriteFail()
  13. {
  14. $stream = tmpfile();
  15. $readResponse = compact('stream');
  16. $copy = new StreamedCopyStub($readResponse, false);
  17. $this->assertFalse($copy->copy('from', 'to'));
  18. fclose($stream);
  19. }
  20. public function testSuccess()
  21. {
  22. $stream = tmpfile();
  23. $readResponse = compact('stream');
  24. $copy = new StreamedCopyStub($readResponse, $readResponse);
  25. $this->assertTrue($copy->copy('from', 'to'));
  26. if (is_resource($stream)) {
  27. fclose($stream);
  28. }
  29. }
  30. }