Skip to content
Snippets Groups Projects
RunLogControllerTest.php 4.31 KiB
Newer Older
<?php
/**
 * Copyright (c) 2012-2017, 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 RunLogControllerByDateTest extends CosmoControllerTestCase {
  public function setUp() {
    parent::setUp();

    $this->fixture('Class_CosmoVar',
                   ['id' => 'type_fichier',
                    'liste' => "0:notices\r\n1:abonnés\r\n2:prêts\r\n3:reservations\r\n4:paniers\r\n5:autorités"]);

    $this->fixture('Class_CosmoVar',
                   ['id' => 'import_type_operation',
                    'liste' => "0:Import incrémentiel\r\n1:Suppression d'exemplaires\r\n2:Import total\r\n3:Suppression fichier d'entête Pergame"]);

    $this->fixture('Class_Cosmogramme_Integration',
                   ['id' => 10439,
                    'traite' => '2018-11-06',
                    'fichier' => 'integre1212.pan',
                    'pointeur_reprise' => 0,
                    'nb_erreurs' => 0,
                    'nb_warnings' => 0,
                    'type_operation' => Class_Cosmogramme_Integration::TYPE_OPERATION_TOTAL,
                    'bib' => $this->fixture('Class_IntBib', ['id' => 3, 'nom_court' => 'test']),
                    'profil_donnees' => $this->fixture('Class_IntProfilDonnees',
                                                       ['id' => 678,
                                                        'type_fichier' => Class_IntProfilDonnees::FT_AUTHORITY])
                   ]);

    $filesystem = $this->mock()
                       ->whenCalled('file_exists')->answers(true)
                       ->whenCalled('filesize')->answers(2299270)
      ;
    Class_Cosmogramme_Integration::setFileSystem($filesystem);

    $this->dispatch('/cosmo/run-log/by-date/date/2018-11-06');
  }


  public function tearDown() {
    Class_Cosmogramme_Integration::setFileSystem(null);
    parent::tearDown();
  }


  /** @test */
  public function titleShouldBeJournalDesIntegrations() {
    $this->assertXPathContentContains('//h1', 'Journal des intégrations du mardi 6 novembre 2018');
  }


  /** @test */
  public function linkToSyntheseShouldBePresent() {
    $this->assertXPath('//a[contains(@href, "/run-log/synthese/id/10439/date/2018-11-06")]');
  }


  /** @test */
  public function firstColumnTitleShouldBeDate() {
    $this->assertXPathContentContains('(//th)[1]', 'Date');
  }


  /** @test */
  public function secondColumnTitleShouldBeBibliotheque() {
    $this->assertXPathContentContains('(//th)[2]', 'Bibliothèque');
  }


  /** @test */
  public function thirdColumnTitleShouldBeTypeDeFichier() {
    $this->assertXPathContentContains('(//th)[3]', 'Type de fichier');
  }


  /** @test */
  public function dateShouldBePresent() {
    $this->assertXPathContentContains('//td', 'mardi 6 novembre 2018');
  }


  /** @test */
  public function libraryShouldBePresent() {
    $this->assertXPathContentContains('//td', 'test');
  }


  /** @test */
  public function fileTypeShouldBeAuthorities() {
    $this->assertXPathContentContains('//td', 'autorités');
  }


  /** @test */
  public function operationTypeShouldBeTotal() {
    $this->assertXPathContentContains('//td', 'Import total');
  }


  /** @test */
  public function fileShouldBeIntegre1212DotPan() {
    $this->assertXPathContentContains('//td',
                                      'integre1212.pan');
  }


  /** @test */
  public function fileSizeShouldBe2245Ko() {
    $this->assertXPathContentContains('//td', '2 245');
  }


  /** @test */
  public function fileDownloadLinkShouldBePresent() {
    $this->assertXPath('//a[contains(@href, "/run-log/download/id/10439/date/2018-11-06")]');
  }
}