-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #360 from nanasess/improve/plugin-loader
プラグインを任意のディレクトリに配置できるように修正
- Loading branch information
Showing
8 changed files
with
89 additions
and
11 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
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
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
11 changes: 11 additions & 0 deletions
11
tests/class/fixtures/plugin/FixturePlugin/FixturePlugin.php
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
class FixturePlugin extends SC_Plugin_Base | ||
{ | ||
public function loadClassFileChange(&$classname, &$classpath) { | ||
if ($classname === "SC_Customer_Ex") { | ||
$classpath = "FixturePlugin/Fixture_SC_Customer.php"; | ||
$classname = "Fixture_SC_Customer"; | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/class/fixtures/plugin/FixturePlugin/Fixture_SC_Customer.php
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
class Fixture_SC_Customer extends SC_Customer | ||
{ | ||
public function getValue($key) | ||
{ | ||
return $key; | ||
} | ||
} |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/** | ||
* @group classloader | ||
*/ | ||
class LoadClassFileChangeCustomDirTest extends Common_TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
$plugin_id = $this->objQuery->nextVal('dtb_plugin_plugin_id'); | ||
$pluginValues = [ | ||
'plugin_id' => $plugin_id, | ||
'plugin_name' => 'FixturePlugin', | ||
'plugin_code' => 'FixturePlugin', | ||
'class_name' => 'FixturePlugin', | ||
'plugin_version' => '0.0.0', | ||
'compliant_version' => '2.17', | ||
'enable' => 1, | ||
'create_date' => 'CURRENT_TIMESTAMP', | ||
'update_date' => 'CURRENT_TIMESTAMP' | ||
]; | ||
$this->objQuery->insert('dtb_plugin', $pluginValues); | ||
|
||
$plugin_hookpoint_id = $this->objQuery->nextVal('dtb_plugin_hookpoint_plugin_hookpoint_id'); | ||
$hookpointValues = [ | ||
'plugin_hookpoint_id' => $plugin_hookpoint_id, | ||
'plugin_id' => $plugin_id, | ||
'hook_point' => 'loadClassFileChange', | ||
'callback' => 'loadClassFileChange', | ||
'update_date' => 'CURRENT_TIMESTAMP' | ||
]; | ||
$this->objQuery->insert('dtb_plugin_hookpoint', $hookpointValues); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
* @preserveGlobalState disabled | ||
*/ | ||
public function testLOading() | ||
{ | ||
// __DIR__.'/../fixtures/plugin/ に配置したプラグインをオートロード対象にする | ||
spl_autoload_register(function ($class){ | ||
SC_ClassAutoloader_Ex::autoload($class, __DIR__.'/../fixtures/plugin/'); | ||
}, true, true); | ||
|
||
$objCustomer = new SC_Customer_Ex(); | ||
$this->assertInstanceOf('Fixture_SC_Customer', $objCustomer); | ||
$this->assertEquals('loading', $objCustomer->getValue('loading'), __DIR__.'/../fixtures/plugin/Fixture_SC_Customer がロードされる'); | ||
} | ||
} |
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