From 3c42666bfc2b02059b12bfd2d44c1bf675ede0df Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Mon, 22 Aug 2016 17:10:39 +0100 Subject: [PATCH] Issue #2787577 by alexpott, dawehner: When tests use multiple namespaces they should do so in a coding standards compliant way --- .../AggregatorPluginSettingsBaseTest.php | 12 +-- .../tests/src/Unit/CommentLinkBuilderTest.php | 12 +-- .../src/Unit/LanguageNegotiationUrlTest.php | 14 ++- .../tests/src/Unit/TestInfoParsingTest.php | 8 +- .../Controller/ViewAjaxControllerTest.php | 4 +- .../tests/src/Unit/EntityViewsDataTest.php | 12 +-- .../src/Unit/Plugin/Block/ViewsBlockTest.php | 14 ++- .../Unit/Plugin/field/FieldPluginBaseTest.php | 14 +-- .../views/field/EntityOperationsUnitTest.php | 4 +- .../Unit/Routing/ViewPageControllerTest.php | 14 ++- .../Utility/ArgumentsResolverTest.php | 10 +- .../Asset/CssCollectionRendererUnitTest.php | 86 ++++++++------- .../Tests/Core/Asset/CssOptimizerUnitTest.php | 100 ++++++++++-------- .../Config/Entity/ConfigEntityStorageTest.php | 15 ++- .../Core/Entity/EntityResolverManagerTest.php | 35 +++--- .../KeyValueEntityStorageTest.php | 16 ++- .../Plugin/Discovery/HookDiscoveryTest.php | 20 ++-- .../Core/Render/Element/MachineNameTest.php | 12 +-- .../Session/PermissionsHashGeneratorTest.php | 22 ++-- .../Tests/Core/Utility/LinkGeneratorTest.php | 4 +- 20 files changed, 205 insertions(+), 223 deletions(-) diff --git a/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php b/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php index 022b7934314..87a5d934329 100644 --- a/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php +++ b/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php @@ -1,6 +1,6 @@ moduleHandler->expects($this->at(1)) ->method('invoke') ->with('hook_discovery_test', 'test_plugin') - ->will($this->returnValue(hook_discovery_test_test_plugin())); + ->will($this->returnValue($this->hookDiscoveryTestTestPlugin())); $this->moduleHandler->expects($this->at(2)) ->method('invoke') ->with('hook_discovery_test2', 'test_plugin') - ->will($this->returnValue(hook_discovery_test2_test_plugin())); + ->will($this->returnValue($this->hookDiscoveryTest2TestPlugin())); $definitions = $this->hookDiscovery->getDefinitions(); @@ -94,8 +94,8 @@ class HookDiscoveryTest extends UnitTestCase { $this->moduleHandler->expects($this->any()) ->method('invoke') ->will($this->returnValueMap(array( - array('hook_discovery_test', 'test_plugin', array(), hook_discovery_test_test_plugin()), - array('hook_discovery_test2', 'test_plugin', array(), hook_discovery_test2_test_plugin()), + array('hook_discovery_test', 'test_plugin', array(), $this->hookDiscoveryTestTestPlugin()), + array('hook_discovery_test2', 'test_plugin', array(), $this->hookDiscoveryTest2TestPlugin()), ) )); @@ -129,20 +129,16 @@ class HookDiscoveryTest extends UnitTestCase { $this->hookDiscovery->getDefinition('test_non_existant', TRUE); } -} - -} - -namespace { - function hook_discovery_test_test_plugin() { + protected function hookDiscoveryTestTestPlugin() { return array( 'test_id_1' => array('class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Apple'), 'test_id_2' => array('class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Orange'), ); } - function hook_discovery_test2_test_plugin() { + protected function hookDiscoveryTest2TestPlugin() { return array( 'test_id_3' => array('class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry'), ); } + } diff --git a/core/tests/Drupal/Tests/Core/Render/Element/MachineNameTest.php b/core/tests/Drupal/Tests/Core/Render/Element/MachineNameTest.php index fe4406ded4c..c7ef72e3c5f 100644 --- a/core/tests/Drupal/Tests/Core/Render/Element/MachineNameTest.php +++ b/core/tests/Drupal/Tests/Core/Render/Element/MachineNameTest.php @@ -1,6 +1,6 @@