Skip to content
Snippets Groups Projects
Commit dcf279e0 authored by Laurent's avatar Laurent
Browse files

dev #17990 article categories and domains attribution

parent 4a8fd1bc
Branches
Tags
2 merge requests!565Dev#17990 miop integration suite,!561Dev#17990 miop integration suite
......@@ -62,10 +62,10 @@ class Class_Import_Typo3 {
$this->import_categories();
echo "Importing articles\n";
$this->import_articles();
$this->importArticles();
echo "Importing articles pages\n";
$this->import_articles_pages();
$this->importArticlesPages();
echo "Importing events\n";
$this->import_calendar();
......@@ -200,7 +200,7 @@ class Class_Import_Typo3 {
}
public function import_articles() {
public function importArticles() {
$_SERVER['HTTP_HOST']='localhost';
$t3news = $this->t3db->findAllArticles();
foreach($t3news as $new) {
......@@ -229,12 +229,16 @@ class Class_Import_Typo3 {
Class_Import_Typo3_Logs::getInstance()->incrementArticlesSaved();
$t3_news_domains = $this->t3db->findAllForeignUidForNewsCat($new['uid']);
$domains = [];
$domains = [$this->domaine_map->findOrCreateDomaine($element->getCategorie())];
foreach ($t3_news_domains as $t3_domain) {
if (!$category = $this->news_categories_map->find($t3_domain['uid_foreign']))
$category = $this->sites_categories_map->find($t3_domain['uid_foreign']);
$domains[] = $this->domaine_map->findOrCreateDomaine($category);
}
if (isset($category)) {
$element->setCategorie($category);
}
$element->setDomaines($domains)->save();
}
......@@ -309,7 +313,7 @@ class Class_Import_Typo3 {
public function import_articles_pages() {
public function importArticlesPages() {
$rows = $this->t3db->findAllContents();
$pages_cat = Class_ArticleCategorie::newInstance(['libelle' => 'Pages fixes']);
......
......@@ -189,7 +189,7 @@ class Import_Typo3ArticleTest extends Import_Typo3TestCase {
$this->migration->import_user();
$this->migration->import_categories();
$this->migration->import_articles();
$this->migration->importArticles();
}
......@@ -199,13 +199,6 @@ class Import_Typo3ArticleTest extends Import_Typo3TestCase {
}
/** @test */
public function articleABordDuBateauPirateShouldHaveCategorieSaocieteCivilisation() {
$id_cat = Class_Article::findFirstBy(['titre' => 'A bord du bateau pirate'])->getIdCat();
$this->assertEquals('Société & Civilisation', Class_ArticleCategorie::findFirstBy(['id_cat' => $id_cat])->getLibelle());
}
/** @test */
public function articleABordDuBateauPirateShouldBelongToSerge() {
$id_user = Class_Article::findFirstBy(['titre' => 'A bord du bateau pirate'])->getIdUser();
......@@ -220,7 +213,14 @@ class Import_Typo3ArticleTest extends Import_Typo3TestCase {
foreach (explode(';', $domaine_ids) as $id) {
$domaines[] = Class_Catalogue::findFirstBy(['id_catalogue' => $id])->getLibelle();
}
$this->assertEquals(['Divers', 'Autres'], $domaines);
$this->assertEquals(['Société & Civilisation', 'Divers', 'Autres'], $domaines);
}
/** @test */
public function articleABordDuBateauPirateCategoryShouldBeAutres() {
$this->assertEquals('Autres',
Class_Article::findFirstBy(['titre' => 'A bord du bateau pirate'])->getCategorieLibelle());
}
......@@ -359,7 +359,7 @@ class Import_Typo3ContentTest extends Import_Typo3TestCase {
public function setUp() {
parent::setUp();
$this->migration->import_categories();
$this->migration->import_articles_pages();
$this->migration->importArticlesPages();
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment