Skip to content
This repository
Browse code

Add rmdir() management.

  • Loading branch information...
commit 551713f9d71f83e6ff1c9e7a6c89415b3ddad708 1 parent fb82173
Frédéric Hardy mageekguy authored
14 classes/mock/streams/fs/directory/controller.php
@@ -40,6 +40,20 @@ public function mkdir($path, $mode, $options)
40 40 }
41 41 }
42 42
  43 + public function rmdir($path, $options)
  44 + {
  45 + if ($this->exists === false || $this->checkIfWritable() === false)
  46 + {
  47 + return false;
  48 + }
  49 + else
  50 + {
  51 + $this->exists = false;
  52 +
  53 + return true;
  54 + }
  55 + }
  56 +
43 57 public function dir_opendir($path, $useSafeMode)
44 58 {
45 59 return $this->exists;
20 tests/units/classes/mock/streams/fs/directory/controller.php
@@ -66,4 +66,24 @@ public function testMkdir()
66 66 ->integer($controller->getPermissions())->isEqualTo(0777)
67 67 ;
68 68 }
  69 +
  70 + public function testRmdir()
  71 + {
  72 + $this
  73 + ->if($controller = new testedClass(uniqid()))
  74 + ->and($controller->exists())
  75 + ->then
  76 + ->boolean($controller->rmdir(uniqid(), STREAM_MKDIR_RECURSIVE))->isTrue()
  77 + ->variable($controller->getPermissions())->isNull()
  78 + ->if($controller->exists())
  79 + ->and($controller->isNotWritable())
  80 + ->then
  81 + ->boolean($controller->rmdir(uniqid(), STREAM_MKDIR_RECURSIVE))->isFalse()
  82 + ->integer($controller->getPermissions())->isNotNull()
  83 + ->if($controller->notExists())
  84 + ->then
  85 + ->boolean($controller->rmdir(uniqid(), STREAM_MKDIR_RECURSIVE))->isFalse()
  86 + ->variable($controller->getPermissions())->isNull()
  87 + ;
  88 + }
69 89 }

0 comments on commit 551713f

Please sign in to comment.
Something went wrong with that request. Please try again.