Bootstrapping Zend_Application avec Zend_Test
-
26-09-2019 - |
Question
dans la documentation du code fourni pour bootstrapping ressemble
protected $application;
public function setUp() {
$this->bootstrap = array($this, 'appBootstrap');
parent::setUp();
}
public function appBootstrap() {
$this->application = new Zend_Application( ... );
$this->application->bootstrap();
}
Je suis curieux de savoir pourquoi quand j'ai essayé
protected $application;
public function setUp() {
$this->application = new Zend_Application( ... );
$this->application->bootstrap();
parent::setUp();
}
il a échoué. aussi quand je l'ai essayé de déplacer bootstrapping application dans bootstrap.php il échoue aussi
// bootstrap.php
...
$application = new Zend_Application( ... );
$application->bootstrap();
la raison pour laquelle je pensais de passer à ce bootstrap.php est jon Lebensold à partir de moulages zend a prolongé la ControllerTestCase pour gérer tout cela bootstrapping dans une catégorie distincte. je pensais au lieu d'étendre la classe, si je peux déplacer le code dans le bootstrap.php en 1 place Wont mieux
La solution
est ce que mon ControllerTestCase.php ressemble à:
<?php
abstract class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{
public function setUp()
{
$this->bootstrap = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
parent::setUp();
}
}
TestHelper.php (Bootstrap)
<?php
define('BASE_PATH', realpath(dirname(__FILE__) . '/../public'));
define('APPLICATION_PATH', realpath(BASE_PATH . '/../application'));
set_include_path(implode(PATH_SEPARATOR, array(
'.',
realpath(APPLICATION_PATH . '/../library'),
get_include_path()
)));
define('APPLICATION_ENV', 'testing');
require_once "Zend/Loader/Autoloader.php";
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
$loader->suppressNotFoundWarnings(false);
require_once 'ControllerTestCase.php';
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow