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


PHP ArrayList::last方法代碼示例

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


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

示例1: testSortActionWithAdminPermission

 public function testSortActionWithAdminPermission()
 {
     $team1 = $this->objFromFixture('GridFieldAction_SortOrder_Team', 'team1');
     $team2 = $this->objFromFixture('GridFieldAction_SortOrder_Team', 'team2');
     $team3 = $this->objFromFixture('GridFieldAction_SortOrder_Team', 'team3');
     $this->logInWithPermission('ADMIN');
     $stateID = 'testGridStateActionField';
     Session::set($stateID, array('grid' => '', 'actionName' => 'saveGridRowSort', 'args' => array('GridFieldSortableRows' => array('sortableToggle' => true))));
     $request = new SS_HTTPRequest('POST', 'url', array('ItemIDs' => "{$team1->ID}, {$team3->ID}, {$team2->ID}"), array('action_gridFieldAlterAction?StateID=' . $stateID => true));
     $this->gridField->gridFieldAlterAction(array('StateID' => $stateID), $this->form, $request);
     $this->assertEquals($team2->ID, $this->list->last()->ID, 'User should be able to sort records with ADMIN permission.');
 }
開發者ID:vinstah,項目名稱:body,代碼行數:12,代碼來源:GridFieldSortableRowsTest.php

示例2: testAppendToTopAutoSort

 public function testAppendToTopAutoSort()
 {
     if (Member::currentUser()) {
         Member::currentUser()->logOut();
     }
     $this->gridField->getConfig()->getComponentByType('GridFieldSortableRows')->setAppendToTop(true);
     $this->assertEquals(0, $this->list->last()->SortOrder, 'Auto sort should not have run');
     $stateID = 'testGridStateActionField';
     Session::set($stateID, array('grid' => '', 'actionName' => 'sortableRowsToggle', 'args' => array('GridFieldSortableRows' => array('sortableToggle' => true))));
     $request = new SS_HTTPRequest('POST', 'url', array(), array('action_gridFieldAlterAction?StateID=' . $stateID => true));
     $this->gridField->gridFieldAlterAction(array('StateID' => $stateID), $this->form, $request);
     //Insure sort ran
     $this->assertEquals(3, $this->list->last()->SortOrder, 'Auto sort should have run');
     //Check for duplicates (there shouldn't be any)
     $count = $this->list->Count();
     $indexes = count(array_unique($this->list->column('SortOrder')));
     $this->assertEquals(0, $count - $indexes, 'Duplicate indexes detected');
 }
開發者ID:vinstah,項目名稱:body,代碼行數:18,代碼來源:GridFieldSortableRowsAutoSortTest.php

示例3: testFirstLast

 public function testFirstLast()
 {
     $list = new ArrayList(array(array('Key' => 1), array('Key' => 2), array('Key' => 3)));
     $this->assertEquals($list->first(), array('Key' => 1));
     $this->assertEquals($list->last(), array('Key' => 3));
 }
開發者ID:maent45,項目名稱:redefine_renos,代碼行數:6,代碼來源:ArrayListTest.php

示例4: testMultiSort

	public function testMultiSort() {
		$list = new ArrayList(array(
			(object) array('ID'=>3, 'Name'=>'Bert', 'Importance'=>1),
			(object) array('ID'=>1, 'Name'=>'Aron', 'Importance'=>2),
			(object) array('ID'=>2, 'Name'=>'Aron', 'Importance'=>1),
		));
		
		$list->sort(array('Name'=>'ASC', 'Importance'=>'ASC'));
		$this->assertEquals($list->first()->ID, 2, 'Aron.2 should be first in the list');
		$this->assertEquals($list->last()->ID, 3, 'Bert.3 should be last in the list');
		
		$list->sort(array('Name'=>'ASC', 'Importance'=>'DESC'));
		$this->assertEquals($list->first()->ID, 1, 'Aron.2 should be first in the list');
		$this->assertEquals($list->last()->ID, 3, 'Bert.3 should be last in the list');
	}
開發者ID:redema,項目名稱:sapphire,代碼行數:15,代碼來源:ArrayListTest.php


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