$iter_att->save();
$related_news = getRelatedNews($obj);
$n_related_news = count($related_news);
$generated_news = $iter_att->getGeneratedNews();
$first_generated = $generated_news[0];
$t->ok($n_related_news == 5, 'Five related news');
$t->ok($first_generated->getPriority() == 2, 'Priority for non-conclusive iter step is ' . $first_generated->getPriority());
dumpNews($t, "news related to the act", $related_news);
$t->diag('Add a new politician');
$pol = new OppPolitico();
$pol->setNome('Guglielmo');
$pol->setCognome('Celata');
$pol->setId(999999);
$pol->save();
$t->diag('Add a new charge');
$car = new OppCarica();
$car->setId(999999);
$car->setOppPolitico($pol);
$car->setTipoCaricaId(2);
$car->setCarica('Ministro dell\'abolizione dei beni Inutili');
$car->setDataInizio('2008-10-10');
$car->save();
$pol_related_news = getRelatedNews($pol);
$n_pol_related_news = count($pol_related_news);
$t->diag("related_news: " . $n_pol_related_news);
$t->ok($n_pol_related_news == 1, 'One news related to the politician');
dumpNews($t, "news related to the politician", $pol_related_news);
$t->diag('Add a group to the charge');
$gruppo = OppGruppoPeer::retrieveByPK(1);
$car_gruppo = new OppCaricaHasGruppo();
$car_gruppo->setOppCarica($car);
define('SF_ENVIRONMENT', 'dev');
define('SF_DEBUG', true);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
sfContext::getInstance();
print "Fetching data... \n";
$xml = simplexml_load_file('http://www.openpolis.it/api/senatori');
foreach ($xml->charges->charge as $charge) {
    $politico = OppPoliticoPeer::RetrieveByPk($charge->politicianid);
    if ($politico == null) {
        $xml = simplexml_load_file('http://www.openpolis.it/api/politician/id/' . $charge->politicianid);
        $nome = $xml->politician->firstname;
        $cognome = $xml->politician->lastname;
        echo "{$nome} {$cognome} \n";
        $politico = new OppPolitico();
        $politico->setId($charge->politicianid);
        $politico->setNome($nome);
        $politico->setCognome($cognome);
        $politico->save();
    }
    $carica = new OppCarica();
    $carica->setId($charge->id);
    $carica->setPoliticoId($charge->politicianid);
    $carica->setCarica($charge->chargetype);
    $carica->setDataInizio($charge->datestart);
    $carica->setGruppo($charge->group);
    $carica->setLegislatura(16);
    $carica->setCircoscrizione($charge->constituency);
    $carica->save();
    echo "{$charge->id}\n";
}
print "done.\n";