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


PHP Note::getByName方法代码示例

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


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

示例1: testSimpleUserImportWhereAllRowsSucceed

 public function testSimpleUserImportWhereAllRowsSucceed()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $notes = Note::getAll();
     $this->assertEquals(0, count($notes));
     $import = new Import();
     $serializedData['importRulesType'] = 'Notes';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('simpleImportTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.notes.tests.unit.files'));
     $this->assertEquals(4, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $mappingData = array('column_0' => ImportMappingUtil::makeTextAreaColumnMappingData('description'), 'column_1' => ImportMappingUtil::makeDateTimeColumnMappingData('occurredOnDateTime'), 'column_2' => ImportMappingUtil::makeModelDerivedColumnMappingData('AccountDerived'), 'column_3' => ImportMappingUtil::makeModelDerivedColumnMappingData('ContactDerived'), 'column_4' => ImportMappingUtil::makeModelDerivedColumnMappingData('OpportunityDerived'));
     $importRules = ImportRulesUtil::makeImportRulesByType('Notes');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //Confirm that 3 models where created.
     $notes = Note::getAll();
     $this->assertEquals(3, count($notes));
     $notes = Note::getByName('note1');
     $this->assertEquals(1, count($notes[0]));
     $this->assertEquals(1, count($notes[0]->activityItems));
     $this->assertEquals('testAccount', $notes[0]->activityItems[0]->name);
     $this->assertEquals('Account', get_class($notes[0]->activityItems[0]));
     $this->assertEquals('2011-12-22 05:03', substr($notes[0]->latestDateTime, 0, -3));
     $notes = Note::getByName('note2');
     $this->assertEquals(1, count($notes[0]));
     $this->assertEquals(1, count($notes[0]->activityItems));
     $this->assertEquals('testContact', $notes[0]->activityItems[0]->firstName);
     $this->assertEquals('Contact', get_class($notes[0]->activityItems[0]));
     $this->assertEquals('2011-12-22 05:03', substr($notes[0]->latestDateTime, 0, -3));
     $notes = Note::getByName('note3');
     $this->assertEquals(1, count($notes[0]));
     $this->assertEquals(1, count($notes[0]->activityItems));
     $this->assertEquals('testOpportunity', $notes[0]->activityItems[0]->name);
     $this->assertEquals('Opportunity', get_class($notes[0]->activityItems[0]));
     $this->assertEquals('2011-12-22 06:03', substr($notes[0]->latestDateTime, 0, -3));
     //Confirm 10 rows were processed as 'created'.
     $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED));
     //Confirm that 0 rows were processed as 'updated'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
     //Confirm 2 rows were processed as 'errors'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
     $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
     $this->assertEquals(0, count($beansWithErrors));
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:54,代码来源:NoteImportTest.php

示例2: testDeleteOfTheNoteForTheCustomFieldsPlacedForNotesModule

 /**
  * @depends testEditOfTheNoteForTheCustomFieldsPlacedForNotesModule
  */
 public function testDeleteOfTheNoteForTheCustomFieldsPlacedForNotesModule()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Retrieve the note Id based on the created note.
     $note = Note::getByName('Note Edit Description');
     //Set the note id so as to delete the note.
     $this->setGetArray(array('id' => $note[0]->id));
     $this->runControllerWithRedirectExceptionAndGetUrl('notes/default/delete');
     //Check to confirm that the note is deleted.
     $note = Note::getByName('Note Edit Description');
     $this->assertEquals(0, count($note));
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:15,代码来源:NotesDesignerSuperUserWalkthroughTest.php

示例3: testUnprivilegedUserViewUpdateDeleteNotes

 /**
  * @depends testListNotes
  */
 public function testUnprivilegedUserViewUpdateDeleteNotes()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $notAllowedUser = UserTestHelper::createBasicUser('Steven');
     $notAllowedUser->setRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API);
     $saved = $notAllowedUser->save();
     $authenticationData = $this->login('steven', 'steven');
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $this->assertTrue($everyoneGroup->save());
     $notes = Note::getByName('Updated note description');
     $this->assertEquals(1, count($notes));
     $data['description'] = "Updated note description";
     // Test with unprivileged user to view, edit and delete account.
     $authenticationData = $this->login('steven', 'steven');
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/read/' . $notes[0]->id, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']);
     $this->assertEquals('You do not have rights to perform this action.', $response['message']);
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/update/' . $notes[0]->id, 'PUT', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']);
     $this->assertEquals('You do not have rights to perform this action.', $response['message']);
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/delete/' . $notes[0]->id, 'DELETE', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']);
     $this->assertEquals('You do not have rights to perform this action.', $response['message']);
     //now check if user have rights, but no permissions.
     $notAllowedUser->setRight('NotesModule', NotesModule::getAccessRight());
     $notAllowedUser->setRight('NotesModule', NotesModule::getCreateRight());
     $notAllowedUser->setRight('NotesModule', NotesModule::getDeleteRight());
     $saved = $notAllowedUser->save();
     $this->assertTrue($saved);
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/read/' . $notes[0]->id, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']);
     $this->assertEquals('You do not have permissions for this action.', $response['message']);
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/update/' . $notes[0]->id, 'PUT', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']);
     $this->assertEquals('You do not have permissions for this action.', $response['message']);
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/delete/' . $notes[0]->id, 'DELETE', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']);
     $this->assertEquals('You do not have permissions for this action.', $response['message']);
     // Allow everyone group to read/write note
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     unset($data);
     $data['explicitReadWriteModelPermissions'] = array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP);
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/update/' . $notes[0]->id, 'PUT', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $authenticationData = $this->login('steven', 'steven');
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/read/' . $notes[0]->id, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     unset($data);
     $data['description'] = "Updated note description 2";
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/update/' . $notes[0]->id, 'PUT', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals("Updated note description 2", $response['data']['description']);
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/delete/' . $notes[0]->id, 'DELETE', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']);
     $this->assertEquals('You do not have permissions for this action.', $response['message']);
     // Test with privileged user
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     //Test Delete
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/delete/' . $notes[0]->id, 'DELETE', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $response = ApiRestTestHelper::createApiCall($this->serverUrl . '/test.php/notes/note/api/read/' . $notes[0]->id, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_FAILURE, $response['status']);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:83,代码来源:ApiRestNoteTest.php

示例4: testUpdateNoteFromForm

 /**
  * @depends testCreateAndGetNoteById
  */
 public function testUpdateNoteFromForm()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $user = User::getByUsername('billy');
     $notes = Note::getByName('myNote');
     $note = $notes[0];
     $this->assertEquals($note->description, 'myNote');
     $postData = array('owner' => array('id' => $user->id), 'description' => 'New Name', 'occurredOnDateTime' => '');
     $sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel($note, $postData);
     $note->setAttributes($sanitizedPostData);
     $this->assertTrue($note->save());
     $id = $note->id;
     unset($note);
     $note = Note::getById($id);
     $this->assertEquals('New Name', $note->description);
     $this->assertEquals(null, $note->occurredOnDateTime);
     //create new note from scratch where the DateTime attributes are not populated. It should let you save.
     $note = new Note();
     $postData = array('owner' => array('id' => $user->id), 'description' => 'Lamazing', 'occurredOnDateTime' => '');
     $sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel($note, $postData);
     $note->setAttributes($sanitizedPostData);
     $this->assertTrue($note->save());
     $id = $note->id;
     unset($note);
     $note = Note::getById($id);
     $this->assertEquals('Lamazing', $note->description);
     $this->assertEquals(null, $note->occurredOnDateTime);
     //will default to NOW
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:32,代码来源:NoteTest.php


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