當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TestCase::setUp方法代碼示例

本文整理匯總了PHP中OCA\Files_Sharing\Tests\TestCase::setUp方法的典型用法代碼示例。如果您正苦於以下問題:PHP TestCase::setUp方法的具體用法?PHP TestCase::setUp怎麽用?PHP TestCase::setUp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OCA\Files_Sharing\Tests\TestCase的用法示例。


在下文中一共展示了TestCase::setUp方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     // prepare user1's dir structure
     $textData = "dummy file data\n";
     $this->view->mkdir('container');
     $this->view->mkdir('container/shareddir');
     $this->view->mkdir('container/shareddir/subdir');
     $this->view->mkdir('container/shareddirrestricted');
     $this->view->mkdir('container/shareddirrestricted/subdir');
     $this->view->file_put_contents('container/shareddir/textfile.txt', $textData);
     $this->view->file_put_contents('container/shareddirrestricted/textfile1.txt', $textData);
     list($this->ownerStorage, $internalPath) = $this->view->resolvePath('');
     $this->ownerCache = $this->ownerStorage->getCache();
     $this->ownerStorage->getScanner()->scan('');
     // share "shareddir" with user2
     $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
     $node = $rootFolder->get('container/shareddir');
     $share = $this->shareManager->newShare();
     $share->setNode($node)->setShareType(\OCP\Share::SHARE_TYPE_USER)->setSharedWith(self::TEST_FILES_SHARING_API_USER2)->setSharedBy(self::TEST_FILES_SHARING_API_USER1)->setPermissions(\OCP\Constants::PERMISSION_ALL);
     $this->shareManager->createShare($share);
     $node = $rootFolder->get('container/shareddirrestricted');
     $share = $this->shareManager->newShare();
     $share->setNode($node)->setShareType(\OCP\Share::SHARE_TYPE_USER)->setSharedWith(self::TEST_FILES_SHARING_API_USER2)->setSharedBy(self::TEST_FILES_SHARING_API_USER1)->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE);
     $this->shareManager->createShare($share);
     // login as user2
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // retrieve the shared storage
     $this->secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
     list($this->sharedStorage, $internalPath) = $this->secondView->resolvePath('files/shareddir');
     list($this->sharedStorageRestrictedShare, $internalPath) = $this->secondView->resolvePath('files/shareddirrestricted');
     $this->sharedCache = $this->sharedStorage->getCache();
     $this->sharedCacheRestrictedShare = $this->sharedStorageRestrictedShare->getCache();
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:35,代碼來源:PermissionsTest.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $this->connection = \OC::$server->getDatabaseConnection();
     $this->migration = new Migration($this->connection);
     $this->cleanDB();
 }
開發者ID:ZverAleksey,項目名稱:core,代碼行數:7,代碼來源:migrationtest.php

示例3: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->uid = $this->getUniqueID('user');
     $this->mountManager = new \OC\Files\Mount\Manager();
     $this->manager = new \OCA\Files_Sharing\External\Manager(\OC::$server->getDatabaseConnection(), $this->mountManager, new StorageFactory(), $this->getMockBuilder('\\OC\\HTTPHelper')->disableOriginalConstructor()->getMock(), $this->uid);
 }
開發者ID:adolfo2103,項目名稱:hcloudfilem,代碼行數:7,代碼來源:managertest.php

示例4: setUp

 function setUp()
 {
     parent::setUp();
     \OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER1, 'User One');
     \OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER2, 'User Two');
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     // prepare user1's dir structure
     $this->view->mkdir('container');
     $this->view->mkdir('container/shareddir');
     $this->view->mkdir('container/shareddir/subdir');
     $this->view->mkdir('container/shareddir/emptydir');
     $textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
     $this->view->file_put_contents('container/not shared.txt', $textData);
     $this->view->file_put_contents('container/shared single file.txt', $textData);
     $this->view->file_put_contents('container/shareddir/bar.txt', $textData);
     $this->view->file_put_contents('container/shareddir/subdir/another.txt', $textData);
     $this->view->file_put_contents('container/shareddir/subdir/another too.txt', $textData);
     $this->view->file_put_contents('container/shareddir/subdir/not a text file.xml', '<xml></xml>');
     list($this->ownerStorage, $internalPath) = $this->view->resolvePath('');
     $this->ownerCache = $this->ownerStorage->getCache();
     $this->ownerStorage->getScanner()->scan('');
     // share "shareddir" with user2
     $fileinfo = $this->view->getFileInfo('container/shareddir');
     \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $fileinfo = $this->view->getFileInfo('container/shared single file.txt');
     \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     // login as user2
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // retrieve the shared storage
     $secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
     list($this->sharedStorage, $internalPath) = $secondView->resolvePath('files/shareddir');
     $this->sharedCache = $this->sharedStorage->getCache();
 }
開發者ID:Romua1d,項目名稱:core,代碼行數:34,代碼來源:cache.php

