Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542

This commit is contained in:
Pantheon Automation 2015-08-27 12:03:05 -07:00 committed by Greg Anderson
parent 3b2511d96d
commit 81ccda77eb
2155 changed files with 54307 additions and 46870 deletions

View file

@ -0,0 +1,17 @@
id: d6_statistics_settings
label: Drupal 6 statistics configuration
migration_tags:
- Drupal 6
source:
plugin: variable
variables:
- statistics_enable_access_log
- statistics_flush_accesslog_timer
- statistics_count_content_views
process:
'access_log/enabled': statistics_enable_access_log
'access_log/max_lifetime': statistics_flush_accesslog_timer
'count_content_views': statistics_count_content_views
destination:
plugin: config
config_name: statistics.settings

View file

@ -0,0 +1,49 @@
<?php
/**
* @file
* Contains \Drupal\statistics\Tests\Migrate\d6\MigrateStatisticsConfigsTest.
*/
namespace Drupal\statistics\Tests\Migrate\d6;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to statistics.settings.yml.
*
* @group statistics
*/
class MigrateStatisticsConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('statistics');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loadDumps(['Variable.php']);
$this->executeMigration('d6_statistics_settings');
}
/**
* Tests migration of statistics variables to statistics.settings.yml.
*/
public function testStatisticsSettings() {
$config = $this->config('statistics.settings');
$this->assertIdentical(FALSE, $config->get('access_log.enabled'));
$this->assertIdentical(259200, $config->get('access_log.max_lifetime'));
$this->assertIdentical(0, $config->get('count_content_views'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'statistics.settings', $config->get());
}
}

View file

