Beispiel #1
0
 protected function setUp()
 {
     $this->legacy = isset($_SERVER['LEGACY_TESTS']) ? (bool) $_SERVER['LEGACY_TESTS'] : false;
     $this->workspace = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid();
     $fs = new Filesystem();
     $fs->mkdir($this->workspace . '/bar');
     $fs->touch($this->workspace . '/foo.txt');
     $fs->touch($this->workspace . '/bar/foo.txt');
     $fs->touch($this->workspace . '/bar/.hidden');
     if (!$this->legacy) {
         MongoGridTestHelper::getGridFS()->storeBytes('', array('filename' => $this->workspace, 'type' => 'dir'));
         MongoGridTestHelper::getGridFS()->storeBytes('', array('filename' => $this->workspace . '/bar', 'type' => 'dir'));
         MongoGridTestHelper::getGridFS()->storeFile($this->workspace . '/foo.txt', array('type' => 'file'));
         MongoGridTestHelper::getGridFS()->storeFile($this->workspace . '/bar/foo.txt', array('type' => 'file'));
         MongoGridTestHelper::getGridFS()->storeFile($this->workspace . '/bar/.hidden', array('type' => 'file'));
         $fs->remove($this->workspace);
     }
 }
 protected function setUp()
 {
     $this->legacy = isset($_SERVER['LEGACY_TESTS']) ? (bool) $_SERVER['LEGACY_TESTS'] : false;
     $this->workspace = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid();
     $this->time = time();
     $old = umask(0);
     mkdir($this->workspace . '/bar', 0777, true);
     chmod($this->workspace . '/bar', 01777);
     touch($this->workspace . '/foo.txt', $this->time, $this->time);
     touch($this->workspace . '/bar/foo.txt');
     file_put_contents($this->workspace . '/bar/dummy.txt', 'bar');
     umask($old);
     if (!$this->legacy) {
         $this->gridfs = MongoGridTestHelper::getGridFS();
         $this->gridfs->storeBytes('', array('uploadDate' => new \MongoDate($this->time), 'filename' => '/', 'type' => 'dir'));
         $this->gridfs->storeBytes('', array('uploadDate' => new \MongoDate($this->time), 'filename' => getcwd(), 'type' => 'dir'));
         $this->gridfs->storeBytes('', array('uploadDate' => new \MongoDate($this->time), 'filename' => $this->workspace, 'type' => 'dir'));
         $this->gridfs->storeBytes('', array('uploadDate' => new \MongoDate($this->time), 'filename' => $this->workspace . '/bar', 'type' => 'dir'));
         $this->gridfs->storeFile($this->workspace . '/foo.txt', array('uploadDate' => new \MongoDate($this->time), 'type' => 'file'));
         $this->gridfs->storeFile($this->workspace . '/bar/foo.txt', array('uploadDate' => new \MongoDate($this->time), 'type' => 'file'));
         $this->gridfs->storeFile($this->workspace . '/bar/dummy.txt', array('uploadDate' => new \MongoDate($this->time), 'type' => 'file'));
         $this->clean($this->workspace);
     }
 }
 /**
  * Test  over MongoDB if $filepath is a directory
  */
 public static function assertIsDir($filepath, $message = null)
 {
     if (!is_string($filepath)) {
         throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
     }
     $found = MongoGridTestHelper::getGridFS()->findOne(array('filename' => $filepath));
     self::assertNotNull($found);
     self::assertEquals('dir', $found->file['type'], $message);
 }