From 0891e757d7a5c94ae4928ae2bf5bdc8136fb35a0 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Sat, 11 Jul 2015 16:19:38 +0200 Subject: [PATCH] First premier chapitre tests --- .../PremierChapitre/PremierChapitreTest.php | 102 ++++++++++++++++++ .../Class/PremierChapitre/liste_livres.xml | 35 ++++++ 2 files changed, 137 insertions(+) create mode 100644 tests/library/Class/PremierChapitre/PremierChapitreTest.php create mode 100644 tests/library/Class/PremierChapitre/liste_livres.xml diff --git a/tests/library/Class/PremierChapitre/PremierChapitreTest.php b/tests/library/Class/PremierChapitre/PremierChapitreTest.php new file mode 100644 index 00000000000..f78fd24dd3b --- /dev/null +++ b/tests/library/Class/PremierChapitre/PremierChapitreTest.php @@ -0,0 +1,102 @@ +<?php +/** + * Copyright (c) 2012, 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 + */ + + +/* Ex commande pour lancer phpunit: + * phpunit -c /chemin/absolu/vers/bokeh/tests/phpunit.xml --filter PremierChapitreWithFourBooksTest PremierChapitreWithFourBooksTest /chemin/absolu/vers/bokeh/tests/library/Class/PremierChapitre/PremierChapitreTest.php + */ +class PremierChapitreWithFourBooksTest extends ModelTestCase { + protected + $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $premier_chapitre = new Class_WebService_PremierChapitre(); + $premier_chapitre->updateDatabaseFromFile(__DIR__.'/liste_livres.xml'); + } + + + /** @test */ + public function numberOfPremierChapitreInstancesShouldBeFour() { + $this->assertCount(4, Class_PremierChapitre::findAll()); + } + + + /** @test */ + public function firstBookTitleShouldBeLaDeconnexionDesElites() { + $this->assertEquals('La déconnexion des élites - Comment Internet dérange l\'ordre établi', + Class_PremierChapitre::find(9782352043645)->getTitre()); + } +} + + + + +class PremierChapitreInactiveAdminControllerIndexTest extends Admin_AbstractControllerTestCase { + protected + $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + Class_AdminVar::set('PREMIERCHAPITRE_BIB_ID', ''); + $this->dispatch('/admin/premier-chapitre', true); + } + + + /** @test */ + public function h1ShouldContainsPremierChapitre() { + $this->assertXPathContentContains('//h1', + 'Premier Chapitre', + $this->_response->getBody()); + } + + + /** @test */ + public function divModulesShouldContainsServiceInactif() { + $this->assertXPathContentContains('//div[@class="modules"]', + 'Service inactif', + $this->_response->getBody()); + } +} + + + +class PremierChapitreActiveAdminControllerIndexTest extends Admin_AbstractControllerTestCase { + protected + $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + Class_AdminVar::set('PREMIERCHAPITRE_BIB_ID', '123'); + Class_AdminVar::set('PREMIERCHAPITRE_BMKEY', 'secret'); + Class_AdminVar::set('PREMIERCHAPITRE_BMID', '123'); + $this->dispatch('/admin/premier-chapitre', true); + } + + + /** @test */ + public function h1ShouldContainsPremierChapitreIndexDesFonctions() { + $this->assertXPathContentContains('//h1', + 'Premier Chapitre :: Index des fonctions', + $this->_response->getBody()); + } +} \ No newline at end of file diff --git a/tests/library/Class/PremierChapitre/liste_livres.xml b/tests/library/Class/PremierChapitre/liste_livres.xml new file mode 100644 index 00000000000..8cc26af19d7 --- /dev/null +++ b/tests/library/Class/PremierChapitre/liste_livres.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<premierchapitre> + <livre> + <ean>9782352043645</ean> + <titre>La déconnexion des élites - Comment Internet dérange l'ordre établi</titre> + <url_reader>http://www.premierchapitre.fr/book_reader/index.php?idk=23&idc=d3ee1956c15a614d44e58755af2b1f10</url_reader> + <url_couverture>http://www.moveandread.com/moveandread/multimedia/ebook/1435853131/c/1435853131.png</url_couverture> + <url_couverture_small>http://www.moveandread.com/moveandread/multimedia/ebook/1435853131/c/v/1435853131.png</url_couverture_small> + <auteur_nom>Laure Belot</auteur_nom> + </livre> + <livre> + <ean>9782501098779</ean> + <titre>Comment je suis devenu 10% plus heureux - La méditation pour les sceptiques</titre> + <url_reader>http://www.premierchapitre.fr/book_reader/index.php?idk=23&idc=bcc0c9000e24e091e3a34a98d295aeaf</url_reader> + <url_couverture>http://www.moveandread.com/moveandread/multimedia/ebook/1435848302/c/1435848302.png</url_couverture> + <url_couverture_small>http://www.moveandread.com/moveandread/multimedia/ebook/1435848302/c/v/1435848302.png</url_couverture_small> + <auteur_nom>Dan Harris</auteur_nom> + </livre> + <livre> + <ean>9782809808186</ean> + <titre>Dragon des brumes</titre> + <url_reader>http://www.premierchapitre.fr/book_reader/index.php?idk=23&idc=693952166c663641e5536da1c808ec98</url_reader> + <url_couverture>http://www.moveandread.com/moveandread/multimedia/ebook/1341509609/c/1343672172.png</url_couverture> + <url_couverture_small>http://www.moveandread.com/moveandread/multimedia/ebook/1341509609/c/v/1343672172.png</url_couverture_small> + <auteur_nom>Nicolas Cluzeau</auteur_nom> + </livre> + <livre> + <ean>9782809807769</ean> + <titre>Copycat</titre> + <url_reader>http://www.premierchapitre.fr/book_reader/index.php?idk=23&idc=d28360426420fdf1e613991f05367b07</url_reader> + <url_couverture>http://www.moveandread.com/moveandread/multimedia/ebook/1340887952/c/1401354389.png</url_couverture> + <url_couverture_small>http://www.moveandread.com/moveandread/multimedia/ebook/1340887952/c/v/1401354389.png</url_couverture_small> + <auteur_nom>James Patterson</auteur_nom> + </livre> +</premierchapitre> -- GitLab