}
$c = new Criteria();
$c->add(OppPoliticoPeer::ID, 999999);
$existing_records = OppPoliticoPeer::doSelect($c);
foreach ($existing_records as $rec) {
    $t->diag('Cleaning record ' . get_class($rec) . "(" . $rec->getId() . ")");
    $rec->delete();
}
$t->diag('Create the test act object');
$obj = new OppAtto();
$obj->setTipoAttoId(1);
$obj->setParlamentoId(999999);
$obj->setRamo('S');
$obj->setNumFase(914);
$obj->setDataPres('2008-11-01');
$obj->setDescrizione("Una descrizione di prova");
$obj->save();
$related_news = getRelatedNews($obj);
$n_related_news = count($related_news);
$first_news = $related_news[0];
$t->ok($n_related_news == 1, 'One news related to the act was generated');
dumpNews($t, "news related to the act", $related_news);
$t->diag('Create a non-final votation: two more news expected (group and detail)');
$vot = OppVotazionePeer::retrieveByPK(9900);
$vot_att = new OppVotazioneHasAtto();
$vot_att->setOppVotazione($vot);
$vot_att->setOppAtto($obj);
$vot_att->save();
$related_news = getRelatedNews($obj);
$n_related_news = count($related_news);
$t->ok($n_related_news == 3, 'Now there are two more news related to the act');
    $t->diag('Cleaning record ' . get_class($rec) . "(" . $rec->getId() . ")");
    $rec->delete();
}
$c = new Criteria();
$c->add(OppVotazionePeer::NUMERO_VOTAZIONE, 999999);
$existing_records = OppVotazionePeer::doSelect($c);
foreach ($existing_records as $rec) {
    $t->diag('Cleaning record ' . get_class($rec) . "(" . $rec->getId() . ")");
    $rec->delete();
}
$t->diag('Create the act object');
$obj_atto = new OppAtto();
$obj_atto->setTipoAttoId(1);
$obj_atto->setParlamentoId(999999);
$obj_atto->setDataPres('2008-11-01');
$obj_atto->setDescrizione("Un'atto di test");
$obj_atto->save();
$prefix = sfConfig::get(sprintf('propel_behavior_wikifiableBehavior_%s_prefix', get_class($obj_atto)));
$t->ok($prefix == 'atto', 'The prefix was correctly read from the behavior configuration');
$wiki_page = nahoWikiPagePeer::retrieveByName($prefix . "_" . $obj_atto->getId());
$t->ok($wiki_page instanceof nahoWikiPage, 'a wiki page was just created for this object');
$c = new Criteria();
$c->add(nahoWikiRevisionPeer::REVISION, 1);
$wiki_revisions = $wiki_page->getRevisions($c);
$wiki_revision = $wiki_revisions[0];
$t->ok(count($wiki_revisions) == 1 && $wiki_revision instanceof nahoWikiRevision, 'a wiki revision was added');
$wiki_content = $wiki_revision->getnahoWikiContent();
$t->ok($wiki_content instanceof nahoWikiContent, 'a wiki content was also added');
$t->ok($wiki_revision->getComment() == 'Creazione Automatica' && $wiki_revision->getContent() == 'Descrizione wiki, a cura degli utenti.', 'comment and content were correctly inserted');
$atto_page_id = $wiki_page->getId();
$atto_revision_num = $wiki_revision->getRevision();
Ejemplo n.º 3
0
<?php

define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..'));
define('SF_APP', 'fe');
define('SF_ENVIRONMENT', 'dev');
define('SF_DEBUG', false);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
$ddls = OppDdlPeer::doSelect(new Criteria());
foreach ($ddls as $ddl) {
    $atto = new OppAtto();
    $atto->setId($ddl->getId());
    $atto->setParlamentoId($ddl->getParlamentoId());
    $atto->setTipoAttoId($ddl->getTipo());
    $atto->setRamo($ddl->getRamo());
    $atto->setNumfase($ddl->getNumfase());
    $atto->setLegislatura($ddl->getLegislatura());
    $atto->setDataPres($ddl->getDataPres());
    $atto->setDataAgg($ddl->getDataAgg());
    $atto->setTitolo($ddl->getTitolo());
    $atto->setIniziativa($ddl->getIniziativa());
    $atto->setCompleto($ddl->getCompleto());
    $atto->setDescrizione($ddl->getDescrizione());
    $atto->setSeduta($ddl->getSeduta());
    $atto->setIter($ddl->getIter());
    $atto->setDataIter($ddl->getDataIter());
    $atto->save();
    print "atto: " . $atto->getId() . "...\n";
}
print "done.\n";
$t->diag('Tests beginning');
// clean the database
$t->diag('Cleaning previously created test records');
$c = new Criteria();
$c->add(OppAttoPeer::PARLAMENTO_ID, 999999);
$existing_records = OppAttoPeer::doSelect($c);
foreach ($existing_records as $rec) {
    $t->diag('Cleaning record ' . $rec->getId());
    $rec->delete();
}
$t->diag('Preparing a longvarchar variable');
$longvarchar = '';
for ($i = 0; $i < 15000; $i++) {
    $longvarchar .= 'pippo ';
}
$var_length = strlen($longvarchar);
$t->diag('Long variable created: length=' . $var_length);
$t->diag('Create the test OppAtto object');
$obj = new OppAtto();
$obj->setTipoAttoId(1);
$obj->setParlamentoId(999999);
$obj->setDescrizione($longvarchar);
$obj->save();
$c = new Criteria();
$c->add(OppAttoPeer::PARLAMENTO_ID, 999999);
$read_obj = OppAttoPeer::doSelectOne($c);
$read_var = $read_obj->getDescrizione();
$read_length = strlen($read_var);
$t->diag('Long variable read from DB: length=' . $read_length);
$t->ok($read_var == $longvarchar, 'the variable was set correctly');
$t->ok($read_length == $var_length, 'the length is ok');