Author: Phergie Development Team (team@phergie.org)
Esempio n. 1
0
<?php

/**
 * Phergie
 *
 * PHP version 5
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.
 * It is also available through the world-wide-web at this URL:
 * http://phergie.org/license
 *
 * @category  Phergie
 * @package   Phergie_Tests
 * @author    Phergie Development Team <*****@*****.**>
 * @copyright 2008-2011 Phergie Development Team (http://phergie.org)
 * @license   http://phergie.org/license New BSD License
 * @link      http://pear.phergie.org/package/Phergie_Tests
 */
error_reporting(E_ALL | E_STRICT);
// Phergie components require Phergie_Autoload to function correctly.
require_once dirname(__FILE__) . '/../Phergie/Autoload.php';
Phergie_Autoload::registerAutoloader();
Esempio n. 2
0
 /**
  * Tests that the autoloader strips off prefixes given to addPath() from class names before trying to find their
  * corresponding files. If it fails to do that, the class in this test shouldn't be loaded.
  *
  * @return void
  */
 public function testRemovesPrefixFromClassFileName()
 {
     // Fake environment and register autoloader
     $path = dirname(__FILE__) . '/Autoload/_PrefixRemovedFromClassFileNameTest';
     Phergie_Autoload::registerAutoloader();
     Phergie_Autoload::addPath($path, 'Phergie_Prefixed_');
     $this->assertTrue(class_exists('Phergie_Prefixed_Class', true));
 }
Esempio n. 3
0
 /**
  * Constructor to initialize class properties and add the path for core
  * plugins.
  *
  * @param Phergie_Config        $config configuration to pass to any
  *        instantiated plugin
  * @param Phergie_Event_Handler $events event handler to pass to any
  *        instantiated plugin
  *
  * @return void
  */
 public function __construct(Phergie_Config $config, Phergie_Event_Handler $events)
 {
     $this->config = $config;
     $this->events = $events;
     $this->plugins = array();
     $this->paths = array();
     $this->autoload = false;
     if (!empty($config['plugins.paths'])) {
         foreach ($config['plugins.paths'] as $dir => $prefix) {
             $this->addPath($dir, $prefix);
             Phergie_Autoload::addPath($dir, $prefix);
         }
     }
     $this->addPath(dirname(__FILE__), 'Phergie_Plugin_');
 }
Esempio n. 4
0
 /**
  * Tests that the autoloader can add a path to the include path.
  *
  * @return void
  */
 public function testAddPath()
 {
     $path = dirname(__FILE__);
     Phergie_Autoload::addPath($path);
     $paths = explode(PATH_SEPARATOR, get_include_path());
     $this->assertContains($path, $paths);
 }
Esempio n. 5
0
 /**
  * Tests that expects an error if an expected class wasn't found in a file
  *
  * @return void
  */
 public function testClassNotInFile()
 {
     // Fake environment and register autoloader
     $path = dirname(__FILE__) . '/Autoload/_ClassNotInFileTest';
     set_include_path($path . PATH_SEPARATOR . get_include_path());
     Phergie_Autoload::registerAutoloader();
     try {
         class_exists('Phergie_Missing_Class', true);
         $this->fail('Expected exception not throwen');
     } catch (Phergie_Exception $e) {
         $this->assertEquals('Expected class Phergie_Missing_Class in ' . $path . '/Phergie/Missing/Class.php not found', $e->getMessage());
     }
 }