当前位置: 首页>>代码示例>>PHP>>正文


PHP FileModel::getAll方法代码示例

本文整理汇总了PHP中FileModel::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP FileModel::getAll方法的具体用法?PHP FileModel::getAll怎么用?PHP FileModel::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileModel的用法示例。


在下文中一共展示了FileModel::getAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testResolveModelsHasManyFilesFromPost

 public function testResolveModelsHasManyFilesFromPost()
 {
     if (!RedBeanDatabase::isFrozen()) {
         Yii::app()->user->userModel = User::getByUsername('super');
         $fileCount = count(FileModel::getAll());
         $this->assertEquals(0, $fileCount);
         $file1 = ZurmoTestHelper::createFileModel();
         $file2 = ZurmoTestHelper::createFileModel();
         $file3 = ZurmoTestHelper::createFileModel();
         $model = new ModelWithAttachmentTestItem();
         $_POST['myTest'] = array($file1->id, $file2->id, $file3->id);
         FileModelUtil::resolveModelsHasManyFilesFromPost($model, 'files', 'myTest');
         $model->member = 'test';
         $saved = $model->save();
         $this->assertTrue($saved);
         $fileCount = count(FileModel::getAll());
         $this->assertEquals(3, $fileCount);
         $modelId = $model->id;
         $model->forget();
         $model = ModelWithAttachmentTestItem::getById($modelId);
         $this->assertEquals(3, $model->files->count());
         //Add a fourth file.
         $file4 = ZurmoTestHelper::createFileModel();
         $_POST['myTest'] = array($file1->id, $file2->id, $file3->id, $file4->id);
         FileModelUtil::resolveModelsHasManyFilesFromPost($model, 'files', 'myTest');
         $saved = $model->save();
         $this->assertTrue($saved);
         $fileCount = count(FileModel::getAll());
         $this->assertEquals(4, $fileCount);
         $model->forget();
         $model = ModelWithAttachmentTestItem::getById($modelId);
         $this->assertEquals(4, $model->files->count());
         //Remove the 2nd file.
         $_POST['myTest'] = array($file1->id, $file3->id, $file4->id);
         FileModelUtil::resolveModelsHasManyFilesFromPost($model, 'files', 'myTest');
         $saved = $model->save();
         $this->assertTrue($saved);
         $fileCount = count(FileModel::getAll());
         $this->assertEquals(3, $fileCount);
         $model->forget();
         $model = ModelWithAttachmentTestItem::getById($modelId);
         $this->assertEquals(3, $model->files->count());
         $compareIds = array($file1->id, $file3->id, $file4->id);
         foreach ($model->files as $fileModel) {
             $this->assertTrue(in_array($fileModel->id, $compareIds));
         }
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:48,代码来源:FileModelUtilTest.php

示例2: testFileControllerActions

 public function testFileControllerActions()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $this->assertEquals(0, count(FileModel::getAll()));
     $pathToFiles = Yii::getPathOfAlias('application.modules.zurmo.tests.unit.files');
     $filePath = $pathToFiles . DIRECTORY_SEPARATOR . 'testNote.txt';
     $contents = file_get_contents($pathToFiles . DIRECTORY_SEPARATOR . 'testNote.txt');
     //upload a file
     $filePath = $pathToFiles . DIRECTORY_SEPARATOR . 'testNote.txt';
     self::resetAndPopulateFilesArrayByFilePathAndName('aTest', $filePath, 'testNote.txt');
     $this->resetPostArray();
     $this->SetGetArray(array('filesVariableName' => 'aTest'));
     $content = $this->runControllerWithExitExceptionAndGetContent('zurmo/fileModel/upload');
     //Confirm the file has actually been uploaded
     $files = FileModel::getAll();
     $compareJsonString = '[{"name":"testNote.txt","type":"text\\/plain","size":"6.34KB","id":' . $files[0]->id . '}]';
     $this->assertEquals($compareJsonString, $content);
     $fileModels = FileModel::getAll();
     $this->assertEquals(1, count($fileModels));
     $this->assertEquals($contents, $fileModels[0]->fileContent->content);
     if (!RedBeanDatabase::isFrozen()) {
         //add fileModel to a model.
         $model = new ModelWithAttachmentTestItem();
         $model->member = 'test';
         $model->files->add($fileModels[0]);
         $this->assertTrue($model->save());
         $modelId = $model->id;
         $model->forget();
         //download a file.
         $this->setGetArray(array('id' => $fileModels[0]->id, 'modelId' => $modelId, 'modelClassName' => 'ModelWithAttachmentTestItem'));
         $this->resetPostArray();
         $content = $this->runControllerWithExitExceptionAndGetContent('zurmo/fileModel/download');
         $compareContent = 'Testing download.';
         $this->assertEquals($compareContent, $content);
     }
     //todo: test all file errors.
     //Test deleting a file.
     $this->assertEquals(1, count(FileModel::getAll()));
     $this->assertEquals(1, count(FileContent::getAll()));
     $this->setGetArray(array('id' => $fileModels[0]->id));
     $this->resetPostArray();
     $this->runControllerWithNoExceptionsAndGetContent('zurmo/fileModel/delete', true);
     //Now confirm that there are no file models or content in the system.
     $this->assertEquals(0, count(FileModel::getAll()));
     $this->assertEquals(0, count(FileContent::getAll()));
     //Test GlobalSearchAutoComplete
     $this->assertTrue(ContactsModule::loadStartingData());
     $this->setGetArray(array('term' => 'something'));
     $this->resetPostArray();
     $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/globalSearchAutoComplete');
     $compareContent = '[{"href":"","label":"No results found","iconClass":""}';
     // Not Coding Standard
     $this->assertTrue(strpos($content, $compareContent) !== false);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:54,代码来源:ZurmoSuperUserWalkthroughTest.php

示例3: testDeleteSocialItem

 /**
  * @depends testAddingComments
  */
 public function testDeleteSocialItem()
 {
     $socialItems = SocialItem::getAll();
     $this->assertEquals(1, count($socialItems));
     $comments = Comment::getAll();
     $this->assertEquals(1, count($comments));
     $fileModels = FileModel::getAll();
     $this->assertEquals(1, count($fileModels));
     foreach ($socialItems as $socialItem) {
         $socialItemId = $socialItem->id;
         $socialItem->forget();
         $socialItem = SocialItem::getById($socialItemId);
         $deleted = $socialItem->delete();
         $this->assertTrue($deleted);
     }
     $socialItems = SocialItem::getAll();
     $this->assertEquals(0, count($socialItems));
     //check that all comments are removed, since they are owned.
     $comments = Comment::getAll();
     $this->assertEquals(0, count($comments));
     $fileModels = FileModel::getAll();
     $this->assertEquals(0, count($fileModels));
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:26,代码来源:SocialItemTest.php

示例4: testModelWithAttachmentTestItem

 public function testModelWithAttachmentTestItem()
 {
     if (!RedBeanDatabase::isFrozen()) {
         Yii::app()->user->userModel = User::getByUsername('super');
         $pathToFiles = Yii::getPathOfAlias('application.modules.zurmo.tests.unit.files');
         $filePath = $pathToFiles . DIRECTORY_SEPARATOR . 'testNote.txt';
         $model = new ModelWithAttachmentTestItem();
         $fileModel = FileModelUtil::makeByFilePathAndName($filePath, 'testNote.txt');
         $firstFileModelId = $fileModel->id;
         $this->assertTrue($fileModel instanceof FileModel);
         $this->assertEquals(6495, strlen($fileModel->fileContent->content));
         $theContent = $fileModel->fileContent->content;
         $model->files->add($fileModel);
         $model->member = 'test';
         $saved = $model->save();
         $this->assertTrue($saved);
         $modelId = $model->id;
         $model->forget();
         $model = ModelWithAttachmentTestItem::getById($modelId);
         $this->assertEquals($theContent, $model->files[0]->fileContent->content);
         $this->assertEquals('testNote.txt', $model->files[0]->name);
         $this->assertEquals('text/plain', $model->files[0]->type);
         $this->assertEquals(6495, $model->files[0]->size);
         //Now try using CUploadedFile.
         self::resetAndPopulateFilesArrayByFilePathAndName('aTest', $filePath, 'testNote.txt');
         $uploadedFile = CUploadedFile::getInstanceByName('aTest');
         $this->assertTrue($uploadedFile instanceof CUploadedFile);
         $fileModel = FileModelUtil::makeByUploadedFile($uploadedFile);
         $this->assertTrue($fileModel instanceof FileModel);
         $this->assertTrue($fileModel->id != $firstFileModelId);
         $this->assertTrue($fileModel->id > 0);
         $model = ModelWithAttachmentTestItem::getById($modelId);
         $model->files->add($fileModel);
         $saved = $model->save();
         $this->assertTrue($saved);
         $modelId = $model->id;
         $model->forget();
         $model = ModelWithAttachmentTestItem::getById($modelId);
         $this->assertEquals(2, $model->files->count());
         //Delete the model and confirm the related models are removed
         $this->assertEquals(1, count(ModelWithAttachmentTestitem::getAll()));
         $this->assertEquals(2, count(FileModel::getAll()));
         $this->assertEquals(2, count(FileContent::getAll()));
         $model->delete();
         $this->assertEquals(0, count(ModelWithAttachmentTestitem::getAll()));
         $this->assertEquals(0, count(FileModel::getAll()));
         $this->assertEquals(0, count(FileContent::getAll()));
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:49,代码来源:ModelWithAttachmentTest.php


注:本文中的FileModel::getAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。