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


PHP ArrayUtil::sort方法代码示例

本文整理汇总了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());
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:28,代码来源:ModulesTest.php

示例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();
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:16,代码来源:X2CalendarPermissionsTest.php

示例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));
    }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:22,代码来源:TagBehaviorTest.php

示例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));
 }
开发者ID:shayanyi,项目名称:CRM,代码行数:12,代码来源:TagBehaviorTest.php


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