@ -40,7 +40,7 @@ class StatisticsAdminTest extends WebTestBase {
/**
* The Guzzle HTTP client.
*
* @var \GuzzleHttp\ClientInterface;
* @var \GuzzleHttp\Client;
*/
protected $client;
@ -54,8 +54,8 @@ class StatisticsAdminTest extends WebTestBase {
$this->privilegedUser = $this->drupalCreateUser(array('administer statistics', 'view post access counter', 'create page content'));
$this->drupalLogin($this->privilegedUser);
$this->testNode = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->privilegedUser->id()));
$this->client = \Drupal::httpClient();
$this->client->setDefaultOption('config/curl', array(CURLOPT_TIMEOUT => 10));
$this->client = \Drupal::service('http_client_factory')
->fromOptions(['config/curl' => [CURLOPT_TIMEOUT => 10]]);
}
/**
@ -78,16 +78,16 @@ class StatisticsAdminTest extends WebTestBase {
$post = array('nid' => $nid);
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$this->client->post($stats_path, array('body' => $post));
$this->client->post($stats_path, array('form_params' => $post));
// Hit the node again (the counter is incremented after the hit, so
// "1 view" will actually be shown when the node is hit the second time).
$this->drupalGet('node/' . $this->testNode->id());
$this->client->post($stats_path, array('body' => $post));
$this->client->post($stats_path, array('form_params' => $post));
$this->assertText('1 view', 'Node is viewed once.');
$this->drupalGet('node/' . $this->testNode->id());
$this->client->post($stats_path, array('body' => $post));
$this->client->post($stats_path, array('form_params' => $post));
$this->assertText('2 views', 'Node is viewed 2 times.');
}
@ -103,7 +103,7 @@ class StatisticsAdminTest extends WebTestBase {
$post = array('nid' => $nid);
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$this->client->post($stats_path, array('body' => $post));
$this->client->post($stats_path, array('form_params' => $post));
$result = db_select('node_counter', 'n')
->fields('n', array('nid'))
@ -137,9 +137,9 @@ class StatisticsAdminTest extends WebTestBase {
$post = array('nid' => $nid);
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$this->client->post($stats_path, array('body' => $post));
$this->client->post($stats_path, array('form_params' => $post));
$this->drupalGet('node/' . $this->testNode->id());
$this->client->post($stats_path, array('body' => $post));
$this->client->post($stats_path, array('form_params' => $post));
$this->assertText('1 view', 'Node is viewed once.');
// statistics_cron() will subtract

View file

@ -36,7 +36,7 @@ class StatisticsLoggingTest extends WebTestBase {
/**
* The Guzzle HTTP client.
*
* @var \GuzzleHttp\ClientInterface;
* @var \GuzzleHttp\Client;
*/
protected $client;
@ -61,8 +61,8 @@ class StatisticsLoggingTest extends WebTestBase {
// Clear the logs.
db_truncate('node_counter');
$this->client = \Drupal::httpClient();
$this->client->setDefaultOption('config/curl', array(CURLOPT_TIMEOUT => 10));
$this->client = \Drupal::service('http_client_factory')
->fromOptions(['config/curl' => [CURLOPT_TIMEOUT => 10]]);
}
/**
@ -94,7 +94,7 @@ class StatisticsLoggingTest extends WebTestBase {
// Manually call statistics.php to simulate ajax data collection behavior.
$nid = $this->node->id();
$post = array('nid' => $nid);
$this->client->post($stats_path, array('body' => $post));
$this->client->post($stats_path, array('form_params' => $post));
$node_counter = statistics_get($this->node->id());
$this->assertIdentical($node_counter['totalcount'], '1');
}

View file

@ -30,8 +30,8 @@ class StatisticsReportsTest extends StatisticsTestBase {
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$client = \Drupal::httpClient();
$client->setDefaultOption('config/curl', array(CURLOPT_TIMEOUT => 10));
$client = \Drupal::service('http_client_factory')
->fromOptions(['config/curl' => [CURLOPT_TIMEOUT => 10]]);
$client->post($stats_path, array('headers' => $headers, 'body' => $post));
// Configure and save the block.

View file

@ -33,8 +33,8 @@ class StatisticsTokenReplaceTest extends StatisticsTestBase {
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$client = \Drupal::httpClient();
$client->setDefaultOption('config/curl', array(CURLOPT_TIMEOUT => 10));
$client = \Drupal::service('http_client_factory')
->fromOptions(['config/curl' => [CURLOPT_TIMEOUT => 10]]);
$client->post($stats_path, array('headers' => $headers, 'body' => $post));
$statistics = statistics_get($node->id());

View file

@ -76,9 +76,8 @@ class IntegrationTest extends ViewTestBase {
// @see \Drupal\statistics\Tests\StatisticsLoggingTest::testLogging().
global $base_url;
$stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php';
$client = \Drupal::httpClient();
$client->setDefaultOption('config/curl', array(CURLOPT_TIMEOUT => 10));
$client->post($stats_path, array('body' => array('nid' => $this->node->id())));
$client = \Drupal::service('http_client_factory')->fromOptions(['config/curl', array(CURLOPT_TIMEOUT => 10)]);
$client->post($stats_path, array('form_params' => array('nid' => $this->node->id())));
$this->drupalGet('test_statistics_integration');
$expected = statistics_get($this->node->id());

View file

@ -5,6 +5,8 @@
* Builds placeholder replacement tokens for node visitor statistics.
*/
use Drupal\Core\Render\BubbleableMetadata;
/**
* Implements hook_token_info().
*/
@ -31,7 +33,7 @@ function statistics_token_info() {
/**
* Implements hook_tokens().
*/
function statistics_tokens($type, $tokens, array $data = array(), array $options = array()) {
function statistics_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$token_service = \Drupal::token();
$replacements = array();
@ -56,7 +58,7 @@ function statistics_tokens($type, $tokens, array $data = array(), array $options
if ($created_tokens = $token_service->findWithPrefix($tokens, 'last-view')) {
$statistics = statistics_get($node->id());
$replacements += $token_service->generate('date', $created_tokens, array('date' => $statistics['timestamp']), $options);
$replacements += $token_service->generate('date', $created_tokens, array('date' => $statistics['timestamp']), $options, $bubbleable_metadata);
}
}