diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheTest.php index b836d36034e3adf06f1514424a551cda890763c8..a42557219db7d73028f21b68f269439529946925 100644 --- a/core/tests/Drupal/Tests/Core/Cache/CacheTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/CacheTest.php @@ -53,7 +53,8 @@ public function testValidateTags(array $tags, $expected_exception_message) { if ($expected_exception_message !== FALSE) { $this->setExpectedException('LogicException', $expected_exception_message); } - Cache::validateTags($tags); + // If it doesn't throw an exception, validateTags() returns NULL. + $this->assertNull(Cache::validateTags($tags)); } /** diff --git a/core/tests/Drupal/Tests/Core/DrupalTest.php b/core/tests/Drupal/Tests/Core/DrupalTest.php index b281eef10f5ab95b68ec1564bd0f4faf32d0a74f..4af023dd8cd9e9bcca77d12ef9616474be4b7616 100644 --- a/core/tests/Drupal/Tests/Core/DrupalTest.php +++ b/core/tests/Drupal/Tests/Core/DrupalTest.php @@ -34,6 +34,8 @@ protected function setUp() { /** * Tests the get/setContainer() method. + * + * @covers ::getContainer */ public function testSetContainer() { \Drupal::setContainer($this->container); @@ -42,6 +44,8 @@ public function testSetContainer() { /** * Tests the service() method. + * + * @covers ::service */ public function testService() { $this->setMockContainerService('test_service'); @@ -50,6 +54,8 @@ public function testService() { /** * Tests the currentUser() method. + * + * @covers ::currentUser */ public function testCurrentUser() { $this->setMockContainerService('current_user'); @@ -58,6 +64,8 @@ public function testCurrentUser() { /** * Tests the entityManager() method. + * + * @covers ::entityManager */ public function testEntityManager() { $this->setMockContainerService('entity.manager'); @@ -66,6 +74,8 @@ public function testEntityManager() { /** * Tests the database() method. + * + * @covers ::database */ public function testDatabase() { $this->setMockContainerService('database'); @@ -74,6 +84,8 @@ public function testDatabase() { /** * Tests the service() method. + * + * @covers ::cache */ public function testCache() { $this->setMockContainerService('cache.test'); @@ -82,6 +94,8 @@ public function testCache() { /** * Tests the keyValueExpirable() method. + * + * @covers ::keyValueExpirable */ public function testKeyValueExpirable() { $keyvalue = $this->getMockBuilder('Drupal\Core\KeyValueStore\KeyValueExpirableFactory') @@ -98,6 +112,8 @@ public function testKeyValueExpirable() { /** * Tests the lock() method. + * + * @covers ::lock */ public function testLock() { $this->setMockContainerService('lock'); @@ -106,6 +122,8 @@ public function testLock() { /** * Tests the config() method. + * + * @covers ::config */ public function testConfig() { $config = $this->getMock('Drupal\Core\Config\ConfigFactoryInterface'); @@ -120,6 +138,8 @@ public function testConfig() { /** * Tests the queue() method. + * + * @covers ::queue */ public function testQueue() { $queue = $this->getMockBuilder('Drupal\Core\Queue\QueueFactory') @@ -148,6 +168,8 @@ public function testRequestStack() { /** * Tests the keyValue() method. + * + * @covers ::keyValue */ public function testKeyValue() { $keyvalue = $this->getMockBuilder('Drupal\Core\KeyValueStore\KeyValueFactory') @@ -164,6 +186,8 @@ public function testKeyValue() { /** * Tests the state() method. + * + * @covers ::state */ public function testState() { $this->setMockContainerService('state'); @@ -172,6 +196,8 @@ public function testState() { /** * Tests the httpClient() method. + * + * @covers ::httpClient */ public function testHttpClient() { $this->setMockContainerService('http_client'); @@ -180,6 +206,8 @@ public function testHttpClient() { /** * Tests the entityQuery() method. + * + * @covers ::entityQuery */ public function testEntityQuery() { $query = $this->getMockBuilder('Drupal\Core\Entity\Query\QueryFactory') @@ -196,6 +224,8 @@ public function testEntityQuery() { /** * Tests the entityQueryAggregate() method. + * + * @covers ::entityQueryAggregate */ public function testEntityQueryAggregate() { $query = $this->getMockBuilder('Drupal\Core\Entity\Query\QueryFactory') @@ -212,6 +242,8 @@ public function testEntityQueryAggregate() { /** * Tests the flood() method. + * + * @covers ::flood */ public function testFlood() { $this->setMockContainerService('flood'); @@ -220,6 +252,8 @@ public function testFlood() { /** * Tests the moduleHandler() method. + * + * @covers ::moduleHandler */ public function testModuleHandler() { $this->setMockContainerService('module_handler'); @@ -227,7 +261,9 @@ public function testModuleHandler() { } /** - * Tests the typedData() method. + * Tests the typedDataManager() method. + * + * @covers ::typedDataManager */ public function testTypedDataManager() { $this->setMockContainerService('typed_data_manager'); @@ -236,6 +272,8 @@ public function testTypedDataManager() { /** * Tests the token() method. + * + * @covers ::token */ public function testToken() { $this->setMockContainerService('token'); @@ -244,6 +282,8 @@ public function testToken() { /** * Tests the urlGenerator() method. + * + * @covers ::urlGenerator */ public function testUrlGenerator() { $this->setMockContainerService('url_generator'); @@ -253,6 +293,7 @@ public function testUrlGenerator() { /** * Tests the _url() method. * + * @covers ::url * @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute() */ public function testUrl() { @@ -270,6 +311,8 @@ public function testUrl() { /** * Tests the linkGenerator() method. + * + * @covers ::linkGenerator */ public function testLinkGenerator() { $this->setMockContainerService('link_generator'); @@ -277,8 +320,9 @@ public function testLinkGenerator() { } /** - * Tests the _l() method. + * Tests the l() method. * + * @covers ::l * @see \Drupal\Core\Utility\LinkGeneratorInterface::generate() */ public function testL() { @@ -297,6 +341,8 @@ public function testL() { /** * Tests the translation() method. + * + * @covers ::translation */ public function testTranslation() { $this->setMockContainerService('string_translation'); @@ -305,6 +351,8 @@ public function testTranslation() { /** * Tests the languageManager() method. + * + * @covers ::languageManager */ public function testLanguageManager() { $this->setMockContainerService('language_manager'); @@ -313,6 +361,8 @@ public function testLanguageManager() { /** * Tests the csrfToken() method. + * + * @covers ::csrfToken */ public function testCsrfToken() { $this->setMockContainerService('csrf_token'); @@ -321,6 +371,8 @@ public function testCsrfToken() { /** * Tests the transliteration() method. + * + * @covers ::transliteration */ public function testTransliteration() { $this->setMockContainerService('transliteration'); @@ -329,6 +381,8 @@ public function testTransliteration() { /** * Tests the formBuilder() method. + * + * @covers ::formBuilder */ public function testFormBuilder() { $this->setMockContainerService('form_builder'); @@ -337,6 +391,8 @@ public function testFormBuilder() { /** * Tests the menuTree() method. + * + * @covers ::menuTree */ public function testMenuTree() { $this->setMockContainerService('menu.link_tree'); @@ -345,6 +401,8 @@ public function testMenuTree() { /** * Tests the pathValidator() method. + * + * @covers ::pathValidator */ public function testPathValidator() { $this->setMockContainerService('path.validator'); @@ -353,6 +411,8 @@ public function testPathValidator() { /** * Tests the accessManager() method. + * + * @covers ::accessManager */ public function testAccessManager() { $this->setMockContainerService('access_manager'); diff --git a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php index 2b1b3ce7b8397b0380d7fe3eedb62d89434dd195..8c3a0f80c6a9136355d9fc6352dc663432a0a3b2 100644 --- a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php @@ -295,7 +295,8 @@ public function testCustomStorage() { public function testDefaultValueCallback() { $definition = BaseFieldDefinition::create($this->fieldType); $callback = get_class($this) . '::mockDefaultValueCallback'; - $definition->setDefaultValueCallback($callback); + // setDefaultValueCallback returns $this. + $this->assertSame($definition, $definition->setDefaultValueCallback($callback)); } /** @@ -306,7 +307,10 @@ public function testDefaultValueCallback() { */ public function testInvalidDefaultValueCallback() { $definition = BaseFieldDefinition::create($this->fieldType); - $definition->setDefaultValueCallback([get_class($this), 'mockDefaultValueCallback']); + // setDefaultValueCallback returns $this. + $this->assertSame($definition, + $definition->setDefaultValueCallback([get_class($this), 'mockDefaultValueCallback']) + ); } /** @@ -316,7 +320,8 @@ public function testInvalidDefaultValueCallback() { */ public function testNullDefaultValueCallback() { $definition = BaseFieldDefinition::create($this->fieldType); - $definition->setDefaultValueCallback(NULL); + // setDefaultValueCallback returns $this. + $this->assertSame($definition, $definition->setDefaultValueCallback(NULL)); } /** diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php index 222dd133768cbf1f598d3f1e3df2d7cd80ed83d3..400df61252c8a6e8515aedc2810d3f6f2faa8f32 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php @@ -92,6 +92,7 @@ protected function setUp() { * @covers ::addDefaultLangcodeSchema() * @covers ::processBaseTable() * @covers ::processIdentifierSchema() + * @covers ::onEntityTypeCreate() */ public function testGetSchemaBase() { $this->entityType = new ContentEntityType(array( @@ -380,7 +381,9 @@ public function testGetSchemaBase() { ->method('getTableMapping') ->will($this->returnValue($table_mapping)); - $this->storageSchema->onEntityTypeCreate($this->entityType); + $this->assertNull( + $this->storageSchema->onEntityTypeCreate($this->entityType) + ); } /** @@ -394,6 +397,7 @@ public function testGetSchemaBase() { * @covers ::getEntityIndexName() * @covers ::processRevisionTable() * @covers ::processIdentifierSchema() + * @covers ::onEntityTypeCreate() */ public function testGetSchemaRevisionable() { $this->entityType = new ContentEntityType(array( @@ -568,7 +572,9 @@ public function testGetSchemaTranslatable() { ->method('getTableMapping') ->will($this->returnValue($table_mapping)); - $this->storageSchema->onEntityTypeCreate($this->entityType); + $this->assertNull( + $this->storageSchema->onEntityTypeCreate($this->entityType) + ); } /** @@ -759,8 +765,7 @@ public function testGetSchemaRevisionableTranslatable() { /** * Tests the schema for a field dedicated table. * - * @covers ::getDedicatedTableSchema() - * @covers ::createDedicatedTableSchema() + * @covers ::onFieldStorageDefinitionCreate */ public function testDedicatedTableSchema() { $entity_type_id = 'entity_test'; @@ -898,14 +903,15 @@ public function testDedicatedTableSchema() { ->method('getTableMapping') ->will($this->returnValue($table_mapping)); - $this->storageSchema->onFieldStorageDefinitionCreate($field_storage); + $this->assertNull( + $this->storageSchema->onFieldStorageDefinitionCreate($field_storage) + ); } /** * Tests the schema for a field dedicated table for an entity with a string identifier. * - * @covers ::getDedicatedTableSchema() - * @covers ::createDedicatedTableSchema() + * @covers ::onFieldStorageDefinitionCreate */ public function testDedicatedTableSchemaForEntityWithStringIdentifier() { $entity_type_id = 'entity_test'; @@ -1043,7 +1049,9 @@ public function testDedicatedTableSchemaForEntityWithStringIdentifier() { ->method('getTableMapping') ->will($this->returnValue($table_mapping)); - $this->storageSchema->onFieldStorageDefinitionCreate($field_storage); + $this->assertNull( + $this->storageSchema->onFieldStorageDefinitionCreate($field_storage) + ); } /** diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php index 7767ff01996a4b104d1e0ef785145ff7e25d0035..c2ef84143c160dafb3e2861c8548d403825263d5 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php @@ -218,7 +218,7 @@ public function testCreateInstanceWithJustValidInterfaces() { $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, NULL, NULL, '\Drupal\plugin_test\Plugin\plugin_test\fruit\FruitInterface'); foreach ($this->expectedDefinitions as $plugin_id => $definition) { - $plugin_manager->createInstance($plugin_id); + $this->assertNotNull($plugin_manager->createInstance($plugin_id)); } } @@ -276,7 +276,7 @@ public function testGetDefinitionsWithoutRequiredInterface() { $this->expectedDefinitions['banana']['provider'] = 'plugin_test'; $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, $module_handler, NULL); - $plugin_manager->getDefinitions(); + $this->assertInternalType('array', $plugin_manager->getDefinitions()); } } diff --git a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php index 77b73d7e69a058deaf2478ec68b31bfa1b583a27..17409b437dedc9a25250e7405f69833148427dc9 100644 --- a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Routing\Route; /** - * @coversDefaultClass \Drupal\Core\Routing\Router + * @coversDefaultClass \Drupal\Core\Routing\AccessAwareRouter * @group Routing */ class AccessAwareRouterTest extends UnitTestCase { diff --git a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php index 231f833e8a76667b0b60e65af6e1055a8d6b070d..f92109b42dd0927d6463724fe1bc7c6d8c26f8a0 100644 --- a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php +++ b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php @@ -51,7 +51,7 @@ public function testNoProxy() { /** * Tests that subscriber sets trusted headers when reverse proxy is set. * - * @dataProvider testReverseProxyEnabledProvider + * @dataProvider reverseProxyEnabledProvider */ public function testReverseProxyEnabled($provided_settings) { // Enable reverse proxy and add test values. @@ -62,7 +62,7 @@ public function testReverseProxyEnabled($provided_settings) { /** * Data provider for testReverseProxyEnabled. */ - public function testReverseProxyEnabledProvider() { + public function reverseProxyEnabledProvider() { return array( array( array(