示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->uid = $this->getUniqueID('user');
     $this->mountManager = new \OC\Files\Mount\Manager();
     $this->httpHelper = $httpHelper = $this->getMockBuilder('\\OC\\HTTPHelper')->disableOriginalConstructor()->getMock();
     /** @var \OC\HTTPHelper $httpHelper */
     $this->manager = new Manager(\OC::$server->getDatabaseConnection(), $this->mountManager, new StorageFactory(), $httpHelper, \OC::$server->getNotificationManager(), $this->uid);
 }
開發者ID:hyb148,項目名稱:core,代碼行數:9,代碼來源:managertest.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->remoteUser = $this->getUniqueID('remoteuser');
     $this->storage = $this->getMockBuilder('\\OCA\\Files_Sharing\\External\\Storage')->disableOriginalConstructor()->getMock();
     $this->storage->expects($this->any())->method('getId')->will($this->returnValue('dummystorage::'));
     $this->cache = new \OCA\Files_Sharing\External\Cache($this->storage, 'http://example.com/owncloud', $this->remoteUser);
     $this->cache->put('test.txt', array('mimetype' => 'text/plain', 'size' => 5, 'mtime' => 123));
 }
開發者ID:Kevin-ZK,項目名稱:vaneDisk,代碼行數:9,代碼來源:cache.php

示例7: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->userManager = $this->getMockBuilder('OCP\\IUserManager')->disableOriginalConstructor()->getMock();
     $this->groupManager = $this->getMockBuilder('OCP\\IGroupManager')->disableOriginalConstructor()->getMock();
     $this->contactsManager = $this->getMockBuilder('OCP\\Contacts\\IManager')->disableOriginalConstructor()->getMock();
     $this->session = $this->getMockBuilder('OCP\\IUserSession')->disableOriginalConstructor()->getMock();
     $this->request = $this->getMockBuilder('OCP\\IRequest')->disableOriginalConstructor()->getMock();
     $this->sharees = new Sharees($this->groupManager, $this->userManager, $this->contactsManager, $this->getMockBuilder('OCP\\IConfig')->disableOriginalConstructor()->getMock(), $this->session, $this->getMockBuilder('OCP\\IURLGenerator')->disableOriginalConstructor()->getMock(), $this->request, $this->getMockBuilder('OCP\\ILogger')->disableOriginalConstructor()->getMock());
 }
開發者ID:lchen01,項目名稱:STEdwards,代碼行數:10,代碼來源:shareestest.php

示例8: setUp

 protected function setUp()
 {
     parent::setUp();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OCP\Share::registerBackend('test', 'Test_Share_Backend');
     $config = $this->getMockBuilder('\\OCP\\IConfig')->disableOriginalConstructor()->getMock();
     $certificateManager = $this->getMock('\\OCP\\ICertificateManager');
     $httpHelperMock = $this->getMockBuilder('\\OC\\HTTPHelper')->setConstructorArgs(array($config, $certificateManager))->getMock();
     $httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(true));
     $this->registerHttpHelper($httpHelperMock);
     $this->s2s = new \OCA\Files_Sharing\API\Server2Server();
 }
開發者ID:riso,項目名稱:owncloud-core,代碼行數:12,代碼來源:server2server.php

示例9: setUp

 public function setUp()
 {
     parent::setUp();
     $this->httpClient = $this->getMock('OCP\\Http\\Client\\IClient');
     $this->jobList = $this->getMock('OCP\\BackgroundJob\\IJobList');
     $this->urlGenerator = $this->getMock('OCP\\IURLGenerator');
     $this->trustedServers = $this->getMockBuilder('OCA\\Federation\\TrustedServers')->disableOriginalConstructor()->getMock();
     $this->dbHandler = $this->getMockBuilder('OCA\\Federation\\DbHandler')->disableOriginalConstructor()->getMock();
     $this->logger = $this->getMock('OCP\\ILogger');
     $this->response = $this->getMock('OCP\\Http\\Client\\IResponse');
     $this->getSharedSecret = new GetSharedSecret($this->httpClient, $this->urlGenerator, $this->jobList, $this->trustedServers, $this->logger, $this->dbHandler);
 }
開發者ID:evanjt,項目名稱:core,代碼行數:12,代碼來源:getsharedsecrettest.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OCP\Share::registerBackend('test', 'Test_Share_Backend');
     $config = $this->getMockBuilder('\\OCP\\IConfig')->disableOriginalConstructor()->getMock();
     $clientService = $this->getMock('\\OCP\\Http\\Client\\IClientService');
     $httpHelperMock = $this->getMockBuilder('\\OC\\HTTPHelper')->setConstructorArgs([$config, $clientService])->getMock();
     $httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(true));
     $this->registerHttpHelper($httpHelperMock);
     $this->s2s = new \OCA\Files_Sharing\API\Server2Server();
     $this->connection = \OC::$server->getDatabaseConnection();
 }
開發者ID:hyb148,項目名稱:core,代碼行數:13,代碼來源:server2server.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\\OCA\\Files_Sharing\\Hooks', 'unshareChildren');
     $this->folder = self::TEST_FOLDER_NAME;
     $this->subfolder = '/subfolder_share_api_test';
     $this->subsubfolder = '/subsubfolder_share_api_test';
     $this->filename = '/share-api-test';
     // save file with content
     $this->view->mkdir($this->folder);
     $this->view->mkdir($this->folder . $this->subfolder);
     $this->view->mkdir($this->folder . $this->subfolder . $this->subsubfolder);
     $this->view->file_put_contents($this->folder . $this->filename, $this->data);
     $this->view->file_put_contents($this->folder . $this->subfolder . $this->filename, $this->data);
 }
開發者ID:evanjt,項目名稱:core,代碼行數:15,代碼來源:unsharechildren.php

示例12: setUp

 function setUp()
 {
     parent::setUp();
     $this->folder = self::TEST_FOLDER_NAME;
     $this->subfolder = '/subfolder_share_api_test';
     $this->subsubfolder = '/subsubfolder_share_api_test';
     $this->filename = '/share-api-test.txt';
     // save file with content
     $this->view->file_put_contents($this->filename, $this->data);
     $this->view->mkdir($this->folder);
     $this->view->mkdir($this->folder . $this->subfolder);
     $this->view->mkdir($this->folder . $this->subfolder . $this->subsubfolder);
     $this->view->file_put_contents($this->folder . $this->filename, $this->data);
     $this->view->file_put_contents($this->folder . $this->subfolder . $this->filename, $this->data);
 }
開發者ID:Romua1d,項目名稱:core,代碼行數:15,代碼來源:api.php

示例13: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->uid = $this->getUniqueID('user');
     $this->createUser($this->uid, '');
     $this->user = \OC::$server->getUserManager()->get($this->uid);
     $this->mountManager = new \OC\Files\Mount\Manager();
     $this->httpHelper = $httpHelper = $this->getMockBuilder('\\OC\\HTTPHelper')->disableOriginalConstructor()->getMock();
     $discoveryManager = new DiscoveryManager(\OC::$server->getMemCacheFactory(), \OC::$server->getHTTPClientService());
     /** @var \OC\HTTPHelper $httpHelper */
     $this->manager = new Manager(\OC::$server->getDatabaseConnection(), $this->mountManager, new StorageFactory(), $httpHelper, \OC::$server->getNotificationManager(), $discoveryManager, $this->uid);
     $this->mountProvider = new MountProvider(\OC::$server->getDatabaseConnection(), function () {
         return $this->manager;
     });
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:15,代碼來源:ManagerTest.php

示例14: setUp

 public function setUp()
 {
     parent::setUp();
     $this->userBackend = new \Test\Util\User\Dummy();
     \OC::$server->getUserManager()->registerBackend($this->userBackend);
     $this->ownerUid = $this->getUniqueID('owner_');
     $this->recipientUid = $this->getUniqueID('recipient_');
     $this->userBackend->createUser($this->ownerUid, '');
     $this->userBackend->createUser($this->recipientUid, '');
     $this->loginAsUser($this->ownerUid);
     Filesystem::mkdir('/foo');
     Filesystem::file_put_contents('/foo/bar.txt', 'asd');
     $fileId = Filesystem::getFileInfo('/foo/bar.txt')->getId();
     \OCP\Share::shareItem('file', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->recipientUid, 31);
     $this->loginAsUser($this->recipientUid);
     $this->assertTrue(Filesystem::file_exists('bar.txt'));
 }
開發者ID:enoch85,項目名稱:owncloud-testserver,代碼行數:17,代碼來源:locking.php

示例15: setUp

 protected function setUp()
 {
     parent::setUp();
     \OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups', 'no');
     \OC::$server->getAppConfig()->setValue('core', 'shareapi_expire_after_n_days', '7');
     $this->folder = self::TEST_FOLDER_NAME;
     $this->subfolder = '/subfolder_share_api_test';
     $this->subsubfolder = '/subsubfolder_share_api_test';
     $this->filename = '/share-api-test.txt';
     // save file with content
     $this->view->file_put_contents($this->filename, $this->data);
     $this->view->mkdir($this->folder);
     $this->view->mkdir($this->folder . $this->subfolder);
     $this->view->mkdir($this->folder . $this->subfolder . $this->subsubfolder);
     $this->view->file_put_contents($this->folder . $this->filename, $this->data);
     $this->view->file_put_contents($this->folder . $this->subfolder . $this->filename, $this->data);
 }
開發者ID:evanjt,項目名稱:core,代碼行數:17,代碼來源:api.php


注:本文中的OCA\Files_Sharing\Tests\TestCase::setUp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。