Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
change the method to support array only
  • Loading branch information
saeideng committed Jul 12, 2018
1 parent fbd8a17 commit f9d2db1
Show file tree
Hide file tree
Showing 41 changed files with 71 additions and 74 deletions.
7 changes: 2 additions & 5 deletions src/TestSuite/TestCase.php
Expand Up @@ -196,19 +196,16 @@ public function loadFixtures()
* Useful to test how plugins being loaded/not loaded interact with other
* elements in CakePHP or applications.
*
* @param string|array $plugins list of Plugins to load
* @param array $plugins list of Plugins to load
* @return \Cake\Http\BaseApplication
*/
public function loadPlugins($plugins = [])
public function loadPlugins(array $plugins = [])
{
$app = $this->getMockForAbstractClass(
BaseApplication::class,
['']
);

if (is_string($plugins)) {
$plugins = (array)$plugins;
}
foreach ($plugins as $k => $opts) {
if (is_array($opts)) {
$app->addPlugin($k, $opts);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Auth/FormAuthenticateTest.php
Expand Up @@ -272,7 +272,7 @@ public function testAuthenticateIncludesVirtualFields()
*/
public function testPluginModel()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$PluginModel = $this->getTableLocator()->get('TestPlugin.AuthUsers');
$user['id'] = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Auth/PasswordHasherFactoryTest.php
Expand Up @@ -41,7 +41,7 @@ public function testBuild()
$this->assertInstanceof('Cake\Auth\DefaultPasswordHasher', $hasher);
$this->assertEquals(['foo' => 'bar'], $hasher->getConfig('hashOptions'));

$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$hasher = PasswordHasherFactory::build('TestPlugin.Legacy');
$this->assertInstanceof('TestPlugin\Auth\LegacyPasswordHasher', $hasher);
Plugin::unload();
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Cache/CacheTest.php
Expand Up @@ -298,7 +298,7 @@ public function testConfigFailedInit()
public function testConfigWithLibAndPluginEngines()
{
static::setAppNamespace();
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$config = ['engine' => 'TestAppCache', 'path' => TMP, 'prefix' => 'cake_test_'];
Cache::setConfig('libEngine', $config);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Console/HelperRegistryTest.php
Expand Up @@ -112,7 +112,7 @@ public function testLoadMissingHelper()
*/
public function testLoadWithAlias()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$result = $this->helpers->load('SimpleAliased', ['className' => 'Simple']);
$this->assertInstanceOf(SimpleHelper::class, $result);
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Console/ShellTest.php
Expand Up @@ -129,7 +129,7 @@ public function testInitialize()
{
static::setAppNamespace();

$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$this->Shell->tasks = ['Extract' => ['one', 'two']];
$this->Shell->plugin = 'TestPlugin';
$this->Shell->modelClass = 'TestPlugin.TestPluginComments';
Expand Down Expand Up @@ -160,7 +160,7 @@ public function testLoadModel()
);
$this->assertEquals('Articles', $Shell->modelClass);

$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$result = $this->Shell->loadModel('TestPlugin.TestPluginComments');
$this->assertInstanceOf(
'TestPlugin\Model\Table\TestPluginCommentsTable',
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Console/TaskRegistryTest.php
Expand Up @@ -88,7 +88,7 @@ public function testLoadPluginTask()
$shell = $this->getMockBuilder('Cake\Console\Shell')
->disableOriginalConstructor()
->getMock();
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$this->Tasks = new TaskRegistry($shell, $dispatcher);

$result = $this->Tasks->load('TestPlugin.OtherTask');
Expand All @@ -104,7 +104,7 @@ public function testLoadPluginTask()
*/
public function testLoadWithAlias()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$result = $this->Tasks->load('CommandAliased', ['className' => 'Command']);
$this->assertInstanceOf('Cake\Shell\Task\CommandTask', $result);
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Controller/ComponentRegistryTest.php
Expand Up @@ -93,7 +93,7 @@ public function testLoadWithAlias()
$result = $this->Components->load('Cookie');
$this->assertInstanceOf(__NAMESPACE__ . '\CookieAliasComponent', $result);

$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$result = $this->Components->load('SomeOther', ['className' => 'TestPlugin.Other']);
$this->assertInstanceOf('TestPlugin\Controller\Component\OtherComponent', $result);
$this->assertInstanceOf('TestPlugin\Controller\Component\OtherComponent', $this->Components->SomeOther);
Expand Down Expand Up @@ -138,7 +138,7 @@ public function testLoadMissingComponent()
*/
public function testLoadPluginComponent()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$result = $this->Components->load('TestPlugin.Other');
$this->assertInstanceOf('TestPlugin\Controller\Component\OtherComponent', $result, 'Component class is wrong.');
$this->assertInstanceOf('TestPlugin\Controller\Component\OtherComponent', $this->Components->Other, 'Class is wrong');
Expand All @@ -151,7 +151,7 @@ public function testLoadPluginComponent()
*/
public function testLoadWithAliasAndPlugin()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$result = $this->Components->load('AliasedOther', ['className' => 'TestPlugin.Other']);
$this->assertInstanceOf('TestPlugin\Controller\Component\OtherComponent', $result);
$this->assertInstanceOf('TestPlugin\Controller\Component\OtherComponent', $this->Components->AliasedOther);
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Controller/ControllerTest.php
Expand Up @@ -318,7 +318,7 @@ public function testLoadModel()
*/
public function testLoadModelInPlugins()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$Controller = new TestPluginController();
$Controller->setPlugin('TestPlugin');
Expand All @@ -343,7 +343,7 @@ public function testLoadModelInPlugins()
*/
public function testConstructSetModelClass()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$request = new ServerRequest();
$response = new Response();
Expand All @@ -368,7 +368,7 @@ public function testConstructSetModelClass()
*/
public function testConstructClassesWithComponents()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$Controller = new TestPluginController(new ServerRequest(), new Response());
$Controller->loadComponent('TestPlugin.Other');
Expand All @@ -383,7 +383,7 @@ public function testConstructClassesWithComponents()
*/
public function testRender()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$request = new ServerRequest([
'url' => 'controller_posts/index',
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Core/Configure/Engine/IniConfigTest.php
Expand Up @@ -210,7 +210,7 @@ public function testReadWithDots()
*/
public function testReadPluginValue()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$engine = new IniConfig($this->path);
$result = $engine->read('TestPlugin.nested');

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Core/Configure/Engine/JsonConfigTest.php
Expand Up @@ -137,7 +137,7 @@ public function testReadWithDots()
*/
public function testReadPluginValue()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$engine = new JsonConfig($this->path);
$result = $engine->read('TestPlugin.load');
$this->assertArrayHasKey('plugin_load', $result);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Core/Configure/Engine/PhpConfigTest.php
Expand Up @@ -123,7 +123,7 @@ public function testReadWithDots()
*/
public function testReadPluginValue()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$engine = new PhpConfig($this->path);
$result = $engine->read('TestPlugin.load');
$this->assertArrayHasKey('plugin_load', $result);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Core/ConfigureTest.php
Expand Up @@ -394,7 +394,7 @@ public function testLoadMergeWithExistingData()
public function testLoadPlugin()
{
Configure::config('test', new PhpConfig());
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$result = Configure::load('TestPlugin.load', 'test');
$this->assertTrue($result);
$expected = '/test_app/Plugin/TestPlugin/Config/load.php';
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Datasource/ConnectionManagerTest.php
Expand Up @@ -202,7 +202,7 @@ public function testConfigured()
*/
public function testGetPluginDataSource()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$name = 'test_variant';
$config = ['className' => 'TestPlugin.TestSource', 'foo' => 'bar'];
ConnectionManager::setConfig($name, $config);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Error/ErrorHandlerTest.php
Expand Up @@ -381,7 +381,7 @@ public function testHandleExceptionLogSkipping()
*/
public function testLoadPluginHandler()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$errorHandler = new TestErrorHandler([
'exceptionRenderer' => 'TestPlugin.TestPluginExceptionRenderer',
]);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Error/ExceptionRendererTest.php
Expand Up @@ -803,7 +803,7 @@ public function testMissingPluginRenderSafe()
*/
public function testMissingPluginRenderSafeWithPlugin()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$exception = new NotFoundException();
$ExceptionRenderer = new ExceptionRenderer($exception);

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Http/SessionTest.php
Expand Up @@ -496,7 +496,7 @@ public function testUsingAppLibsHandler()
public function testUsingPluginHandler()
{
static::setAppNamespace();
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$config = [
'defaults' => 'cake',
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/I18n/I18nTest.php
Expand Up @@ -206,7 +206,7 @@ public function testPluginMesagesLoad()
*/
public function testPluginOverride()
{
$this->loadPlugins('TestTheme');
$this->loadPlugins(['TestTheme']);
$translator = I18n::getTranslator('test_theme');
$this->assertEquals(
'translated',
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Log/LogTest.php
Expand Up @@ -44,7 +44,7 @@ public function tearDown()
public function testImportingLoggers()
{
static::setAppNamespace();
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

Log::setConfig('libtest', [
'engine' => 'TestApp'
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Mailer/EmailTest.php
Expand Up @@ -1746,7 +1746,7 @@ public function testSendRenderJapanese()
*/
public function testSendRenderThemed()
{
$this->loadPlugins('TestTheme');
$this->loadPlugins(['TestTheme']);
$this->Email->reset();
$this->Email->setTransport('debug');

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/AssociationTest.php
Expand Up @@ -436,7 +436,7 @@ public function testSetTarget()
*/
public function testTargetPlugin()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$config = [
'className' => 'TestPlugin.Comments',
'foreignKey' => 'a_key',
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/ORM/BehaviorRegistryTest.php
Expand Up @@ -58,7 +58,7 @@ public function tearDown()
*/
public function testClassName()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$expected = 'Cake\ORM\Behavior\TranslateBehavior';
$result = BehaviorRegistry::className('Translate');
Expand All @@ -78,7 +78,7 @@ public function testClassName()
*/
public function testLoad()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$config = ['alias' => 'Sluggable', 'replacement' => '-'];
$result = $this->Behaviors->load('Sluggable', $config);
$this->assertInstanceOf('TestApp\Model\Behavior\SluggableBehavior', $result);
Expand Down Expand Up @@ -127,7 +127,7 @@ public function testLoadEnabledFalse()
*/
public function testLoadPlugin()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$result = $this->Behaviors->load('TestPlugin.PersisterOne');

$expected = 'TestPlugin\Model\Behavior\PersisterOneBehavior';
Expand Down Expand Up @@ -220,7 +220,7 @@ public function testLoadDuplicateFinderAliasing()
*/
public function testHasMethod()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$this->Behaviors->load('TestPlugin.PersisterOne');
$this->Behaviors->load('Sluggable');

Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/ORM/Locator/TableLocatorTest.php
Expand Up @@ -124,7 +124,7 @@ public function testGetConfig()
*/
public function testConfigPlugin()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$data = [
'connection' => 'testing',
Expand Down Expand Up @@ -336,7 +336,7 @@ public function testGetWithConventions()
*/
public function testGetPlugin()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$table = $this->_locator->get('TestPlugin.TestPluginComments');

$this->assertInstanceOf('TestPlugin\Model\Table\TestPluginCommentsTable', $table);
Expand Down Expand Up @@ -388,7 +388,7 @@ public function testGetMultiplePlugins()
*/
public function testGetPluginWithClassNameOption()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$table = $this->_locator->get('Comments', [
'className' => 'TestPlugin.TestPluginComments',
]);
Expand All @@ -409,7 +409,7 @@ public function testGetPluginWithClassNameOption()
*/
public function testGetPluginWithFullNamespaceName()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$class = 'TestPlugin\Model\Table\TestPluginCommentsTable';
$table = $this->_locator->get('Comments', [
'className' => $class,
Expand Down Expand Up @@ -522,7 +522,7 @@ public function testSet()
*/
public function testSetPlugin()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);

$mock = $this->getMockBuilder('TestPlugin\Model\Table\CommentsTable')->getMock();

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/QueryRegressionTest.php
Expand Up @@ -527,7 +527,7 @@ public function testBelongsToManyDeepSave2()
public function testPluginAssociationQueryGeneration()
{
$this->loadFixtures('Articles', 'Comments', 'Authors');
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$articles = $this->getTableLocator()->get('Articles');
$articles->hasMany('TestPlugin.Comments');
$articles->belongsTo('TestPlugin.Authors');
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/ResultSetTest.php
Expand Up @@ -382,7 +382,7 @@ public function testFetchMissingDefaultAlias()
*/
public function testSourceOnContainAssociations()
{
$this->loadPlugins('TestPlugin');
$this->loadPlugins(['TestPlugin']);
$comments = $this->getTableLocator()->get('TestPlugin.Comments');
$comments->belongsTo('Authors', [
'className' => 'TestPlugin.Authors',
Expand Down

0 comments on commit f9d2db1

Please sign in to comment.