示例#1
0
 /**
  * Create new list from selection then mass add to newly created list
  */
 public function testExecute()
 {
     TestingAuxLib::suLogin('admin');
     X2List::model()->deleteAllByAttributes(array('name' => 'test'));
     $newList = new NewListFromSelection();
     $addToList = new MassAddToList();
     // create new list with 2 records
     $_POST['modelType'] = 'Contacts';
     $_POST['listName'] = 'test';
     $_SERVER['REQUEST_METHOD'] = 'POST';
     $_SERVER['SERVER_NAME'] = 'localhost';
     Yii::app()->controller = new ContactsController('contacts', new ContactsModule('contacts', null));
     $gvSelection = range(1, 2);
     AuxLib::debugLogR($newList->execute($gvSelection));
     $getFlashes = TestingAuxLib::setPublic('NewListFromSelection', 'getFlashes');
     AuxLib::debugLogR($getFlashes());
     $list = X2List::model()->findByAttributes(array('name' => 'test'));
     $itemIds = $list->queryCommand(true)->select('id')->queryColumn();
     $this->assertEquals(array(1, 2), $itemIds);
     //  add the rest of the contacts to the newly created list
     unset($_POST['modelType']);
     unset($_POST['listName']);
     $_POST['listId'] = $list->id;
     $gvSelection = range(3, 24);
     $addToList->execute($gvSelection);
     $itemIds = $list->queryCommand(true)->select('id')->queryColumn();
     $this->assertEquals(range(1, 24), $itemIds);
 }
 /**
  * Mass update firstName and lastName for fixture records 
  */
 public function testExecute()
 {
     X2List::model()->deleteAllByAttributes(array('name' => 'test'));
     $_POST['modelType'] = 'Contacts';
     $_POST['listName'] = 'test';
     $_SERVER['REQUEST_METHOD'] = 'POST';
     $_SERVER['SERVER_NAME'] = 'localhost';
     $gvSelection = range(1, 24);
     Yii::app()->controller = new ContactsController('contacts', new ContactsModule('contacts', null));
     $newList = new NewListFromSelection();
     $newList->execute($gvSelection);
     $list = X2List::model()->findByAttributes(array('name' => 'test'));
     $itemIds = $list->queryCommand(true)->select('id')->queryColumn();
     $contactIds = Yii::app()->db->createCommand(" \n            SELECT id \n            FROM x2_contacts\n        ")->queryColumn();
     $this->assertEquals($contactIds, $itemIds);
 }