public function testGetAssignedTo() { // Flush the cache; we're doing group membership tests, which will use // the cache, and we've loaded fixtures that affect that: $cacheVal = Yii::app()->cache->get('user_groups'); $this->assertTrue(Yii::app()->cache->flush()); $this->assertTrue($cacheVal === false || $cacheVal !== Yii::app()->cache->get('user_groups')); // Direct single-user assignment: $action = new Actions(); $action->assignedTo = 'testUser1'; $this->assertTrue($action->isAssignedTo('testUser1')); // Assignment via single-group association: $action = new Actions(); $action->assignedTo = '2'; //$assignees = explode(', ','2'); //$groupIds = array_filter($assignees,'ctype_digit'); //$userGroupsAssigned = array_intersect($groupIds,Groups::getUserGroups(1)); $this->assertTrue($action->isAssignedTo('testUser1')); // Assigned via "Anyone" or null assignment: $action = new Actions(); $action->assignedTo = 'Anyone'; $this->assertTrue($action->isAssignedTo('testUser1')); $action = new Actions(); $action->assignedTo = ''; $this->assertTrue($action->isAssignedTo('testUser1')); // Assigned via multiple assignment (username): $action = new Actions(); $action->assignedTo = 'testUser1, testUser2'; $this->assertTrue($action->isAssignedTo('testUser1')); // Assigned via multiple assignment (group): $action = new Actions(); $action->assignedTo = '2, testUser2'; $this->assertTrue($action->isAssignedTo('testUser1')); // Not assigned (single): $action = new Actions(); $action->assignedTo = 'testUser2'; $this->assertFalse($action->isAssignedTo('testUser1')); // Not assigned (multiple) $action = new Actions(); $action->assignedTo = 'testUser2, testUser3'; $this->assertFalse($action->isAssignedTo('testUser1')); }