Core and composer updates
This commit is contained in:
parent
a82634bb98
commit
62cac30480
1118 changed files with 21770 additions and 6306 deletions
|
@ -21,7 +21,7 @@ class StatisticsSettingsForm extends ConfigFormBase {
|
|||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* Constructs a \Drupal\user\StatisticsSettingsForm object.
|
||||
* Constructs a \Drupal\statistics\StatisticsSettingsForm object.
|
||||
*
|
||||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
||||
* The factory for configuration objects.
|
||||
|
|
|
@ -27,7 +27,10 @@ interface StatisticsStorageInterface {
|
|||
* @param array $ids
|
||||
* An array of IDs of entities to fetch the views for.
|
||||
*
|
||||
* @return array \Drupal\statistics\StatisticsViewsResult
|
||||
* @return \Drupal\statistics\StatisticsViewsResult[]
|
||||
* An array of value objects representing the number of times each entity
|
||||
* has been viewed. The array is keyed by entity ID. If an ID does not
|
||||
* exist, it will not be present in the array.
|
||||
*/
|
||||
public function fetchViews($ids);
|
||||
|
||||
|
@ -37,7 +40,9 @@ interface StatisticsStorageInterface {
|
|||
* @param int $id
|
||||
* The ID of the entity to fetch the views for.
|
||||
*
|
||||
* @return \Drupal\statistics\StatisticsViewsResult
|
||||
* @return \Drupal\statistics\StatisticsViewsResult|false
|
||||
* If the entity exists, a value object representing the number of times if
|
||||
* has been viewed. If it does not exist, FALSE is returned.
|
||||
*/
|
||||
public function fetchView($id);
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
|||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\statistics\StatisticsViewsResult;
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
|
@ -125,6 +126,12 @@ function statistics_get($id) {
|
|||
if ($id > 0) {
|
||||
/** @var \Drupal\statistics\StatisticsViewsResult $statistics */
|
||||
$statistics = \Drupal::service('statistics.storage.node')->fetchView($id);
|
||||
|
||||
// For backwards compatibility, return FALSE if an invalid node ID was
|
||||
// passed in.
|
||||
if (!($statistics instanceof StatisticsViewsResult)) {
|
||||
return FALSE;
|
||||
}
|
||||
return [
|
||||
'totalcount' => $statistics->getTotalCount(),
|
||||
'daycount' => $statistics->getDayCount(),
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\statistics\Tests;
|
||||
namespace Drupal\Tests\statistics\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\Tests\Traits\Core\CronRunTrait;
|
||||
|
||||
/**
|
||||
* Tests the statistics admin.
|
||||
*
|
||||
* @group statistics
|
||||
*/
|
||||
class StatisticsAdminTest extends WebTestBase {
|
||||
class StatisticsAdminTest extends BrowserTestBase {
|
||||
|
||||
use CronRunTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
|
@ -1,8 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\statistics\Tests;
|
||||
namespace Drupal\Tests\statistics\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
|
||||
/**
|
||||
* Tests request logging for cached and uncached pages.
|
||||
|
@ -12,7 +13,7 @@ use Drupal\simpletest\WebTestBase;
|
|||
*
|
||||
* @group statistics
|
||||
*/
|
||||
class StatisticsLoggingTest extends WebTestBase {
|
||||
class StatisticsLoggingTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -125,6 +126,17 @@ class StatisticsLoggingTest extends WebTestBase {
|
|||
$this->client->post($base_root . $stats_path, ['form_params' => $post]);
|
||||
$node_counter = statistics_get($this->node->id());
|
||||
$this->assertIdentical($node_counter['totalcount'], '1');
|
||||
|
||||
// Try fetching statistics for an invalid node ID and verify it returns
|
||||
// FALSE.
|
||||
$node_id = 1000000;
|
||||
$node = Node::load($node_id);
|
||||
$this->assertNull($node);
|
||||
|
||||
// This is a test specifically for the deprecated statistics_get() function
|
||||
// and so should remain unconverted until that function is removed.
|
||||
$result = statistics_get($node_id);
|
||||
$this->assertIdentical($result, FALSE);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\statistics\Tests;
|
||||
namespace Drupal\Tests\statistics\Functional;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
|
@ -32,7 +32,7 @@ class MigrateStatisticsConfigsTest extends MigrateDrupal6TestBase {
|
|||
*/
|
||||
public function testStatisticsSettings() {
|
||||
$config = $this->config('statistics.settings');
|
||||
$this->assertIdentical(0, $config->get('count_content_views'));
|
||||
$this->assertSame(1, $config->get('count_content_views'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'statistics.settings', $config->get());
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue