Exemple #1
0
 public function __construct($options = array())
 {
     // require autoloader
     \Zend\Loader\Autoloader::getInstance();
     // this might look goofy, but this is setting up the
     // registry for dependency injection into the client
     $registry = new \Zend\Tool\Framework\Registry\FrameworkRegistry();
     $registry->setClient($this);
     // NOTE: at this moment, $this->_registry should contain the registry object
     if ($options) {
         $this->setOptions($options);
     }
 }
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     if (file_exists($this->_includeCache)) {
         unlink($this->_includeCache);
     }
     // Possible for previous tests to remove autoloader
     Autoloader::resetInstance();
     $al = Autoloader::getInstance();
     $al->registerPrefix('PHPUnit_');
     PluginLoader::setIncludeFileCache(null);
     $this->_includeCache = __DIR__ . '/_files/includeCache.inc.php';
     $this->libPath = realpath(__DIR__ . '/../../../library');
     $this->key = null;
 }
 public function setUp()
 {
     // Store original autoloaders
     $this->loaders = spl_autoload_functions();
     if (!is_array($this->loaders)) {
         // spl_autoload_functions does not return empty array when no
         // autoloaders registered...
         $this->loaders = array();
     }
     Autoloader::resetInstance();
     $this->autoloader = Autoloader::getInstance();
     $this->application = new Application('testing');
     $this->bootstrap = new ZfAppBootstrap($this->application);
 }
 public function setUp()
 {
     // Store original autoloaders
     $this->loaders = spl_autoload_functions();
     if (!is_array($this->loaders)) {
         // spl_autoload_functions does not return empty array when no
         // autoloaders registered...
         $this->loaders = array();
     }
     Autoloader::resetInstance();
     $this->autoloader = Autoloader::getInstance();
     $this->autoloader->unshiftAutoloader('ZendTest_Autoloader', 'ZendTest');
     $this->application = new Application\Application('testing');
     $this->error = false;
 }
 public function tearDown()
 {
     // Restore original autoloaders
     $loaders = spl_autoload_functions();
     foreach ($loaders as $loader) {
         spl_autoload_unregister($loader);
     }
     foreach ($this->loaders as $loader) {
         spl_autoload_register($loader);
     }
     // Retore original include_path
     set_include_path($this->includePath);
     // Reset autoloader instance so it doesn't affect other tests
     Autoloader::resetInstance();
     Autoloader::getInstance();
 }
Exemple #6
0
 public function setUp()
 {
     // Store original autoloaders
     $this->loaders = spl_autoload_functions();
     if (!is_array($this->loaders)) {
         // spl_autoload_functions does not return empty array when no
         // autoloaders registered...
         $this->loaders = array();
     }
     // Store original include_path
     $this->includePath = get_include_path();
     Autoloader::resetInstance();
     $this->autoloader = Autoloader::getInstance();
     $this->application = new Application\Application('testing');
     $this->iniOptions = array();
 }
Exemple #7
0
 /**
  * Constructor
  *
  * Initialize application. Potentially initializes include_paths, PHP
  * settings, and bootstrap class.
  *
  * @param  string                   $environment
  * @param  string|array|\Zend\Config\Config $options String path to configuration file, or array/\Zend\Config\Config of configuration options
  * @throws \Zend\Application\Exception When invalid options are provided
  * @return void
  */
 public function __construct($environment, $options = null)
 {
     $this->_environment = (string) $environment;
     require_once 'Zend/Loader/Autoloader.php';
     $this->_autoloader = \Zend\Loader\Autoloader::getInstance();
     if (null !== $options) {
         if (is_string($options)) {
             $options = $this->_loadConfig($options);
         } elseif ($options instanceof \Zend\Config\Config) {
             $options = $options->toArray();
         } elseif (!is_array($options)) {
             throw new Exception('Invalid options provided; must be location of config file, a config object, or an array');
         }
         $this->setOptions($options);
     }
 }
Exemple #8
0
 public function setUp()
 {
     // Store original autoloaders
     $this->loaders = spl_autoload_functions();
     if (!is_array($this->loaders)) {
         // spl_autoload_functions does not return empty array when no
         // autoloaders registered...
         $this->loaders = array();
     }
     // Store original include_path
     $this->includePath = get_include_path();
     Autoloader::resetInstance();
     $this->autoloader = Autoloader::getInstance();
     // initialize 'error' member for tests that utilize error handling
     $this->error = null;
     $this->loader = new ModuleAutoloader(array('namespace' => 'FooBar', 'basePath' => realpath(__DIR__ . '/_files')));
 }
Exemple #9
0
 public function testSingletonInstanceShouldAllowReset()
 {
     ZendAutoloader::resetInstance();
     $autoloader = ZendAutoloader::getInstance();
     $this->assertNotSame($this->autoloader, $autoloader);
 }
Exemple #10
0
<?php

// Set used namespaces
use Zend\Loader\Autoloader;
use Zend\Locale\Locale;
use Zend\Registry;
use Zend\Service\LiveDocx\Helper;
// Turn up error reporting
error_reporting(E_ALL | E_STRICT);
// Set path to libraries
set_include_path(__DIR__ . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR . dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'library');
// Set autoloader to autoload libraries
require_once 'Zend/Loader/Autoloader.php';
Autoloader::getInstance();
// Set default locale
Locale::setDefault(Helper::LOCALE);
$locale = new Locale(Locale::ZFDEFAULT);
Registry::set('Zend_Locale', $locale);
// Ensure LiveDocx credentials are available
if (false === Helper::credentialsAvailable()) {
    Helper::printLine(Helper::credentialsHowTo());
    exit;
}
Exemple #11
0
 /**
  * @group ZF-7473
  */
 public function testAutoloaderShouldReceiveNamespaceWithTrailingUnderscore()
 {
     $this->loader = new ResourceAutoloader(array('prefix' => 'FooBar', 'basePath' => realpath(__DIR__ . '/_files/ResourceAutoloader')));
     $al = Autoloader::getInstance();
     $loaders = $al->getPrefixAutoloaders('FooBar');
     $this->assertTrue(empty($loaders));
     $loaders = $al->getPrefixAutoloaders('FooBar_');
     $this->assertFalse(empty($loaders));
     $loader = array_shift($loaders);
     $this->assertSame($this->loader, $loader);
 }