-
Ghislain Loas authoredbc9baad2
AnnexeControllerTest.php 6.03 KiB
<?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
*/
abstract class AnnexeControllerTestCase extends CosmoControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_Bib',
['id' => 56,
'libelle' => 'Médiathèque Annecy']);
$this->fixture('Class_IntBib',
['id' => 56,
'nom_court' => 'Médiathèque Annecy']);
$this->fixture('Class_Bib',
['id' => 9999854,
'libelle' => 'Bibliothèque de Cran-Gevrier']);
$this->fixture('Class_IntBib',
['id' => 9999854,
'nom_court' => 'Bibliothèque de Cran-Gevrier']);
$this->fixture('Class_CodifAnnexe',
['id' => 98,
'libelle' => 'Annexe Annecy',
'code' => 'ACY01',
'id_origine' => 'ACY-01',
'id_bib' => 56]);
$this->fixture('Class_CodifAnnexe',
['id' => 120,
'libelle' => 'Annex lost',
'code' => 'P01',
'id_origine' => 'P01',
'id_bib' => 666]);
}
}
class AnnexeControllerIndexTest extends AnnexeControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/cosmo/annexe', true);
}
/** @test */
public function annexeAnnecyShouldBeInTable() {
$this->assertXPathContentContains('//table//td', 'Annexe Annecy');
}
/** @test */
public function lostAnnexShouldBeInTable() {
$this->assertXPathContentContains('//table//td', 'Annex lost');
}
/** @test */
public function annexeAnnecyIdOrigineShouldBeInTable() {
$this->assertXPathContentContains('//table//td', 'ACY-01');
}
/** @test */
public function annexeAnnecyCodeShouldBeInTable() {
$this->assertXPathContentContains('//table//td', 'ACY01');
}
/** @test */
public function editAnnexeAnnecyLinkShouldBeInTable() {
$this->assertXPath('//table//td//a[contains(@href, "/cosmo/annexe/edit/id/98")]');
}
/** @test */
public function deleteAnnexeAnnecyLinkShouldBeInTable() {
$this->assertXPath('//table//td//a[contains(@href, "/cosmo/annexe/delete/id/98")]');
}
/** @test */
public function addAnnexeLinkShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/cosmo/annexe/add")]');
}
}
class AnnexeControllerAddActionTest extends AnnexeControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/cosmo/annexe/add', true);
}
/** @test */
public function shouldContainsSelectWithMediathequeAnnecy() {
$this->assertXPath('//form//select[@name="id_bib"]//option[2][@value="56"]');
}
/** @test */
public function shouldContainsCode() {
$this->assertXPath('//form//input[@type="text"][@name="id_origine"]');
}
/** @test */
public function shouldContainsLibelle() {
$this->assertXPath('//form//input[@type="text"][@name="libelle"][@placeholder="** nouvelle annexe **"]');
}
/** @test */
public function checkboxRejectItemsShouldBePresent() {
$this->assertXPath('//form//input[@type="checkbox"][@name="invisible"]');
}
/** @test */
public function checkboxNoPickupShouldBePresent() {
$this->assertXPath('//form//input[@type="checkbox"][@name="no_pickup"]');
}
}
class AnnexeControllerEditActionTest extends AnnexeControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/cosmo/annexe/edit/id/98', true);
}
/** @test */
public function shouldContainsSelectWithMediathequeAnnecy() {
$this->assertXPath('//form//select[@name="id_bib"]//option[2][@value="56"][@selected]');
}
/** @test */
public function shouldContainsIdOrigineACYDash01() {
$this->assertXPath('//form//input[@name="id_origine"][@value="ACY-01"][@type="text"]');
}
}
class AnnexeControllerPostEditActionTest extends AnnexeControllerTestCase {
protected $_annecy;
public function setUp() {
parent::setUp();
$this->_annecy = Class_CodifAnnexe::find(98);
$this->postDispatch('/cosmo/annexe/edit/id/98',
['id_origine' => '+A"C" <Y>-0*~=1(0)@',
'libelle' => 'same libelle',
'id_bib' => '9999854']);
}
/** @test */
public function codifAnnexeLibraryShouldBeCran() {
$this->assertEquals('Bibliothèque de Cran-Gevrier', $this->_annecy->getLibraryLabel());
}
/** @test */
public function shouldRedirectToEdit() {
$this->assertRedirect();
$this->assertRedirectTo('/cosmo/annexe/edit/id/98');
}
/** @test */
public function codeShouldBeACY010() {
$this->assertEquals('ACY010', $this->_annecy->getCode());
}
/** @test */
public function idOrigineShouldBeComplicated() {
$this->assertEquals('+A"C" <Y>-0*~=1(0)@', $this->_annecy->getIdOrigine());
}
}
class AnnexeControllerDeleteActionTest extends AnnexeControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/cosmo/annexe/delete/id/98', true);
}
/** @test */
public function shouldDeleteIt() {
$this->assertNull(Class_CodifAnnexe::find(98));
}
/** @test */
public function shouldRedirectToIndex() {
$this->assertRedirectTo('/cosmo/annexe/index');
}
}
?>