Skip to content
Snippets Groups Projects
Commit 93031311 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'hotline#88956_problemes_affichage_realisateur_arte_vod' into 'hotline'

hotline#88956 : add authors migration script

See merge request !3109
parents 51dd76f0 fd05f674
Branches
Tags
3 merge requests!3297WIP: Master,!3125Hotline,!3109hotline#88956 : add authors migration script
Pipeline #6981 passed with stage
in 35 minutes and 38 seconds
- ticket #88956 : Arte VOD : ajout d'un script de mise à jour des auteurs
\ No newline at end of file
<?php
(new Class_Migration_ArteVODAuthorsOrder())->updateAuthorsForAllAlbums();
<?php
/**
* Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Migration_ArteVODAuthorsOrder {
public function updateAuthors($album) {
$old_authors = new Storm_Collection($album->getAuthors());
$album->getMarc()->clearZone('701');
$this->addAuthorsTo($old_authors, function($author)
{
return $author->getResponsibility()=='300';
}, $album);
$this->addAuthorsTo($old_authors, function($author)
{
return $author->getResponsibility()!='300';
}, $album);
$album->index();
}
public function updateAuthorsForAllAlbums($closure=null) {
foreach(Class_Album::findAllBy(['type_doc_id' => Class_TypeDoc::ARTEVOD]) as $album) {
$this->updateAuthors($album);
if ($closure)
$closure($album);
}
}
protected function addAuthorsTo($authors, $closure, $album) {
$authors->select($closure)
->eachDo(function ($author) use ($album)
{
$album->addAuthor($author);
}) ;
}
}
<?php
error_reporting(E_ERROR | E_PARSE);
require(__DIR__.'/../console.php');
(new Class_Migration_ArteVODAuthorsOrder())
->updateAuthorsForAllAlbums(function($album) { echo 'updated [ ' .$album->getTitre()." ]\n";});
......@@ -2585,3 +2585,11 @@ class UpgradeDB_369_Test extends UpgradeDBTestCase {
$this->assertIndex('rendez_vous', $key);
}
}
class UpgradeDB_370_Test extends UpgradeDBTestCase {
public function prepare() {}
/** @test */
public function placeholderForArteVodUpdateAuthor() {}
}
......@@ -153,10 +153,4 @@ class ArteVodLinkWithUserAndAlbumTest extends ModelTestCase {
$this->_arte_vod_link->url());
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ArteVodLinkUpdateAuthorTest extends ModelTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$album = $this->fixture('Class_Album',
['id' => 5,
'titre' => 'Comme elle respire',
]);
$album->beArteVOD()
->setNotes([
['field' => '701',
'data' => ['a' => 'Trintignant Marie',
'4' => '005']],
['field' => '701',
'data' => ['a' => 'Depardieu Guillaume',
'4' => '005']],
['field' => '701',
'data' => ['a' => 'Salvadori Pierre',
'4' => '300']],
['field' => '701',
'data' => ['a' => 'Zo',
'4' => '300']],
['field' => '701',
'data'=> ['a' => 'Jean-François Stévenin',
'4' => '005']],
['field' => '701',
'data' => ['a' => 'Mastroiani',
'4' => '300']],
])
->setVisible(true)
->setExternalUri("http://artevod/comme-elle-respire")
->beValidated()
->save();
(new Class_Migration_ArteVODAuthorsOrder())->updateAuthorsForAllAlbums();
}
/** @test */
public function directorShouldBeSalvadori() {
$this->assertEquals('Salvadori Pierre' ,
Class_Notice::findFirstBy([])->getAuteurPrincipal());
}
/** @test */
public function secondDirectorShouldBeZo() {
$this->assertEquals('Zo|' ,
Class_Notice::findFirstBy([])->getAuteursUnimarc()[1]);
}
/** @test */
public function thirdDirectorShouldBeMastroiani() {
$this->assertEquals('Mastroiani|' ,
Class_Notice::findFirstBy([])->getAuteursUnimarc()[2]);
}
/** @test */
public function firstActorShouldBeTrintignant() {
$this->assertEquals('Trintignant Marie|' ,
Class_Notice::findFirstBy([])->getAuteursUnimarc()[3]);
}
/** @test */
public function secondActorShouldBeDepardieu() {
$this->assertEquals('Depardieu Guillaume|' ,
Class_Notice::findFirstBy([])->getAuteursUnimarc()[4]);
}
/** @test */
public function thirdActorShouldBeDepardieu() {
$this->assertEquals('Jean-François Stévenin|' ,
Class_Notice::findFirstBy([])->getAuteursUnimarc()[5]);
}
/** @test */
public function externalUriShouldBeCommeElleRespire() {
$this->assertContains('http://artevod/comme-elle-respire',
implode(Class_Notice::findFirstBy([])->getUnimarcZone("856")));
}
}
\ No newline at end of file
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