Skip to content
Snippets Groups Projects
IntegrationControllerTest.php 26.6 KiB
Newer Older
<?php
/**
 * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
 *
Laurent's avatar
Laurent committed
 * 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).
 *
Laurent's avatar
Laurent committed
 * 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
Laurent's avatar
Laurent committed
 * along with BOKEH; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */


class Cosmo_IntegrationControllerTestActionTest extends CosmoControllerTestCase {
  protected $_service;

  public function setUp() {
    parent::setUp();
    $this->_service = $this->mock()->whenCalled('test')->answers('');
    Class_WebService_SIGB_Nanook::setService(['url_serveur' => 'http://localhost/ilsdi'],
                                             $this->_service);
  }


  public function tearDown() {
    Class_WebService_SIGB_Nanook::reset();
    parent::tearDown();
  }


	public function shouldHaveCalledServiceTestMethod() {
		$this->dispatch('/cosmo/integration/test?type=7&options[url_serveur]=' . urlencode('http://localhost/ilsdi'), true);

		$this->assertTrue($this->_service->methodHasBeenCalled('test'));



abstract class Cosmo_IntegrationControllerControlActionTestCase extends CosmoControllerTestCase {
	public function setUp() {
		parent::setUp();
    $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\r\n"]);

    $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\n"]);

		$this->file_system = $this->mock();
		Class_Cosmogramme_Integration::setFileSystem($this->file_system);
	}
}



class Cosmo_IntegrationControllerControlActionWithoutBibTest extends Cosmo_IntegrationControllerControlActionTestCase {
	public function setUp() {
		parent::setUp();
		$this->dispatch('/cosmo/integration/control/id/99', true);
	}

	/** @test */
	public function libraryShouldBeUnknown() {
		$this->assertXPathContentContains('//div[@class="message_grand"]',
																			'Bibliothèque inconnue');
	}


	/** @test */
	public function shouldNotHavePlanif() {
		$this->assertXPathContentContains('//h3', 'Plannification : Aucune');
	}


	/** @test */
	public function shouldNotHaveFiles() {
		$this->assertXPathContentContains('//h3', 'Cette bibliothèque n\'a jamais été intégrée.');
	}
}



class Cosmo_IntegrationControllerControlActionWithBibTest extends Cosmo_IntegrationControllerControlActionTestCase {
	public function setUp() {
		parent::setUp();
		$this->file_system
			->whenCalled('file_exists')->answers(true)
			->whenCalled('filesize')->answers(1024)
			;

Laurent's avatar
Laurent committed
		$profil = $this->fixture('Class_IntProfilDonnees',
														 ['id' => 1,
															'type_fichier' => 1]);

		$integration = $this->fixture('Class_Cosmogramme_Integration',
																	['id' => 29,
																	 'traite' => 'non',
																	 'date_transfert' => '2014-11-14',
																	 'type_operation' => 2,
																	 'fichier' => 'integre0000.pan',
																	 'pointeur_reprise' => 0,
																	 'nb_erreurs' => 0,
																	 'nb_warnings' => 0,
																	 'profil_donnees' => $profil]);
		$this->fixture('Class_IntBib',
									 ['id' => 19,
										'nom_court' => 'Testing library',
										'planif_mode' => 'r',
										'planif_jours' => '0010011',
										'integrations' => [$integration]]);

		$this->dispatch('/cosmo/integration/control/id/19', true);
	}


	/** @test */
	public function libraryShouldBePresent() {
		$this->assertXPathContentContains('//div[@class="message_grand"]',
																			'Testing library');
	}


	/** @test */
	public function shouldHavePlanif() {
		$this->assertXPathContentContains('//h3', 'Plannification : Me, Sa, Di');
	}


	/** @test */
	public function shouldHaveFiles() {
		$this->assertXPath('//table');
	}


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


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


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


	/** @test */
	public function downloadLinkShouldBePresent() {
		$this->assertXPath('//a[contains(@href, "run-log/download/id/29")]');
	}


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



abstract class Cosmo_IntegrationControllerGenerateActionTestCase extends CosmoControllerTestCase {
  public function setUp() {
    parent::setUp();
    $this->fixture('Class_CosmoVar',
                   ['id' => 'ftp_path',
                    'valeur' => '../ftp/transfert/']);

    $subdir_calls = 0;
    $subdir_provider = function() use (&$subdir_calls) {
      $subdir_calls++;
      $mapping = [1 => '.', 2 => '..', 3 => 'library', 4 => 'test'];
      return array_key_exists($subdir_calls, $mapping) ? $mapping[$subdir_calls] : false;
    };

    $file_system = $this->mock()
                        ->whenCalled('file_exists')->with('../ftp/transfert/')
                        ->answers(true)

                        ->whenCalled('opendir')->with('../ftp/transfert/')
                        ->answers(true)

                        ->whenCalled('readdir')->with(true)
                        ->willDo($subdir_provider)

                        ->whenCalled('is_dir')->with('../ftp/transfert/library')
                        ->answers(true)

                        ->whenCalled('is_readable')
                        ->with('../ftp/transfert/library/etalon')
                        ->answers(true)

                        ->whenCalled('is_readable')
                        ->with('../ftp/transfert/library/etalon/annexes.txt')
                        ->answers(true)

                        ->whenCalled('is_readable')
                        ->with('../ftp/transfert/library/etalon/genres.txt')
                        ->answers(true)

                        ->whenCalled('is_readable')
                        ->with('../ftp/transfert/library/etalon/sections.txt')
                        ->with('../ftp/transfert/library/etalon/emplacements.txt')
                        ->with('../ftp/transfert/library/etalon/annexes.txt')
                        ->answers(['BIB_SPS_UTT|ID_SITE|LIBELLE',
                                   '20|library1',
                        ->with('../ftp/transfert/library/etalon/sections.txt')
                        ->answers(['BIB_C_SECTION|CODE|LIBELLE',
                                   '1|Adulte',
                                   '2|Jeunesse'])

                        ->whenCalled('file')
                        ->with('../ftp/transfert/library/etalon/emplacements.txt')
                        ->answers(['BIB_C_EMPLACEMENT|CODE|LIBELLE',
                                   '4|Coin des tout-petits',
                                   '5|Livres CD',
                                   '6|Bacs imagiers',
                                   '7|Albums'])
                        ->with('../ftp/transfert/library/etalon/genres.txt')
                        ->answers(['BIB_GENRES|SUPPORT|CODE|LIBELLE|DOC',
                                   '0|1|Album|f',
                                   '0|2|Bande dessinée|f',
                                   '0|3|Biographie|f'])

                        ->beStrict();

    Class_Cosmogramme_LandingDirectory::setFileSystem($file_system);
  }


  public function tearDown() {
    Class_Log::getInstance()->reset();
    parent::tearDown();
  }
}



class Cosmo_IntegrationControllerGenerateActionTest extends Cosmo_IntegrationControllerGenerateActionTestCase {
  public function setUp() {
    parent::setUp();
    $this->dispatch('cosmo/integration/generate', true);
  }


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


  /** @test */
  public function titleShouldBeGenerationAutomatique() {
    $this->assertXPathContentContains('//h1', 'Génération automatique');
  }


  /** @test */
  public function library1ShouldBeSelectable() {
    $this->assertXPath('//select[@name="path_ftp"]//option[@value="library"]');
  }


  /** @test */
  public function testShouldNotBeSelectable() {
    $this->assertNotXPath('//select[@name="path_ftp"]//option[@value="test"]');
  }


  /** @test */
  public function parentShouldNotBeSelectable() {
    $this->assertNotXPath('//select[@name="path_ftp"]//option[@value=".."]');
  }


  /** @test */
  public function sigbNanookShouldBeSelectable() {
    $this->assertXPath('//select[@name="type_sigb"]//option[@value="13"]');
  }


  /** @test */
  public function shouldBeAbleToChooseBranchCreationMode() {
    $this->assertXPath('//select[@name="creer_annexes"]');
  }
}



class Cosmo_IntegrationControllerGenerateActionNanookPostTest
  extends Cosmo_IntegrationControllerGenerateActionTestCase {

  public function setUp() {
    parent::setUp();

    $this->fixture('Class_IntProfilDonnees',
                   ['id' => 104,
                    'libelle' => 'Unimarc Nanook',
                    'type_fichier' => 0]);

    $this->fixture('Class_IntProfilDonnees',
                   ['id' => 105,
                    'libelle' => 'Abonné Nanook',
                    'type_fichier' => 1]);

    $time_source = $this->mock()->whenCalled('time')->answers(strtotime('2016-01-28'));
    Class_Cosmogramme_Generator::setTimeSource($time_source);
    Class_Cosmogramme_Generator_AbstractTask::setTimeSource($time_source);
    $this->postDispatch('cosmo/integration/generate',
                         'service_nanook' => 'http://nanook-ws.net/ilsdi/',
  protected function _setupExistingDeletedBib() {
    $lib = $this->fixture('Class_IntBib',
                          ['id' => 6,
                           'nom' => 'Existing deleted',
                           'nom_court' => 'Deleted',
                           'qualite' => 5,
                           'sigb' => Class_IntBib::SIGB_NANOOK,
                           'planif_mode' => 'r',
                           'planif_jours' => '1111111',
                           'comm_sigb' => Class_IntBib::COM_NANOOK]);

    $this->fixture('Class_IntMajAuto',
                   ['id_bib' => 20,
                    'profil' => 103,
                    'type_operation' => Class_IntMajAuto::OP_FULL_IMPORT,
                    'nom_fichier' => 'library/site6/reservations.txt']);
  }


  public function tearDown() {
    Class_Cosmogramme_Generator::setTimeSource(null);
    Class_Cosmogramme_Generator_AbstractTask::setTimeSource(null);
  /** @test */
  public function shouldNotContainsForm() {
    $this->assertNotXPath('//form');
  }


  /** @test */
  public function shouldNotHaveError() {
    $this->assertNotXPath('//font[@color="red"]', $this->_response->getBody());
  }


  /** @test */
  public function shouldLogLibraryCreation() {
    $this->assertXPathContentContains('//h3', '1 - Création des bibliothèques', $this->_response->getBody());
  }


  /** @test */
  public function shouldHaveCreated2Libraries() {
    $this->assertEquals(2, Class_Cosmogramme_Generator_FixedIdBib::count());
  /** @test */
  public function shouldHaveDisabledExistingDeletedLibrary() {
    $this->assertTrue(Class_IntBib::find(6)->isDisconnected());
  }


  /** @test */
  public function shouldHaveDeletedExistingDeletedPlannedIntegrations() {
    $this->assertEmpty(Class_IntMajAuto::findAllBy(['id_bib' => 6]));
  }


  /** @test */
  public function library1ShouldBeCreated() {
    $this->assertNotNull(Class_Cosmogramme_Generator_FixedIdBib::findFirstBy(['id_site' => 20,
                                                                              'libelle' => 'library1',
                                                                              'ville' => 'library',
                                                                              'id_zone' => 1,
                                                                              'visibilite' => Class_Bib::V_DATA]));
  }


  /** @test */
  public function library1IntegrationShouldBeCreated() {
    $this->assertNotNull($bib = Class_IntBib::findFirstBy(['id_bib' => 20,
                                                           'nom' => 'library1',
                                                           'nom_court' => 'library',
                                                           'qualite' => 5,
                                                           'sigb' => Class_IntBib::SIGB_NANOOK,
                                                           'planif_mode' => 'r',
                                                           'planif_jours' => '1111111',
                                                           'comm_sigb' => Class_IntBib::COM_NANOOK
                                                           ]));
    return $bib;
  }


  /**
   * @test
   * @depends library1IntegrationShouldBeCreated
   */
  public function library1IntegrationCommParamsShouldContainsNanookWebservice($bib) {
    $this->assertContains('http://nanook-ws.net/ilsdi/', $bib->getCommParams());
  }


  /** @test */
  public function library1BranchShouldBeCreated() {
    $this->assertNotNull(Class_CodifAnnexe::findFirstBy(['id_bib' => 20,
                                                         'code' => 20,
                                                         'libelle' => 'library1',
                                                         'invisible' => 0]),
                         $this->_response->getBody());
  }


  /** @test */
  public function barCodeProfileShouldBeCreated() {
    $this->assertNotNull($profile = Class_IntProfilDonnees::findFirstBy(['libelle' => 'Liste de codes-barres']));
    return $profile;
  }


  /**
   * @test
   * @depends barCodeProfileShouldBeCreated
   */
  public function library1ShouldHeveItemDeletionPlanned($profile) {
    $this->assertNotNull(Class_IntMajAuto::findFirstBy(['id_bib' => 20,
                                                        'profil' => $profile->getId(),
                                                        'type_operation' => Class_IntMajAuto::OP_ITEMS_DELETION,
                                                        'nom_fichier' => 'library/site20/suppressions.txt']));
  }


  /** @test */
  public function library1ShouldHaveRecordsTotalPlanned() {
    $this->assertNotNull(Class_IntMajAuto::findFirstBy(['id_bib' => 20,
                                                        'profil' => 104,
                                                        'type_operation' => Class_IntMajAuto::OP_FULL_IMPORT,
                                                        'nom_fichier' => 'library/site20/notices_total.txt']));
  }


  /** @test */
  public function library1ShouldHaveRecordsPartialPlanned() {
    $this->assertNotNull(Class_IntMajAuto::findFirstBy(['id_bib' => 20,
                                                        'profil' => 104,
                                                        'type_operation' => Class_IntMajAuto::OP_PARTIAL_IMPORT,
                                                        'nom_fichier' => 'library/site20/notices.txt']));
  }


  /** @test */
  public function library1ShouldHaveUsersPlanned() {
    $this->assertNotNull(Class_IntMajAuto::findFirstBy(['id_bib' => 20,
                                                        'profil' => 105,
                                                        'type_operation' => Class_IntMajAuto::OP_FULL_IMPORT,
                                                        'nom_fichier' => 'library/site20/abonnes.txt']));
  }


  /** @test */
  public function library1ShouldHaveLoansPlanned() {
    $this->assertNotNull(Class_IntMajAuto::findFirstBy(['id_bib' => 20,
                                                        'profil' => 102,
                                                        'type_operation' => Class_IntMajAuto::OP_FULL_IMPORT,
                                                        'nom_fichier' => 'library/site20/prets.txt']));
  }


  /** @test */
  public function library1ShouldNotHaveHoldsPlanned() {
    $this->assertNull(Class_IntMajAuto::findFirstBy(['id_bib' => 20,
                                                     'profil' => 103,
                                                     'type_operation' => Class_IntMajAuto::OP_FULL_IMPORT,
                                                     'nom_fichier' => 'library/site20/reservations.txt']));
  }


  /** @test */
  public function basketsProfileShouldBeCreated() {
    $profile = Class_IntProfilDonnees::findFirstBy(['accents' => Class_IntProfilDonnees::ENCODING_UTF8,
                                                    'type_fichier' => Class_IntProfilDonnees::FT_BASKETS,
                                                    'format' => Class_IntProfilDonnees::FORMAT_PIPED_ASCII]);
    $this->assertNotNull($profile);
    return $profile;
  }



  /**
   * @test
   * @depends basketsProfileShouldBeCreated
   */
  public function library1ShouldHaveBasketsFullPlanned($profile) {
    $this->assertNotNull(Class_IntMajAuto::findFirstBy(['id_bib' => 20,
                                                        'profil' => $profile->getId(),
                                                        'type_operation' => Class_IntMajAuto::OP_FULL_IMPORT,
                                                        'nom_fichier' => 'library/site20/paniers_total.txt']));
  }


  /**
   * @test
   * @depends basketsProfileShouldBeCreated
   */
  public function library1ShouldHaveBasketsPartialPlanned($profile) {
    $this->assertNotNull(Class_IntMajAuto::findFirstBy(['id_bib' => 20,
                                                        'profil' => $profile->getId(),
                                                        'type_operation' => Class_IntMajAuto::OP_PARTIAL_IMPORT,
                                                        'nom_fichier' => 'library/site20/paniers.txt']));
  }


  /** @test */
  public function adulteSectionShouldBeCreated() {
    $this->assertNotNull(Class_CodifSection::findFirstBy(['libelle' => 'Adulte',
                                                          'regles' => '995$9=1']));
  }


  /** @test */
  public function coinLocationShouldBeCreated() {
    $this->assertNotNull(Class_CodifEmplacement::findFirstBy(['libelle' => 'Coin des tout-petits',
                                                              'regles' => '995$6=4']));


  /** @test */
  public function bdKindShouldBeCReated() {
    $this->assertNotNull(Class_CodifGenre::findFirstBy(['libelle' => 'Biographie',
                                                        'regles' => '995$7=3']));
  }


  /** @test */
  public function shouldHaveCreated10Deweys() {
    $this->assertEquals(10, Class_CodifDewey::count());
  }


  /** @test */
  public function generaliteDeweyShouldHaveId0() {
    $this->assertNotNull(Class_CodifDewey::findFirstBy(['id_dewey' => 0, 'libelle' => 'Généralités']));
  }


  /** @test */
  public function histoireDeweyShouldHaveId9() {
    $this->assertNotNull(Class_CodifDewey::findFirstBy(['id_dewey' => 9, 'libelle' => 'Histoire, géographie']));
  }


  /** @test */
  public function shouldSayFinished() {
    $this->assertXPathContentContains('//h2', 'Traitement terminé');
  }
}



abstract class Cosmo_IntegrationControllerWaitingFilesTestCase extends CosmoControllerTestCase {
  protected $_tot;

  public function setUp() {
    parent::setUp();
    Class_CosmoVar::set('ftp_path', '/ccpl34');

    $this->fixture('Class_IntMajAuto',
                   ['id' => 43,
                    'int_bib' => $this->fixture('Class_IntBib',
                                                ['id' => 1,
                                                 'nom_court' => 'Lunel']),
                    'libelle' => 'total',
                    'profil_donnees' => $this->fixture('Class_IntProfilDonnees',
                                                       ['id' => 34,
                                                        'libelle' => 'Unimarc KTM']),
                    'type_operation' => Class_IntMajAuto::OP_FULL_IMPORT,
                    'nom_fichier' => 'lunel/[DATE]_records_tot.mrc',
                    'taille_min_import_total' => 0]);
    $ccpl34 = $this
      ->mock()
      ->whenCalled('isDir')->answers(true)
      ->whenCalled('getPath')->answers('/ccpl34')
      ->whenCalled('getName')->answers('ccpl34');

    $lunel = $this
      ->mock()
      ->whenCalled('isDir')->answers(true)
      ->whenCalled('getPath')->answers('/ccpl34/lunel')
      ->whenCalled('getName')->answers('lunel')
      ->whenCalled('getParent')->answers($ccpl34);

    $etalon = $this
      ->mock()
      ->whenCalled('isDir')->answers(true)
      ->whenCalled('getPath')->answers('/ccpl34/etalon')
      ->whenCalled('getName')->answers('etalon')
      ->whenCalled('getParent')->answers($ccpl34);

    $kinds = $this
      ->mock()
      ->whenCalled('getName')->answers('genres.txt')
      ->whenCalled('getMTime')->answers('2019-01-13 22:88:77')
      ->whenCalled('getFileSize')->answers(43986)
      ->whenCalled('getParent')->answers($etalon)
      ->whenCalled('getPath')->answers('/ccpl34/etalon/genres.txt')
      ->whenCalled('getFileMTime')->answers('12345678')
      ->whenCalled('getProgrammed')->answers(null)
      ->whenCalled('isWritable')->answers(true)
      ->whenCalled('getId')->answers('/ccpl34/etalon/genres.txt')
      ->whenCalled('getParentPath')->answers('/ccpl34/etalon')
      ->whenCalled('isFile')->answers(true);

    $this->_tot = $this
      ->mock()
      ->whenCalled('getParent')->answers($lunel)
      ->whenCalled('isWritable')->answers(true)
      ->whenCalled('getName')->answers('20190116220001_records_tot.mrc')
      ->whenCalled('getMTime')->answers('2019-01-13 22:88:77')
      ->whenCalled('getFileMTime')->answers('1234567')
      ->whenCalled('getSize')->answers('42 Ko')
      ->whenCalled('getFileSize')->answers(43986)
      ->whenCalled('getId')->answers('/ccpl34/lunel/20190116220001_records_tot.mrc')
      ->whenCalled('getModels')->answers([])
      ->whenCalled('isDir')->answers(false)
      ->whenCalled('getPath')->answers('/ccpl34/lunel/20190116220001_records_tot.mrc')
      ->whenCalled('getParentPath')->answers('/ccpl34/lunel')
      ->whenCalled('readfile')->answers(true)
      ->whenCalled('getProgrammed')->answers(Class_IntMajAuto::find(43))
      ->whenCalled('isFile')->answers(true);
    $this->_tot->whenCalled('setProgrammed')->answers($this->_tot);

    $file_system = $this
      ->mock()
      ->whenCalled('search')->with('*', '/ccpl34/lunel')->answers([$this->_tot])

      ->whenCalled('search')->with('*', '/ccpl34/etalon')->answers([$kinds])

      ->whenCalled('directoriesAt')->with('/ccpl34')->answers([$lunel, $etalon])

      ->whenCalled('directoryAt')->with('ccpl34/lunel')->answers($lunel)

      ->whenCalled('directoryAt')->with('ccpl34/etalon')->answers($etalon)
      ->whenCalled('fileAt')->with('ccpl34/lunel')->answers(null)

      ->whenCalled('fileAt')->with('ccpl34/etalon')->answers(null)

      ->whenCalled('delete')->with('/ccpl34/lunel/20190116220001_records_tot.mrc')
      ->answers(true)

      ->whenCalled('directoryAt')->with('ccpl34/lunel/20190116220001_records_tot.mrc')
      ->answers(null)

      ->whenCalled('fileAt')->with('ccpl34/lunel/20190116220001_records_tot.mrc')


    Class_FileManager::setFileSystem($file_system);

    Class_Cosmogramme_LandingDirectory::setSubdirCache($etalon);

    Class_AdminVar::set('NOM_DOMAINE', 'http://localhost');
  }
}



class Cosmo_IntegrationControllerWaitingFilesActionTest
  extends Cosmo_IntegrationControllerWaitingFilesTestCase {
  public function setUp() {
    parent::setUp();
    $this->dispatch('/cosmo/integration/waiting-files');
  }


  /** @test */
  public function titleShouldBeFichiersEnAttenteDIntegration() {
    $this->assertXPathContentContains('//h1', 'Fichiers en attente d\'intégration');
  }


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


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


  /** @test */
  public function linkToDeleteRecordTotShouldBePresent() {
    $this->assertXPath('//a[@href = "/cosmo/integration/waiting-files-delete?id=%2Fccpl34%2Flunel%2F20190116220001_records_tot.mrc"]');
  }


  /** @test */
  public function linkToDownloadRecordTotShouldBePresent() {
    $this->assertXPath('//a[@href = "/cosmo/integration/waiting-files-download?id=%2Fccpl34%2Flunel%2F20190116220001_records_tot.mrc"]');
  }


  /** @test */
  public function kindsShouldBeProgrammed() {
    $this->assertXPathContentContains('//tr[@data-path="/ccpl34/etalon/genres.txt"]//td', 'Programmé');
  }
}



class Cosmo_IntegrationControllerWaitingFilesDeleteTest
  extends Cosmo_IntegrationControllerWaitingFilesTestCase {

  public function setUp() {
    parent::setUp();
    $this->dispatch('/cosmo/integration/waiting-files-delete?id=%2Fccpl34%2Flunel%2F20190116220001_records_tot.mrc');
  }


  /** @test */
  public function recordsTotShouldBeDeleted() {
    $this->assertTrue(Class_FileManager::getFileSystem()->methodHasBeenCalled('delete'));
  }
}



class Cosmo_IntegrationControllerWaitingFilesDownloadTest
  extends Cosmo_IntegrationControllerWaitingFilesTestCase {

  /** @test */
  public function totShouldBeRead() {
    $this->dispatch('/cosmo/integration/waiting-files-download?id=%2Fccpl34%2Flunel%2F20190116220001_records_tot.mrc');
    $this->assertTrue($this->_tot->methodHasBeenCalled('readfile'));
  }