Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use composer autoloader

  • Loading branch information...
commit 0b02b0333be707c1b3a03de9e29401cba98fe32d 1 parent 7a75f2f
Romain Pouclet authored
View
34 lib/Github/Autoloader.php
@@ -1,34 +0,0 @@
-<?php
-
-/**
- * Autoloads Github classes
- */
-class Github_Autoloader
-{
- /**
- * Registers Github_Autoloader as an SPL autoloader.
- */
- static public function register()
- {
- ini_set('unserialize_callback_func', 'spl_autoload_call');
- spl_autoload_register(array(new self, 'autoload'));
- }
-
- /**
- * Handles autoloading of classes.
- *
- * @param string $class A class name.
- *
- * @return boolean Returns true if the class has been loaded
- */
- static public function autoload($class)
- {
- if (0 !== strpos($class, 'Github')) {
- return;
- }
-
- if (file_exists($file = dirname(__FILE__).'/../'.str_replace('_', '/', $class).'.php')) {
- require $file;
- }
- }
-}
View
12 test/Github/Tests/AutoloaderTest.php
@@ -1,12 +0,0 @@
-<?php
-
-class Github_Tests_AutoloaderTest extends PHPUnit_Framework_TestCase
-{
- public function testAutoload()
- {
- $this->assertFalse(class_exists('FooBarFoo'), '->autoload() does not try to load classes that does not begin with Github');
-
- $autoloader = new Github_Autoloader();
- $this->assertNull($autoloader->autoload('Foo'), '->autoload() returns false if it is not able to load a class');
- }
-}
View
8 test/bootstrap.php
@@ -1,5 +1,7 @@
<?php
-require_once dirname(__FILE__).'/../test/Github/Tests/ApiTest.php';
-require_once dirname(__FILE__).'/../lib/Github/Autoloader.php';
-Github_Autoloader::register();
+$loader = require_once __DIR__.'/../vendor/.composer/autoload.php';
+$loader->add('Github_', __DIR__.'/../lib');
+$loader->add('Github_', __DIR__.'/../test');
+
+return $loader;
Please sign in to comment.
Something went wrong with that request. Please try again.