Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed PEAR2 prefix requirement, added test cases and generated clas…
…smap capability.
- Loading branch information
Clay Loveless
committed
Jun 25, 2011
1 parent
275c162
commit 38078df
Showing
11 changed files
with
2,705 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,4 @@ | |||
;; maintainers of Autoload | ;; maintainers of Autoload | ||
Gregory Beaver [cellog] <cellog@php.net> (lead) | Gregory Beaver [cellog] <cellog@php.net> (lead) | ||
Brett Bieber [saltybeagle] <saltybeagle@php.net> (lead) | Brett Bieber [saltybeagle] <saltybeagle@php.net> (lead) | ||
Clay Loveless [clay] <clay@php.net> (contributor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
- Add optional dynamically-generated class map so full file paths can be | |||
used when loading class files. | |||
|
|||
- Added a few test cases, along with non-Pyrus .phpt runner to keep us from | |||
trying to load PEAR2\Autoload twice! | |||
|
|||
- Removed PEAR2\ prefix requirement for loaded classes. Now psr-0 compliant. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
#!/bin/bash | |||
|
|||
# | |||
# We need to run these tests outside of pyrus runtime to keep existing | |||
# PEAR2\Autoload from preventing this file from loading | |||
# | |||
|
|||
export NO_INTERACTION=1 | |||
/usr/bin/env php tests/run-tests.php.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
<?php | |||
namespace testDir1; | |||
class Foo | |||
{ | |||
public static function sayHello() | |||
{ | |||
return "class testDir1\Foo says hi\n"; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,10 @@ | |||
--TEST-- | |||
Test PEAR2\Autoload initalization | |||
--FILE-- | |||
<?php | |||
require __DIR__ . '/../src/PEAR2/Autoload.php'; | |||
$paths = PEAR2\Autoload::getPaths(); | |||
echo sizeof($paths); | |||
?> | |||
--EXPECT-- | |||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
--TEST-- | |||
Test PEAR2\Autoload initalization w/2nd path | |||
--FILE-- | |||
<?php | |||
require __DIR__ . '/../src/PEAR2/Autoload.php'; | |||
PEAR2\Autoload::initialize(__DIR__.'/_files'); | |||
$paths = PEAR2\Autoload::getPaths(); | |||
echo sizeof($paths); | |||
?> | |||
--EXPECT-- | |||
2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
--TEST-- | |||
Test PEAR2\Autoload initalization w/2nd path AND loading class. | |||
--FILE-- | |||
<?php | |||
require __DIR__ . '/../src/PEAR2/Autoload.php'; | |||
PEAR2\Autoload::initialize(__DIR__.'/_files'); | |||
echo testDir1\Foo::sayHello(); | |||
|
|||
?> | |||
--EXPECT-- | |||
class testDir1\Foo says hi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,25 @@ | |||
--TEST-- | |||
Test PEAR2\Autoload initalization w/2nd path, loading class & writing map. | |||
--FILE-- | |||
<?php | |||
require __DIR__ . '/../src/PEAR2/Autoload.php'; | |||
PEAR2\Autoload::initialize(__DIR__.'/_files', __DIR__.'/_files/_files_map.php.inc'); | |||
echo testDir1\Foo::sayHello(); | |||
|
|||
$map = include __DIR__.'/_files/_files_map.php.inc'; | |||
if (isset($map['testDir1\\Foo'])) { | |||
echo "class mapped\n"; | |||
} else { | |||
echo "class not mapped\n"; | |||
} | |||
|
|||
?> | |||
--EXPECT-- | |||
class testDir1\Foo says hi | |||
class mapped | |||
|
|||
--CLEAN-- | |||
<?php | |||
// comment this out if you want to review the generated file map! | |||
unlink(__DIR__.'/_files/_files_map.php.inc'); | |||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,10 @@ | |||
--TEST-- | |||
Test PEAR2\Autoload initalization w/2nd path AND FAIL loading non-existent class. | |||
--FILE-- | |||
<?php | |||
require __DIR__ . '/../src/PEAR2/Autoload.php'; | |||
PEAR2\Autoload::initialize(__DIR__.'/_files'); | |||
echo testDir1\UnknownClass::sayHello(); | |||
?> | |||
--EXPECTREGEX-- | |||
^Fatal error.* |
Oops, something went wrong.