modification on parser to test

feature/article
Roxane ROSSETTO 1 year ago
parent 76787c26ef
commit 5de925155f

@ -48,4 +48,13 @@ class ArticleGateway
throw new Exception("PDO error");
}
}
public function removeAllArticleForParser(){
try{
$query = 'DELETE FROM Article;';
$this->con->executeQuery($query);
}catch(\PDOException $p){
throw new Exception("Data is not delete.");
}
}
}

@ -3,6 +3,7 @@
namespace model;
use DAL\ArticleGateway;
use DAL\Connection;
use DAL\FluxGateway;
use DOMDocument;
use Exception;
@ -62,13 +63,25 @@ class Parser
/**
* @throws Exception
*/
public function addAllArticles(){
$allFlux = $this->fluxGateway->findAllFlux();
public function addAllArticles()
{
$this->articleGateway->removeAllArticleForParser();
$allFlux = $this->fluxGateway->findAllFlux();
var_dump($allFlux);
$allArticles = $this->parseAll($allFlux);
var_dump($allArticles);
foreach ($allArticles as $article) {
$this->articleGateway->addArticle($article);
}
return $allArticles;
}
}
}
$gwArt = new ArticleGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp'));
$gwFl = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp'));
$pars = new Parser( $gwFl,$gwArt);
var_dump($pars->addAllArticles());

Loading…
Cancel
Save