コード例 #1
0
ファイル: folder.php プロジェクト: hyb148/core
 public function testSearchSubStorages()
 {
     $manager = $this->getMock('\\OC\\Files\\Mount\\Manager');
     /**
      * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
      */
     $view = $this->getMock('\\OC\\Files\\View');
     $root = $this->getMock('\\OC\\Files\\Node\\Root', array(), array($manager, $view, $this->user));
     $root->expects($this->any())->method('getUser')->will($this->returnValue($this->user));
     $storage = $this->getMock('\\OC\\Files\\Storage\\Storage');
     $cache = $this->getMock('\\OC\\Files\\Cache\\Cache', array(), array(''));
     $subCache = $this->getMock('\\OC\\Files\\Cache\\Cache', array(), array(''));
     $subStorage = $this->getMock('\\OC\\Files\\Storage\\Storage');
     $subMount = $this->getMock('\\OC\\Files\\Mount\\MountPoint', array(), array(null, ''));
     $subMount->expects($this->once())->method('getStorage')->will($this->returnValue($subStorage));
     $subMount->expects($this->once())->method('getMountPoint')->will($this->returnValue('/bar/foo/bar/'));
     $storage->expects($this->once())->method('getCache')->will($this->returnValue($cache));
     $subStorage->expects($this->once())->method('getCache')->will($this->returnValue($subCache));
     $cache->expects($this->once())->method('search')->with('%qw%')->will($this->returnValue(array(array('fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'))));
     $subCache->expects($this->once())->method('search')->with('%qw%')->will($this->returnValue(array(array('fileid' => 4, 'path' => 'asd/qweasd', 'name' => 'qweasd', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'))));
     $root->expects($this->once())->method('getMountsIn')->with('/bar/foo')->will($this->returnValue(array($subMount)));
     $view->expects($this->once())->method('resolvePath')->will($this->returnValue(array($storage, 'foo')));
     $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
     $result = $node->search('qw');
     $this->assertEquals(2, count($result));
 }