本文整理汇总了PHP中RedBeanModelDataProvider::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBeanModelDataProvider::getData方法的具体用法?PHP RedBeanModelDataProvider::getData怎么用?PHP RedBeanModelDataProvider::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanModelDataProvider
的用法示例。
在下文中一共展示了RedBeanModelDataProvider::getData方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetToggleStarStatusLink
public function testGetToggleStarStatusLink()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$account = new Account();
$account->owner = $super;
$account->name = 'Test Account';
$account->officePhone = '1234567890';
$this->assertTrue($account->save());
$dataProvider = new RedBeanModelDataProvider('Account');
$data = $dataProvider->getData();
$link = StarredUtil::getToggleStarStatusLink($data[0], null);
$this->assertContains('unstarred', $link);
$this->assertContains('star-Account-' . $account->id, $link);
}
示例2: testSearchByCustomFieldWithEscapedContent
/**
* @depends testSearchMemberOfAndMembers
*/
public function testSearchByCustomFieldWithEscapedContent()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
//Searching with a custom field that is not blank should not produce any errors.
//The data returned should be no accounts.
$fakePostData = array('name' => null, 'officePhone' => null, 'industry' => array('value' => "Ban'king"), 'officeFax' => null);
$account = new Account(false);
$searchForm = new AccountsSearchForm($account);
$metadataAdapter = new SearchDataProviderMetadataAdapter($searchForm, $super->id, $fakePostData);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
//Run search and make sure the data returned matches how many total accounts are available.
$dataProvider = new RedBeanModelDataProvider('Account', null, false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(0, count($data));
}
示例3: testGetStarredModelsWithSearchAttributeData
public function testGetStarredModelsWithSearchAttributeData()
{
$searchAttributeData = array();
$searchAttributeData['clauses'] = array(1 => array('attributeName' => 'name', 'operatorType' => 'contains', 'value' => 'Test'));
$searchAttributeData['structure'] = '1';
$dataProvider = new RedBeanModelDataProvider('Account', null, false, $searchAttributeData);
$this->assertCount(2, $dataProvider->getData());
$dataProvider = new StarredModelDataProvider('Account', null, false, $searchAttributeData);
$this->assertCount(1, $dataProvider->getData());
$searchAttributeData = array();
$searchAttributeData['clauses'] = array(1 => array('attributeName' => 'name', 'operatorType' => 'equals', 'value' => 'Test'));
$searchAttributeData['structure'] = '1';
$dataProvider = new RedBeanModelDataProvider('Account', null, false, $searchAttributeData);
$this->assertCount(0, $dataProvider->getData());
$dataProvider = new StarredModelDataProvider('Account', null, false, $searchAttributeData);
$this->assertCount(0, $dataProvider->getData());
}
示例4: testGetDataReturningAllResults
public function testGetDataReturningAllResults()
{
$allGG = GG::getAll();
foreach ($allGG as $gg) {
$gg->delete();
}
$numberOfRecords = rand(12, 100);
for ($i = 1; $i <= $numberOfRecords; $i++) {
$gg = new GG();
$gg->g = 'a';
$this->assertTrue($gg->save());
}
$dataProvider = new RedBeanModelDataProvider('GG', 'g', false);
$totalItems = (int) $dataProvider->calculateTotalItemCount();
$dataProvider->getPagination()->setPageSize($totalItems);
$data = $dataProvider->getData();
$this->assertEquals($numberOfRecords, count($data));
}
示例5: testSearchByRelatedAttributeName
/**
* @depends testSearchByOwnerId
*/
public function testSearchByRelatedAttributeName()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$quote = DatabaseCompatibilityUtil::getQuote();
//Test searching contacts where the related account is ABC with account id = 5.
$fakePostData = array('account' => array('name' => 'abc'));
$metadataAdapter = new SearchDataProviderMetadataAdapter(new Contact(false), 1, $fakePostData);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Contact');
$where = RedBeanModelDataProvider::makeWhere('Contact', $searchAttributeData, $joinTablesAdapter);
$compareWhere = "({$quote}account{$quote}.{$quote}name{$quote} like 'abc%')";
$this->assertEquals($compareWhere, $where);
//Now test that the joinTablesAdapter has correct information.
$this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount());
$this->assertEquals(1, $joinTablesAdapter->getLeftTableJoinCount());
$leftTables = $joinTablesAdapter->getLeftTablesAndAliases();
$this->assertEquals('account', $leftTables[0]['tableName']);
//Make sure the sql runs properly.
$dataProvider = new RedBeanModelDataProvider('Contact', null, false, $searchAttributeData);
$data = $dataProvider->getData();
}
示例6: testSearchByType
public function testSearchByType()
{
$super = User::getByUsername('super');
$steven = User::getByUsername('steven');
Yii::app()->user->userModel = $super;
$conversationModel = new Conversation(false);
$searchAttributes = array();
$conversation = new Conversation();
$conversation->owner = $steven;
$conversation->subject = 'My test subject';
$conversation->description = 'My test description';
$this->assertTrue($conversation->save());
$conversationId = $conversation->id;
//Super dont have created conversations
$metadataAdapter = new ConversationsSearchDataProviderMetadataAdapter($conversationModel, $super->id, $searchAttributes, ConversationsSearchDataProviderMetadataAdapter::LIST_TYPE_CREATED);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
$dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(0, count($data));
//Super dont participate in any conversations
$metadataAdapter = new ConversationsSearchDataProviderMetadataAdapter($conversationModel, $super->id, $searchAttributes, ConversationsSearchDataProviderMetadataAdapter::LIST_TYPE_PARTICIPANT);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
$dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(0, count($data));
//Super dont participate in any closed conversations
$metadataAdapter = new ConversationsSearchDataProviderMetadataAdapter($conversationModel, $super->id, $searchAttributes, ConversationsSearchDataProviderMetadataAdapter::LIST_TYPE_CLOSED);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
$dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(0, count($data));
//Super participate in one conversation
$conversation = Conversation::getById($conversationId);
$conversationParticipant = new ConversationParticipant();
$conversationParticipant->person = $super;
$conversation->conversationParticipants->add($conversationParticipant);
$this->assertTrue($conversation->save());
$metadataAdapter = new ConversationsSearchDataProviderMetadataAdapter($conversationModel, $super->id, $searchAttributes, ConversationsSearchDataProviderMetadataAdapter::LIST_TYPE_PARTICIPANT);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
$dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(1, count($data));
//Super participate in a closed conversation
$conversation = Conversation::getById($conversationId);
$conversation->isClosed = true;
$this->assertTrue($conversation->save());
$metadataAdapter = new ConversationsSearchDataProviderMetadataAdapter($conversationModel, $super->id, $searchAttributes, ConversationsSearchDataProviderMetadataAdapter::LIST_TYPE_CLOSED);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
$dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(1, count($data));
}
示例7: testSearchForMultiSelectDropDownAttributePlacedForAccountsModule
/**
* @depends testSetAndGetMultiSelectDropDownAttribute
*/
public function testSearchForMultiSelectDropDownAttributePlacedForAccountsModule()
{
//Test that the multiple select attribute can query properly for search.
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
//Create an account to test searching multiple fields on for search.
$account = new Account();
$this->assertEquals(1, $account->testHobbiesCstm->values->count());
$account->name = 'my test account';
$account->owner = Yii::app()->user->userModel;
$customFieldValue2 = new CustomFieldValue();
$customFieldValue2->value = 'Reading';
$account->testHobbiesCstm->values->add($customFieldValue2);
$this->assertTrue($account->save());
$accountId = $account->id;
$account = Account::getById($accountId);
$this->assertEquals(2, $account->testHobbiesCstm->values->count());
$this->assertContains('Writing', $account->testHobbiesCstm->values);
$this->assertContains('Reading', $account->testHobbiesCstm->values);
//Create a second account with different hobbies
$account = new Account();
//Remove the default value of 'Writing';
$account->testHobbiesCstm->values->removeByIndex(0);
$account->name = 'my test account2';
$account->owner = Yii::app()->user->userModel;
$customFieldValue1 = new CustomFieldValue();
$customFieldValue1->value = 'Singing';
$account->testHobbiesCstm->values->add($customFieldValue1);
$customFieldValue2 = new CustomFieldValue();
$customFieldValue2->value = 'Surfing';
$account->testHobbiesCstm->values->add($customFieldValue2);
$this->assertTrue($account->save());
$accountId = $account->id;
$account = Account::getById($accountId);
$this->assertEquals(2, $account->testHobbiesCstm->values->count());
$this->assertContains('Singing', $account->testHobbiesCstm->values);
$this->assertContains('Surfing', $account->testHobbiesCstm->values);
//Searching with a custom field that is not blank should not produce an errors.
$searchPostData = array('name' => 'my test account', 'officePhone' => '', 'testHobbies' => array('values' => array(0 => '')), 'officeFax' => '');
$modifiedSearchPostData = SearchUtil::getSearchAttributesFromSearchArray($searchPostData);
$this->assertEquals(array('name' => 'my test account', 'officePhone' => null, 'officeFax' => null), $modifiedSearchPostData);
$account = new Account(false);
$searchForm = new AccountsSearchForm($account);
$metadataAdapter = new SearchDataProviderMetadataAdapter($searchForm, $super->id, $modifiedSearchPostData);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
//Make sure the search params are empty
$compareClauses = array(1 => array('attributeName' => 'name', 'operatorType' => 'startsWith', 'value' => 'my test account'));
$compareStructure = '1';
$this->assertEquals($compareClauses, $searchAttributeData['clauses']);
$this->assertEquals($compareStructure, $searchAttributeData['structure']);
//Run search and make sure the data returned matches how many total accounts are available.
$dataProvider = new RedBeanModelDataProvider('Account', null, false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(2, count($data));
}
示例8: testSearch
public function testSearch()
{
$super = User::getByUsername('super');
$steven = User::getByUsername('steven');
Yii::app()->user->userModel = $super;
$createdConversation = $this->createAndSaveNewConversationForUser($super, $steven);
$metadataForSearch = $this->rules->getSearchAttributeData();
$dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $metadataForSearch);
$data = $dataProvider->getData();
$this->assertEquals(1, count($data));
$metadataForSearch = $this->rules->getSearchAttributeData("sub");
$dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $metadataForSearch);
$data = $dataProvider->getData();
$this->assertEquals(1, count($data));
$metadataForSearch = $this->rules->getSearchAttributeData("description");
$dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $metadataForSearch);
$data = $dataProvider->getData();
$this->assertEquals(0, count($data));
}
示例9: testDefaultFullnameOrderOnContacts
public function testDefaultFullnameOrderOnContacts()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$contact = new Contact();
$contact->firstName = 'Jackie';
$contact->lastName = 'Bonn';
$contact->owner = $super;
$contact->state = ContactsUtil::getStartingState();
$this->assertTrue($contact->save());
$searchAttributeData = array();
$dataProvider = new RedBeanModelDataProvider('Contact', null, false, $searchAttributeData);
$data = $dataProvider->getData();
$contacts = array();
foreach ($data as $contact) {
$contacts[] = strval($contact);
}
$sortedContacts = $contacts;
sort($sortedContacts);
$compareContacts = array('Dino Dinoson', 'Jackie Bonn', 'Jackie Jackieson', 'Jackie Tyler');
$this->assertEquals($compareContacts, $sortedContacts);
}
示例10: testSearchByTwoMultipleValuesCustomField
/**
* @depends testSearchByMultipleValuesCustomField
*/
public function testSearchByTwoMultipleValuesCustomField()
{
if (!RedBeanDatabase::isFrozen()) {
$quote = DatabaseCompatibilityUtil::getQuote();
//Test where relatioon id is in a joining table. Many to Many relationship
$_FAKEPOST['TestOwnedCustomFieldsModel'] = array();
$_FAKEPOST['TestOwnedCustomFieldsModel']['multipleIndustries']['values'] = array('A', 'B', 'C');
$_FAKEPOST['TestOwnedCustomFieldsModel']['multipleSomethings']['values'] = array('D', 'E', 'F');
$metadataAdapter = new SearchDataProviderMetadataAdapter(new TestOwnedCustomFieldsModel(false), 1, $_FAKEPOST['TestOwnedCustomFieldsModel']);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('TestOwnedCustomFieldsModel');
$where = RedBeanModelDataProvider::makeWhere('TestOwnedCustomFieldsModel', $searchAttributeData, $joinTablesAdapter);
$compareWhere = "(1 = (select 1 from {$quote}customfieldvalue{$quote} customfieldvalue " . "where {$quote}customfieldvalue{$quote}.{$quote}multiplevaluescustomfield_id{$quote} = " . "{$quote}multiplevaluescustomfield{$quote}.id " . "and {$quote}customfieldvalue{$quote}.{$quote}value{$quote} IN('A','B','C') limit 1))";
// Not Coding Standard
$compareWhere .= " and (1 = (select 1 from {$quote}customfieldvalue{$quote} customfieldvalue " . "where {$quote}customfieldvalue{$quote}.{$quote}multiplevaluescustomfield_id{$quote} = " . "{$quote}multiplevaluescustomfield1{$quote}.id " . "and {$quote}customfieldvalue{$quote}.{$quote}value{$quote} IN('D','E','F') limit 1))";
// Not Coding Standard
$this->assertEquals($compareWhere, $where);
//Now test that the joinTablesAdapter has correct information.
$this->assertEquals(0, $joinTablesAdapter->getFromTableJoinCount());
$this->assertEquals(2, $joinTablesAdapter->getLeftTableJoinCount());
$leftTables = $joinTablesAdapter->getLeftTablesAndAliases();
$this->assertEquals('multiplevaluescustomfield', $leftTables[0]['tableName']);
$this->assertEquals('multiplevaluescustomfield', $leftTables[1]['tableName']);
//Now test that the subsetSQL query produced is correct.
$subsetSql = TestOwnedCustomFieldsModel::makeSubsetOrCountSqlQuery('testcustomfieldsmodel', $joinTablesAdapter, 1, 5, $where, null);
$compareSubsetSql = "select {$quote}testcustomfieldsmodel{$quote}.{$quote}id{$quote} id ";
$compareSubsetSql .= "from {$quote}testcustomfieldsmodel{$quote} ";
$compareSubsetSql .= "left join {$quote}multiplevaluescustomfield{$quote} on ";
$compareSubsetSql .= "{$quote}multiplevaluescustomfield{$quote}.{$quote}id{$quote} = ";
$compareSubsetSql .= "{$quote}testownedcustomfieldsmodel{$quote}.{$quote}multipleindustries_multiplevaluescustomfield_id{$quote} ";
$compareSubsetSql .= "left join {$quote}multiplevaluescustomfield{$quote} multiplevaluescustomfield1 on ";
$compareSubsetSql .= "{$quote}multiplevaluescustomfield1{$quote}.{$quote}id{$quote} = ";
$compareSubsetSql .= "{$quote}testownedcustomfieldsmodel{$quote}.{$quote}multiplesomethings_multiplevaluescustomfield_id{$quote} ";
$compareSubsetSql .= "where " . $compareWhere . ' ';
$compareSubsetSql .= 'limit 5 offset 1';
$this->assertEquals($compareSubsetSql, $subsetSql);
//Make sure the sql runs properly.
$dataProvider = new RedBeanModelDataProvider('TestOwnedCustomFieldsModel', null, false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(1, count($data));
}
}
示例11: testSearchUserFirstName
/**
* @depends testSearchCrossingTables
* @depends testGetAllModels
*/
public function testSearchUserFirstName()
{
$_FAKEPOST = array('User' => array('firstName' => 'billy'));
$metadataAdapter = new SearchDataProviderMetadataAdapter(new User(false), 1, $_FAKEPOST['User']);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
$dataProvider = new RedBeanModelDataProvider('User', null, false, $searchAttributeData);
$users = $dataProvider->getData();
$this->assertEquals(1, count($users));
$this->assertEquals(1, $dataProvider->calculateTotalItemCount());
}
示例12: testSearch
public function testSearch()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$this->deleteAllMissions();
$this->createAndSaveNewMissionForUser($super);
$searchAttributeData = $this->rules->getSearchAttributeData();
$dataProvider = new RedBeanModelDataProvider('Mission', null, false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(1, count($data));
$metadataForSearch = $this->rules->getSearchAttributeData("mis");
$dataProvider = new RedBeanModelDataProvider('Mission', null, false, $metadataForSearch);
$data = $dataProvider->getData();
$this->assertEquals(1, count($data));
$metadataForSearch = $this->rules->getSearchAttributeData("subject");
$dataProvider = new RedBeanModelDataProvider('Mission', null, false, $metadataForSearch);
$data = $dataProvider->getData();
$this->assertEquals(0, count($data));
}
示例13: testLastNameOrderOnUsers
/**
* @depends testDefaultFullnameOrderOnUsers
*/
public function testLastNameOrderOnUsers()
{
$searchAttributeData = array();
$dataProvider = new RedBeanModelDataProvider('User', 'lastName', false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertTrue($this->user3->id == $data[0]->id || $this->user3->id == $data[1]->id);
$this->assertTrue($this->user2->id == $data[1]->id || $this->user2->id == $data[0]->id);
$this->assertEquals($this->super, $data[2]);
$this->assertEquals($this->user1, $data[3]);
}
示例14: testOrderByCombinations
/**
* @depends testManyManyRelationSqlQuery
* See ModelDataProviderUtilTest for more order by testing.
*/
public function testOrderByCombinations()
{
$gg = new GG();
$gg->gg = 'a';
$gg->g = 'v';
$this->assertTrue($gg->save());
$gg = new GG();
$gg->gg = 'b';
$gg->g = 't';
$this->assertTrue($gg->save());
$gg = new GG();
$gg->gg = 'c';
$gg->g = 'u';
$this->assertTrue($gg->save());
$quote = DatabaseCompatibilityUtil::getQuote();
$_FAKEPOST['GG'] = array();
$metadataAdapter = new SearchDataProviderMetadataAdapter(new GG(false), 1, $_FAKEPOST['GG']);
$searchAttributeData = $metadataAdapter->getAdaptedMetadata();
$dataProvider = new RedBeanModelDataProvider('GG', 'gg', false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(3, count($data));
$this->assertEquals('a', $data[0]->gg);
$this->assertEquals('b', $data[1]->gg);
$this->assertEquals('c', $data[2]->gg);
$dataProvider = new RedBeanModelDataProvider('GG', 'gg', true, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(3, count($data));
$this->assertEquals('c', $data[0]->gg);
$this->assertEquals('b', $data[1]->gg);
$this->assertEquals('a', $data[2]->gg);
$compareString = "{$quote}gg{$quote}.{$quote}gg{$quote}";
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('GG');
$this->assertEquals($compareString, RedBeanModelDataProvider::resolveSortAttributeColumnName('GG', $joinTablesAdapter, 'gg'));
$compareString = "{$quote}g{$quote}.{$quote}g{$quote}";
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('GG');
$this->assertEquals($compareString, RedBeanModelDataProvider::resolveSortAttributeColumnName('GG', $joinTablesAdapter, 'g'));
//test ordering by castedUp model.
$dataProvider = new RedBeanModelDataProvider('GG', 'g', false, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(3, count($data));
$this->assertEquals('b', $data[0]->gg);
$this->assertEquals('c', $data[1]->gg);
$this->assertEquals('a', $data[2]->gg);
$dataProvider = new RedBeanModelDataProvider('GG', 'g', true, $searchAttributeData);
$data = $dataProvider->getData();
$this->assertEquals(3, count($data));
$this->assertEquals('a', $data[0]->gg);
$this->assertEquals('c', $data[1]->gg);
$this->assertEquals('b', $data[2]->gg);
//test ordering by custom attribute value.
}