Skip to content
Snippets Groups Projects
PhaseNoticeDublinCoreBokehTest.php 3.64 KiB
Newer Older
<?php
/**
 * Copyright (c) 2012-2023, 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
 */

require_once 'cosmogramme/php/fonctions/variables.php';
require_once 'PhaseNoticeTestCase.php';

abstract class AbstractPhaseNoticeDublinCoreBokehTestCase extends PhaseNoticeTestCase {
  protected function _prepareFixtures() {
    parent::_prepareFixtures();

    Class_TypeDoc::newInstanceWithId(15,
                                     ['label' => 'Online magazine']);

    Class_TypeDoc::newInstanceWithId(16,
                                     ['label' => 'atlas']);

    Class_TypeDoc::newInstanceWithId(25,
                                     ['label' => 'atlas plan']);

    $settings = ['format' => Class_IntProfilDonnees::FORMAT_DUBLIN_CORE_BOKEH,
                 'type_fichier' => Class_IntProfilDonnees::FT_RECORDS,
                 '0_type' => [''],
                 '0_format' => [''],
                 '15_type' => ['Magazine en ligne']];

    $serialized_settings = (new Class_ProfileSerializer($settings))->serializeDatas();

    Class_IntProfilDonnees::find(102)
      ->setTypeFichier(Class_IntProfilDonnees::FT_RECORDS)
      ->setFormat(Class_IntProfilDonnees::FORMAT_DUBLIN_CORE_BOKEH)
      ->setAttributs($serialized_settings)
      ->save();

    $this->fixture(Class_IntBib::class,
                   ['id' => 3,
                    'nom_court' => 'lm59']);

    Class_Cosmogramme_Integration::find(999)
      ->setIdBib(3)
      ->setFichier('dublinCoreBokehResults_all.xml')
      ->save();

    Class_CosmoVar::setValueOf('integration_path', __DIR__ . '/');
  }
}




class PhaseNoticeDublinCoreBokehTest extends AbstractPhaseNoticeDublinCoreBokehTestCase {
  /** @test */
  public function logShouldNotContainsError() {
    $this->assertNotLogContains('Erreur');
  }


  /** @test */
  public function totalNumberOfRecordsFromOAIShouldBeTwo() {
    $this->assertEquals(2, Class_Notice::count());
  }


  /** @test */
  public function firstRecordProviderShouldBeDublinCoreBokeh() {
    $this->assertEquals('DublinCoreBokeh',
                        Class_Notice::find(1)->get_subfield('801', 'b')[0]);
  }


  /** @test */
  public function firstRecordDocTypeShouldBeOnlineMagazine() {
    $this->assertEquals('Online magazine', Class_Notice::find(1)->getTypeDocLabel());
  }


  /** @test */
  public function firstRecordUrlVignetteShouldBeAsExpected() {
    $this->assertEquals('http://lm59-test.afi-sa.net/userfiles/album/25376/thumb_25376_cbbc6d773590425b269667acdc9acd1d.jpeg', Class_Notice::find(1)->getUrlVignette());
  }


  /** @test */
  public function firstRecordShouldHaveOneItem() {
    $this->assertCount(1, Class_Notice::find(1)->getExemplaires());
  }


  /** @test */
  public function secondRecordUrlVignetteShouldBeAsExpected() {
    $this->assertEquals('https://bm-lille.fr/Ils/digitalCollection/DigitalCollectionThumbnailHandler.ashx?documentId=12755', Class_Notice::find(2)->getUrlVignette());