public function test_delete_ok()
 {
     $oldCount = CollaborationPeer::doCount(new Criteria());
     $this->goto_edit();
     $this->b->click('delete')->isRedirected()->followRedirect()->checkResponseElement('body', '/Collaborations/')->checkResponseElement('body', '!/' . $this->Collaborations['c1']['name'] . '/');
     $this->b->test()->is($oldCount - 1, CollaborationPeer::doCount(new Criteria()), "Collaboration count should still be one less than {$oldCount}");
 }
 public function test_create_fails()
 {
     $oldCount = CollaborationPeer::doCount(new Criteria());
     $organizations = OrganizationPeer::doSelect(new Criteria());
     $organization1_id = $organizations[0]->getId();
     $this->b->test()->ok($organization1_id, "Should get organization " . $organization1_id);
     $this->b->get('/collaboration/list')->checkResponseElement('body', '/Collaboration/')->checkResponseElement('body', '/Name/');
     $this->b->click('Create Collaboration')->checkResponseElement('body', '/Create Collaboration/');
     $this->b->click('save', array('name' => 'Collabor 101', 'collaboratingOrganizations' => array($organization1_id)))->checkResponseElement('body', '/Create Collaboration/')->checkResponseElement('body', '/Collaboration must contain at least two organizations/');
     $this->b->test()->is($oldCount, CollaborationPeer::doCount(new Criteria()), "Collaboration count should still be {$oldCount}");
 }
 public function test_create_ok()
 {
     $oldCount = CollaborationPeer::doCount(new Criteria());
     $organizations = OrganizationPeer::doSelect(new Criteria());
     $organization1_id = $organizations[0]->getId();
     $organization2_id = $organizations[1]->getId();
     $this->b->test()->ok($organization1_id, "Should get organization " . $organization1_id);
     $this->b->test()->ok($organization2_id, "Should get organization " . $organization2_id);
     $this->b->get('/collaboration/list')->checkResponseElement('body', '/Collaboration/')->checkResponseElement('body', '/Name/');
     $this->b->click('Create Collaboration')->checkResponseElement('body', '/Create Collaboration/');
     $this->b->click('save', array('name' => 'Kenglish', 'collaboratingOrganizations' => array($organization1_id, $organization2_id), 'collaborationYears' => array(2000, 2009)))->isRedirected()->followRedirect()->checkResponseElement('body', '/View Collaboration/')->checkResponseElement('body', '/Kenglish/');
     $this->b->test()->is($oldCount + 1, CollaborationPeer::doCount(new Criteria()), "Collaboration count should be " . ($oldCount + 1));
 }
 public static function doSelectJoinAll(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     CollaborationYearPeer::addSelectColumns($c);
     $startcol2 = CollaborationYearPeer::NUM_COLUMNS - CollaborationYearPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     CollaborationPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + CollaborationPeer::NUM_COLUMNS;
     $c->addJoin(CollaborationYearPeer::COLLABORATION_ID, CollaborationPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = CollaborationYearPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = CollaborationPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getCollaboration();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addCollaborationYear($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initCollaborationYears();
             $obj2->addCollaborationYear($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
 public function getCollaboration($con = null)
 {
     if ($this->aCollaboration === null && $this->collaboration_id !== null) {
         include_once 'lib/model/om/BaseCollaborationPeer.php';
         $this->aCollaboration = CollaborationPeer::retrieveByPK($this->collaboration_id, $con);
     }
     return $this->aCollaboration;
 }
 public function executeDelete()
 {
     $collaboration = CollaborationPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($collaboration);
     $collaboration->delete();
     return $this->redirect('collaboration/list');
 }
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(CollaborationPeer::ID, $pks, Criteria::IN);
         $objs = CollaborationPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = CollaborationPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDescription($arr[$keys[2]]);
     }
 }