Example #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);
     }
 }
Example #2
0
 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);
     }
     // Reset autoloader instance so it doesn't affect other tests
     Autoloader::resetInstance();
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 public function tearDown()
 {
     \Zend\Db\Table\AbstractTable::setDefaultMetadataCache();
     // Restore original autoloaders
     $loaders = spl_autoload_functions();
     foreach ($loaders as $loader) {
         spl_autoload_unregister($loader);
     }
     foreach ($this->loaders as $loader) {
         spl_autoload_register($loader);
     }
     // Reset autoloader instance so it doesn't affect other tests
     Autoloader::resetInstance();
 }
Example #5
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);
     }
 }
 public function tearDown()
 {
     if (!$this->isEnabled()) {
         return;
     }
     // 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();
 }
Example #7
0
 public function tearDown()
 {
     if ($this->errorHandler !== null) {
         restore_error_handler();
     }
     // Restore original autoloaders
     $loaders = spl_autoload_functions();
     if (is_array($loaders)) {
         foreach ($loaders as $loader) {
             spl_autoload_unregister($loader);
         }
     }
     if (is_array($this->loaders)) {
         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();
 }
Example #8
0
    /**
     * Setup mail transport
     * 
     * @param  array $options 
     * @return void
     */
    protected function _setupTransport(array $options)
    {
    	if(!isset($options['type'])) {
    		$options['type'] = 'sendmail';
    	}
    	
        $transportName = $options['type'];
        if(!Loader\Autoloader::autoload($transportName)) {
            $transportName = ucfirst(strtolower($transportName));

            if(!Loader\Autoloader::autoload($transportName)) {
                $transportName = 'Zend\\Mail\\Transport\\' . $transportName;
                if(!Loader\Autoloader::autoload($transportName)) {
                    throw new Exception\InitializationException(
                        "Specified Mail Transport '{$transportName}'"
                        . 'could not be found'
                    );
                }
            }
        }
        
        unset($options['type']);
        
        switch($transportName) {
            case 'Zend\\Mail\\Transport\\Smtp':
                if(!isset($options['host'])) {
                    throw new Exception\InitializationException(
                        'A host is necessary for smtp transport,'
                        .' but none was given');
                }
                
                $transport = new $transportName($options['host'], $options);
                break;
            case 'Zend\\Mail\\Transport\\Sendmail':
            default:
                $transport = new $transportName($options);
                break;
        }

        return $transport;
    }
Example #9
0
 public function testAutoloadShouldReturnTrueIfAutoloaderImplementationReturnsNonFalseValue()
 {
     $this->autoloader->pushAutoloader(new TestAutoloader());
     $this->assertTrue(ZendAutoloader::autoload('ZendLoaderAutoloader_Foo_Bar'));
 }
Example #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;
}
Example #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);
 }