本文整理汇总了PHP中ArrayUtil::sort方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtil::sort方法的具体用法?PHP ArrayUtil::sort怎么用?PHP ArrayUtil::sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil::sort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdateTopBarLinks
public function testUpdateTopBarLinks()
{
//
// ensure that we can reorder modules
//
$moduleIdsOrdered = Yii::app()->db->createCommand("\n select id\n from x2_modules\n where visible\n order by menuPosition asc\n ")->queryColumn();
Modules::updateTopBarLinks(array_reverse($moduleIdsOrdered), array());
$moduleIdsOrderedNew = Yii::app()->db->createCommand("\n select id\n from x2_modules\n where visible\n order by menuPosition asc\n ")->queryColumn();
// ensure that module menu position order was reversed
$this->assertEquals(array_reverse($moduleIdsOrdered), $moduleIdsOrderedNew);
//
// ensure that we can change visibility of modules
//
$moduleIdsOrdered = $moduleIdsOrderedNew;
Modules::updateTopBarLinks(array(), $moduleIdsOrdered);
$hiddenModuleIds = Yii::app()->db->createCommand("\n select id\n from x2_modules\n where not visible and menuPosition=-1\n order by id asc\n ")->queryColumn();
// ensure that all formerly visible modules are now hidden with menuPosition = -1
$this->assertEquals(ArrayUtil::sort($moduleIdsOrdered), $hiddenModuleIds);
//
// Change visibility and reorder, for good measure
//
$moduleIds = Yii::app()->db->createCommand("\n select id\n from x2_modules\n order by id asc\n ")->queryColumn();
$hideThese = array_reverse(array_slice($moduleIds, 0, floor(count($moduleIds) / 2)));
$showThese = array_reverse(array_slice($moduleIds, floor(count($moduleIds) / 2)));
Modules::updateTopBarLinks($showThese, $hideThese);
$this->assertEquals($showThese, Yii::app()->db->createCommand("\n select id\n from x2_modules\n where visible\n order by menuPosition asc\n ")->queryColumn());
$this->assertEquals($hideThese, Yii::app()->db->createCommand("\n select id\n from x2_modules\n where not visible and menuPosition = -1\n order by id desc\n ")->queryColumn());
}
示例2: testGetViewableUserCalendarNames
/**
* Ensure that list of viewable calendars correctly reflects calendar permissions records
*/
public function testGetViewableUserCalendarNames()
{
TestingAuxLib::loadX2NonWebUser();
TestingAuxLib::suLogin('admin');
$viewable = array_keys(X2CalendarPermissions::getViewableUserCalendarNames());
$this->assertEquals(array_merge(array('Anyone'), Yii::app()->db->createCommand("\n SELECT username\n FROM x2_users\n ")->queryColumn()), ArrayUtil::sort($viewable));
$user = $this->users('testUser');
TestingAuxLib::suLogin('testuser');
$viewable = array_keys(X2CalendarPermissions::getViewableUserCalendarNames());
$grantedUsers = array_unique(array_merge(array('Anyone', 'testuser'), Yii::app()->db->createCommand("\n /**\n * get names of users who have granted view permission to testuser and names of\n * users who have not set up calendar permissions\n */\n SELECT distinct(username)\n FROM x2_users as t, x2_calendar_permissions\n WHERE other_user_id=:userId OR t.id NOT in (\n SELECT distinct(user_id)\n FROM x2_calendar_permissions\n )\n ")->queryColumn(array(':userId' => $user->id))));
$this->assertEquals(ArrayUtil::sort($grantedUsers), ArrayUtil::sort($viewable));
TestingAuxLib::restoreX2WebUser();
}
示例3: testScanForTags
public function testScanForTags()
{
$contact = $this->contacts('testAnyone');
$contact->clearTags();
$expectedTags = array('#test', '#test2', '#test3', '#test4', '#test-test');
$badTags = array('#test5', '#test6', '#test7', '#test-');
$bgInfo = '#test #test2 #test3
#test-test
#test4
#test-
<style>
#test5 {
background: #test6
}
</style> <span style=" #test7 "></span>';
foreach (array_merge($badTags, $expectedTags) as $tag) {
$this->assertFalse($contact->hasTag($tag, null, true));
}
$contact->backgroundInfo = $bgInfo;
$contactTags = $contact->scanForTags();
$this->assertEquals(ArrayUtil::sort($expectedTags), ArrayUtil::sort($contactTags));
}
示例4: testScanForTags
public function testScanForTags()
{
$contact = $this->contacts('testAnyone');
$contact->clearTags();
$tags = array('#test', '#test2', '#test3');
foreach ($tags as $tag) {
$this->assertFalse($contact->hasTag($tag, null, true));
}
$contact->backgroundInfo = implode(' , ', $tags);
$contactTags = $contact->scanForTags();
$this->assertEquals($tags, ArrayUtil::sort($contactTags));
}