EmptyDirPluginTests.php 1.0 KB

123456789101112131415161718192021222324252627282930
  1. <?php
  2. use League\Flysystem\Plugin\EmptyDir;
  3. use PHPUnit\Framework\TestCase;
  4. class EmptyDirPluginTests extends TestCase
  5. {
  6. public function testPlugin()
  7. {
  8. $filesystem = $this->prophesize('League\Flysystem\FilesystemInterface');
  9. $plugin = new EmptyDir();
  10. $this->assertEquals('emptyDir', $plugin->getMethod());
  11. $plugin->setFilesystem($filesystem->reveal());
  12. $filesystem->listContents('dirname', false)->willReturn([
  13. ['type' => 'dir', 'path' => 'dirname/dir'],
  14. ['type' => 'file', 'path' => 'dirname/file.txt'],
  15. ['type' => 'dir', 'path' => 'dirname/another_dir'],
  16. ['type' => 'file', 'path' => 'dirname/another_file.txt'],
  17. ])->shouldBeCalled();
  18. $filesystem->delete('dirname/file.txt')->shouldBeCalled();
  19. $filesystem->delete('dirname/another_file.txt')->shouldBeCalled();
  20. $filesystem->deleteDir('dirname/dir')->shouldBeCalled();
  21. $filesystem->deleteDir('dirname/another_dir')->shouldBeCalled();
  22. $plugin->handle('dirname');
  23. }
  24. }