/** * Destroy the testing environment. */ public function tearDown() { Bundle::$started = array(); Bundle::$routed = array(); Router::$names = array(); Router::$routes = array(); }
function overrideHTMLki($path, $overrides) { $override = function () use($path, $overrides) { $overrides = arrize($overrides, 'ns'); if (!empty($overrides['ns'])) { $overrides += array('compiledHeader' => "<?namespace {$overrides['ns']}?>\n", 'evalPrefix' => "namespace {$overrides['ns']};\n"); } \overrideHTMLki($path, $overrides); }; if (\Bundle::started('htmlki')) { $override(); } else { \Event::listen('laravel.started: htmlki', $override); } }
/** * Load the file corresponding to a given class. * * This method is registerd in the bootstrap file as an SPL auto-loader. * * @param string $class * @return void */ public static function load($class) { // First, we will check to see if the class has been aliased. If it has, // we will register the alias, which may cause the auto-loader to be // called again for the "real" class name. if (isset(static::$aliases[$class])) { class_alias(static::$aliases[$class], $class); } elseif (isset(static::$mappings[$class])) { require static::$mappings[$class]; } // If the class namespace is mapped to a directory, we will load the // class using the PSR-0 standards from that directory; however, we // will trim off the beginning of the namespace to account for // the root of the mapped directory. if (!is_null($info = static::namespaced($class))) { $class = substr($class, strlen($info['namespace'])); return static::load_psr($class, $info['directory']); } elseif (($slash = strpos($class, '\\')) !== false) { $namespace = substr($class, 0, $slash); // If the class is namespaced to an existing bundle and the bundle has // not been started, we will start the bundle and attempt to load the // class file again. If that fails, an error will be thrown by PHP. // // This allows bundle classes to be loaded by the auto-loader before // their class mappings have actually been registered; however, it // is up to the bundle developer to namespace their classes to // match the name of their bundle. if (Bundle::exists($namespace) and !Bundle::started($namespace)) { Bundle::start(strtolower($namespace)); static::load($class); } } // If the class is not maped and is not part of a bundle or a mapped // namespace, we'll make a last ditch effort to load the class via // the PSR-0 from one of the registered directories. static::load_psr($class); }
/** * Test if the activated bundle above is started. * * @return null */ public function testStartActivated() { $this->assertFalse(count(iBundle::register()) <= 0); $this->assertTrue(Bundle::started('docs')); }
/** * Test the Bundle::started method. * * @group laravel */ public function testStartedMethodIndicatesIfBundleIsStarted() { Bundle::register('dummy'); Bundle::start('dummy'); $this->assertTrue(Bundle::started('dummy')); }