diff --git a/core/tests/Drupal/Tests/Core/DrupalTest.php b/core/tests/Drupal/Tests/Core/DrupalTest.php index 7fb3719..134690f 100644 --- a/core/tests/Drupal/Tests/Core/DrupalTest.php +++ b/core/tests/Drupal/Tests/Core/DrupalTest.php @@ -52,7 +52,7 @@ public function testSetContainer() { */ public function testService() { $this->setMockContainerService('test_service'); - \Drupal::service('test_service'); + $this->assertNotNull(\Drupal::service('test_service')); } /** @@ -60,7 +60,7 @@ public function testService() { */ public function testRequest() { $this->setMockContainerService('request'); - \Drupal::request(); + $this->assertNotNull(\Drupal::request()); } /** @@ -68,7 +68,7 @@ public function testRequest() { */ public function testCurrentUser() { $this->setMockContainerService('current_user'); - \Drupal::currentUser(); + $this->assertNotNull(\Drupal::currentUser()); } /** @@ -76,7 +76,7 @@ public function testCurrentUser() { */ public function testEntityManager() { $this->setMockContainerService('entity.manager'); - \Drupal::entityManager(); + $this->assertNotNull(\Drupal::entityManager()); } /** @@ -84,7 +84,7 @@ public function testEntityManager() { */ public function testDatabase() { $this->setMockContainerService('database'); - \Drupal::database(); + $this->assertNotNull(\Drupal::database()); } /** @@ -92,7 +92,7 @@ public function testDatabase() { */ public function testCache() { $this->setMockContainerService('cache.test'); - \Drupal::cache('test'); + $this->assertNotNull(\Drupal::cache('test')); } /** @@ -104,9 +104,11 @@ public function testKeyValueExpirable() { ->getMock(); $keyvalue->expects($this->once()) ->method('get') - ->with('test_collection'); + ->with('test_collection') + ->will($this->returnValue(TRUE)); $this->setMockContainerService('keyvalue.expirable', $keyvalue); - \Drupal::keyValueExpirable('test_collection'); + + $this->assertNotNull(\Drupal::keyValueExpirable('test_collection')); } /** @@ -114,7 +116,7 @@ public function testKeyValueExpirable() { */ public function testLock() { $this->setMockContainerService('lock'); - \Drupal::lock(); + $this->assertNotNull(\Drupal::lock()); } /** @@ -126,9 +128,11 @@ public function testConfig() { ->getMock(); $config->expects($this->once()) ->method('get') - ->with('test_config'); + ->with('test_config') + ->will($this->returnValue(TRUE)); $this->setMockContainerService('config.factory', $config); - \Drupal::config('test_config'); + + $this->assertNotNull(\Drupal::config('test_config')); } /** @@ -140,9 +144,11 @@ public function testQueue() { ->getMock(); $queue->expects($this->once()) ->method('get') - ->with('test_queue', TRUE); + ->with('test_queue', TRUE) + ->will($this->returnValue(TRUE)); $this->setMockContainerService('queue', $queue); - \Drupal::queue('test_queue', TRUE); + + $this->assertNotNull(\Drupal::queue('test_queue', TRUE)); } /** @@ -154,9 +160,11 @@ public function testKeyValue() { ->getMock(); $keyvalue->expects($this->once()) ->method('get') - ->with('test_collection'); + ->with('test_collection') + ->will($this->returnValue(TRUE)); $this->setMockContainerService('keyvalue', $keyvalue); - \Drupal::keyValue('test_collection'); + + $this->assertNotNull(\Drupal::keyValue('test_collection')); } /** @@ -164,7 +172,7 @@ public function testKeyValue() { */ public function testState() { $this->setMockContainerService('state'); - \Drupal::state(); + $this->assertNotNull(\Drupal::state()); } /** @@ -172,7 +180,7 @@ public function testState() { */ public function testHttpClient() { $this->setMockContainerService('http_default_client'); - \Drupal::httpClient(); + $this->assertNotNull(\Drupal::httpClient()); } /** @@ -184,9 +192,11 @@ public function testEntityQuery() { ->getMock(); $query->expects($this->once()) ->method('get') - ->with('test_entity', 'OR'); + ->with('test_entity', 'OR') + ->will($this->returnValue(TRUE)); $this->setMockContainerService('entity.query', $query); - \Drupal::entityQuery('test_entity', 'OR'); + + $this->assertNotNull(\Drupal::entityQuery('test_entity', 'OR')); } /** @@ -198,9 +208,11 @@ public function testEntityQueryAggregate() { ->getMock(); $query->expects($this->once()) ->method('getAggregate') - ->with('test_entity', 'OR'); + ->with('test_entity', 'OR') + ->will($this->returnValue(TRUE)); $this->setMockContainerService('entity.query', $query); - \Drupal::entityQueryAggregate('test_entity', 'OR'); + + $this->assertNotNull(\Drupal::entityQueryAggregate('test_entity', 'OR')); } /** @@ -208,7 +220,7 @@ public function testEntityQueryAggregate() { */ public function testFlood() { $this->setMockContainerService('flood'); - \Drupal::flood(); + $this->assertNotNull(\Drupal::flood()); } /** @@ -216,7 +228,7 @@ public function testFlood() { */ public function testModuleHandler() { $this->setMockContainerService('module_handler'); - \Drupal::moduleHandler(); + $this->assertNotNull(\Drupal::moduleHandler()); } /** @@ -224,7 +236,7 @@ public function testModuleHandler() { */ public function testTypedData() { $this->setMockContainerService('typed_data'); - \Drupal::typedData(); + $this->assertNotNull(\Drupal::typedData()); } /** @@ -232,7 +244,7 @@ public function testTypedData() { */ public function testToken() { $this->setMockContainerService('token'); - \Drupal::token(); + $this->assertNotNull(\Drupal::token()); } /** @@ -240,7 +252,7 @@ public function testToken() { */ public function testUrlGenerator() { $this->setMockContainerService('url_generator'); - \Drupal::urlGenerator(); + $this->assertNotNull(\Drupal::urlGenerator()); } /** @@ -254,9 +266,11 @@ public function testUrl() { ->getMock(); $generator->expects($this->once()) ->method('generateFromRoute') - ->with('test_route', $route_parameters, $options); + ->with('test_route', $route_parameters, $options) + ->will($this->returnValue(TRUE)); $this->setMockContainerService('url_generator', $generator); - \Drupal::url('test_route', $route_parameters, $options); + + $this->assertNotNull(\Drupal::url('test_route', $route_parameters, $options)); } /** @@ -264,7 +278,7 @@ public function testUrl() { */ public function testLinkGenerator() { $this->setMockContainerService('link_generator'); - \Drupal::linkGenerator(); + $this->assertNotNull(\Drupal::linkGenerator()); } /** @@ -278,9 +292,11 @@ public function testL() { ->getMock(); $generator->expects($this->once()) ->method('generate') - ->with('Test title', 'test_route', $route_parameters, $options); + ->with('Test title', 'test_route', $route_parameters, $options) + ->will($this->returnValue(TRUE)); $this->setMockContainerService('link_generator', $generator); - \Drupal::l('Test title', 'test_route', $route_parameters, $options); + + $this->assertNotNull(\Drupal::l('Test title', 'test_route', $route_parameters, $options)); } /** @@ -288,7 +304,7 @@ public function testL() { */ public function testTranslation() { $this->setMockContainerService('string_translation'); - \Drupal::translation(); + $this->assertNotNull(\Drupal::translation()); } /** @@ -296,7 +312,7 @@ public function testTranslation() { */ public function testLanguageManager() { $this->setMockContainerService('language_manager'); - \Drupal::languageManager(); + $this->assertNotNull(\Drupal::languageManager()); } /** @@ -304,7 +320,7 @@ public function testLanguageManager() { */ public function testCsrfToken() { $this->setMockContainerService('csrf_token'); - \Drupal::csrfToken(); + $this->assertNotNull(\Drupal::csrfToken()); } /** @@ -312,7 +328,7 @@ public function testCsrfToken() { */ public function testTransliteration() { $this->setMockContainerService('transliteration'); - \Drupal::transliteration(); + $this->assertNotNull(\Drupal::transliteration()); } /** @@ -331,6 +347,9 @@ protected function setMockContainerService($service_name, $return = NULL) { if (isset($return)) { $expects->will($this->returnValue($return)); } + else { + $expects->will($this->returnValue(TRUE)); + } \Drupal::setContainer($this->container); }