Skip to content
Snippets Groups Projects
Commit b95f14f1 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

rel #14869 : location screen under tests, cosmozend tests bootstrap fixed

parent 26544d7c
Branches
Tags
4 merge requests!310Master,!301Master,!300Hotline 6.47,!291Hotline#14869 Location Rule Forbid Value Equals Zero
......@@ -37,9 +37,6 @@ Zend_Layout::getMvcInstance()
->getView()
->addHelperPath('ZendAfi/View/Helper', 'ZendAfi_View_Helper');
Zend_Controller_Action_HelperBroker::addPath('ZendAfi/Controller/Action/Helper',
'ZendAfi_Controller_Action_Helper');
$front = Zend_Controller_Front::getInstance()
->throwExceptions(true)
->addModuleDirectory($cosmozendPath . '/application/modules')
......
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
abstract class CosmoControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase {
use Storm_Test_THelpers;
public $bootstrap = 'bootstrap_frontcontroller.php';
public function setUp() {
parent::setUp();
Storm_Model_Abstract::unsetLoaders();
Storm_Cache::setDefaultZendCache(null);
}
public function tearDown() {
Storm_Model_Abstract::unsetLoaders();
}
public function postDispatch($url, $data) {
$this->getRequest()
->setMethod('POST')
->setPost($data);
return $this->dispatch($url, true);
}
public function dispatch($url = null, $throw_exceptions = false) {
// redirector should not exit
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->setExit(false);
// json helper should not exit
$json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$json->suppressExit = true;
$request = $this->getRequest();
if (null !== $url) {
$request->setRequestUri($url);
}
$request->setPathInfo(null);
$this->frontController
->setRequest($request)
->setResponse($this->getResponse())
->throwExceptions($throw_exceptions)
->returnResponse(false);
$this->frontController->dispatch();
}
}
?>
\ No newline at end of file
<?PHP
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
......@@ -19,10 +19,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class AuthControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase {
public $bootstrap = 'bootstrap.php';
class AuthControllerTestCase extends CosmoControllerTestCase {
public function setup() {
parent::setup();
$this->dispatch('cosmo/auth/index', true);
......
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
abstract class Cosmo_EmplacementControllerTestCase extends CosmoControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_CodifEmplacement', [
'id' => 18,
'libelle' => 'Albums',
'regles' => '995$x=55',
'ne_pas_afficher' => 0,
]);
}
}
class Cosmo_EmplacementControllerIndexTest extends Cosmo_EmplacementControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/cosmo/emplacement/index', true);
}
/** @test */
public function titleShouldBePresent() {
$this->assertXpathContentContains('//h1', 'Codification des emplacements');
}
/** @test */
public function addButtonShouldBePresent() {
$this->assertXpath('//input[contains(@onclick, "/cosmo/emplacement/add")]');
}
/** @test */
public function albumsFormShouldBePresent() {
$this->assertXpath('//form[contains(@action, "/cosmo/emplacement/validate/id/18")]');
}
/** @test */
public function albumsLabelShouldBePresent() {
$this->assertXpath('//input[@name="libelle"][@value="Albums"]');
}
/** @test */
public function albumsRulesShouldBePresent() {
$this->assertXpathContentContains('//textarea[@name="regles"]', '995$x=55');
}
/** @test */
public function albumsDisplayShouldBePresent() {
$this->assertXpathContentContains(
'//select[@name="ne_pas_afficher"]/option[@selected="selected"]',
'Afficher les exemplaires');
}
/** @test */
public function albumsDeleteButtonShouldBePresent() {
$this->assertXpath('//input[contains(@onclick, "/cosmo/emplacement/delete/id/18")]');
}
}
class Cosmo_EmplacementControllerAlbumsValidatePostTest extends Cosmo_EmplacementControllerTestCase {
public function setUp() {
parent::setUp();
$this->postDispatch(
'/cosmo/emplacement/validate/id/18',
[
'libelle' => 'Alboums',
'regles' => '995$x=07',
'ne_pas_afficher' => 1]);
$this->model = Class_CodifEmplacement::find(18);
}
/** @test */
public function labelShouldBeAlboums() {
$this->assertEquals('Alboums', $this->model->getLibelle());
}
/** @test */
public function rulesShouldBeDollarXEqualsZeroSeven() {
$this->assertEquals('995$x=07', $this->model->getRegles());
}
/** @test */
public function displayHideShouldBeHide() {
$this->assertEquals(1, $this->model->getNePasAfficher());
}
}
class Cosmo_EmplacementControllerAddTest extends Cosmo_EmplacementControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/cosmo/emplacement/add', true);
}
/** @test */
public function titleShouldBePresent() {
$this->assertXpathContentContains('//h1', 'Codification des emplacements');
}
/** @test */
public function formActionShouldGoToValidate() {
$this->assertXpath('//form[contains(@action, "/cosmo/emplacement/validate")]');
}
/** @test */
public function labelShouldDefaultToNouvelEmplacement() {
$this->assertXpath('//input[@name="libelle"][@value="** nouvel emplacement **"]');
}
/** @test */
public function rulesShouldDefault995DollarKSlashR() {
$this->assertXpathContentContains('//textarea[@name="regles"]', '995$k/R');
}
/** @test */
public function albumsDisplayShouldBePresent() {
$this->assertXpathContentContains(
'//select[@name="ne_pas_afficher"]/option[@selected="selected"]',
'Afficher les exemplaires');
}
/** @test */
public function backButtonShouldBePresent() {
$this->assertXpath('//input[@value="Retour"][contains(@onclick, "/cosmo/emplacement")]');
}
}
class Cosmo_EmplacementControllerAddPostTest extends Cosmo_EmplacementControllerTestCase {
public function setUp() {
parent::setUp();
$this->postDispatch(
'/cosmo/emplacement/validate',
[
'libelle' => 'Atlantis',
'regles' => '999$y/Arcadia',
'ne_pas_afficher' => 0]);
$this->model = Class_CodifEmplacement::find(19);
}
/** @test */
public function atlantisShouldBeSaved() {
$this->assertNotNull($this->model);
}
/** @test */
public function labelShouldBeAtlantis() {
$this->assertEquals('Atlantis', $this->model->getLibelle());
}
/** @test */
public function rulesShouldBe999DollarYSlashArcadia() {
$this->assertEquals('999$y/Arcadia', $this->model->getRegles());
}
/** @test */
public function displayHideShouldBeShow() {
$this->assertEquals(0, $this->model->getNePasAfficher());
}
}
class Cosmo_EmplacementControllerAlbumsValidatePostWithErrorsTest extends Cosmo_EmplacementControllerTestCase {
public function setUp() {
parent::setUp();
$this->postDispatch(
'/cosmo/emplacement/validate/id/18',
[
'libelle' => '',
'regles' => '9#95$x=07',
'ne_pas_afficher' => 1]);
$this->model = Class_CodifEmplacement::find(18);
}
public function errorsProvider() {
return [
['Vous devez définir le libellé'],
['Le $ est absent ou mal positionné pour la règle 9#95$x=07'],
['Le champ n\'est pas compris entre a et z ni entre 0 et 9'],
['Signe de comparaison incorrect']];
}
/**
* @test
* @dataProvider errorsProvider
*/
public function errorShouldBePresent($message) {
$this->assertXpathContentContains('//li', $message, $this->_response->getBody());
}
/** @test */
public function labelShouldNotBeSaved() {
$this->assertTrue($this->model->hasChangedAttribute('libelle'));
}
/** @test */
public function rulesShouldNotBeSaved() {
$this->assertTrue($this->model->hasChangedAttribute('regles'));
}
}
\ No newline at end of file
......@@ -18,42 +18,31 @@
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
chdir(realpath(dirname(__FILE__)) . '/../');
error_reporting(E_ALL^E_DEPRECATED);
$cosmozendPath = realpath(dirname(__FILE__)) . '/../';
chdir($cosmozendPath);
error_reporting(E_ALL^E_DEPRECATED^E_NOTICE);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
ini_set('memory_limit', '3072M');
date_default_timezone_set('Europe/Paris');
$basePath = realpath(dirname(__FILE__));
require_once $cosmozendPath . '/../php/classes/classe_cosmopaths.php';
require_once $cosmozendPath . '/../storm_init.php';
set_include_path( $basePath . '/../library'
. PATH_SEPARATOR . $basePath
. PATH_SEPARATOR . $basePath . '/../../../../ZendFramework-1.6.2/library'
. PATH_SEPARATOR . $basePath . '/../application'
. PATH_SEPARATOR . $basePath . '/application'
. PATH_SEPARATOR . $basePath . '/library'
set_include_path( $cosmozendPath
. PATH_SEPARATOR . $cosmozendPath . '/tests'
. PATH_SEPARATOR . $cosmozendPath . '/application'
. PATH_SEPARATOR . $cosmozendPath . '/library'
. PATH_SEPARATOR . get_include_path());
// boostrap ZF
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
Zend_Session::start();
Zend_Layout::startMvc();
Zend_Layout::getMvcInstance()
->getView()
->addHelperPath('ZendAfi/View/Helper', 'ZendAfi_View_Helper');
Zend_Controller_Action_HelperBroker::addPath('ZendAfi/Controller/Action/Helper',
'ZendAfi_Controller_Action_Helper');
$front = Zend_Controller_Front::getInstance()
->throwExceptions(true)
->addModuleDirectory($basePath . '/../application/modules')
->setDefaultModule('opac');
$_SERVER['SERVER_NAME'] = 'localhost';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
require_once 'CosmoControllerTestCase.php';
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
Zend_Layout::startMvc();
Zend_Layout::getMvcInstance()->getView()
->addHelperPath('ZendAfi/View/Helper', 'ZendAfi_View_Helper');
Zend_Controller_Front::getInstance()
->throwExceptions(true)
->addModuleDirectory(realpath(dirname(__FILE__)) . '/../application/modules')
->setDefaultModule('opac')
->registerPlugin(new ZendAfi_Controller_Plugin_CosmoAuth());
$_SESSION['passe'] = 'sysadm';
?>
\ No newline at end of file
......@@ -47,7 +47,7 @@ class Class_CodifEmplacement extends Storm_Model_Abstract {
$champ = substr($regle, 4, 1);
$this->check(
preg_match('/^[a-z0-9]$/', $champ),
'Le champ n\'est pas compris en a et z ni entre 0 et 9 pour la règle ' . $regle);
'Le champ n\'est pas compris entre a et z ni entre 0 et 9 pour la règle ' . $regle);
$valeurs = substr($regle, 6);
$this->check(
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment