diff --git a/tests/PluginTestCase.php b/tests/PluginTestCase.php index 581780869..0a25dd2ec 100644 --- a/tests/PluginTestCase.php +++ b/tests/PluginTestCase.php @@ -151,6 +151,21 @@ abstract class PluginTestCase extends Illuminate\Foundation\Testing\TestCase Artisan::call('plugin:refresh', ['name' => $code]); } + /** + * Returns a plugin object from its code, useful for registering events, etc. + * @return PluginBase + */ + protected function getPluginObject($code = null) + { + if ($code === null) { + $code = $this->guessPluginCodeFromTest(); + } + + if (isset($this->pluginTestCaseLoadedPlugins[$code])) { + return $this->pluginTestCaseLoadedPlugins[$code]; + } + } + /** * The models in October use a static property to store their events, these * will need to be targeted and reset ready for a new test cycle. @@ -198,4 +213,4 @@ abstract class PluginTestCase extends Illuminate\Foundation\Testing\TestCase return $result; } -} \ No newline at end of file +}