updated core to 8.6.1 via composer
This commit is contained in:
+2
-2
@@ -5,5 +5,5 @@ package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- statistics
|
||||
- views
|
||||
- drupal:statistics
|
||||
- drupal:views
|
||||
|
||||
@@ -38,7 +38,7 @@ class StatisticsAdminTest extends BrowserTestBase {
|
||||
/**
|
||||
* The Guzzle HTTP client.
|
||||
*
|
||||
* @var \GuzzleHttp\Client;
|
||||
* @var \GuzzleHttp\Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class StatisticsAttachedTest extends BrowserTestBase {
|
||||
$node = Node::create([
|
||||
'type' => 'page',
|
||||
'title' => 'Page node',
|
||||
'body' => 'body text'
|
||||
'body' => 'body text',
|
||||
]);
|
||||
$node->save();
|
||||
$this->drupalGet('node/' . $node->id());
|
||||
|
||||
@@ -39,7 +39,7 @@ class StatisticsLoggingTest extends BrowserTestBase {
|
||||
/**
|
||||
* The Guzzle HTTP client.
|
||||
*
|
||||
* @var \GuzzleHttp\Client;
|
||||
* @var \GuzzleHttp\Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
@@ -125,7 +125,7 @@ class StatisticsLoggingTest extends BrowserTestBase {
|
||||
$post = ['nid' => $this->node->id()];
|
||||
$this->client->post($base_root . $stats_path, ['form_params' => $post]);
|
||||
$node_counter = statistics_get($this->node->id());
|
||||
$this->assertIdentical($node_counter['totalcount'], '1');
|
||||
$this->assertIdentical($node_counter['totalcount'], 1);
|
||||
|
||||
// Try fetching statistics for an invalid node ID and verify it returns
|
||||
// FALSE.
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Drupal\Tests\statistics\Functional;
|
||||
* @group statistics
|
||||
*/
|
||||
class StatisticsTokenReplaceTest extends StatisticsTestBase {
|
||||
|
||||
/**
|
||||
* Creates a node, then tests the statistics tokens generated from it.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\statistics\FunctionalJavascript;
|
||||
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\user\Entity\Role;
|
||||
|
||||
/**
|
||||
* Tests that statistics works.
|
||||
*
|
||||
* @group system
|
||||
*/
|
||||
class StatisticsLoggingTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'statistics', 'language'];
|
||||
|
||||
/**
|
||||
* Node for tests.
|
||||
*
|
||||
* @var \Drupal\node\Entity\Node
|
||||
*/
|
||||
protected $node;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->config('statistics.settings')
|
||||
->set('count_content_views', 1)
|
||||
->save();
|
||||
|
||||
Role::load(AccountInterface::ANONYMOUS_ROLE)
|
||||
->grantPermission('view post access counter')
|
||||
->save();
|
||||
|
||||
// Add another language to enable multilingual path processor.
|
||||
ConfigurableLanguage::create(['id' => 'xx'])->save();
|
||||
$this->config('language.negotiation')->set('url.prefixes.en', 'en')->save();
|
||||
|
||||
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
|
||||
$this->node = $this->drupalCreateNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that statistics works with different addressing variants.
|
||||
*/
|
||||
public function testLoggingPage() {
|
||||
// At the first request, the page does not contain statistics counter.
|
||||
$this->assertNull($this->getStatisticsCounter('node/1'));
|
||||
$this->assertSame(1, $this->getStatisticsCounter('node/1'));
|
||||
$this->assertSame(2, $this->getStatisticsCounter('en/node/1'));
|
||||
$this->assertSame(3, $this->getStatisticsCounter('en/node/1'));
|
||||
$this->assertSame(4, $this->getStatisticsCounter('index.php/node/1'));
|
||||
$this->assertSame(5, $this->getStatisticsCounter('index.php/node/1'));
|
||||
$this->assertSame(6, $this->getStatisticsCounter('index.php/en/node/1'));
|
||||
$this->assertSame(7, $this->getStatisticsCounter('index.php/en/node/1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets counter of views by path.
|
||||
*
|
||||
* @param string $path
|
||||
* A path to node.
|
||||
*
|
||||
* @return int|null
|
||||
* A counter of views. Returns NULL if the page does not contain statistics.
|
||||
*/
|
||||
protected function getStatisticsCounter($path) {
|
||||
$this->drupalGet($path);
|
||||
// Wait while statistics module send ajax request.
|
||||
$this->assertSession()->assertWaitOnAjaxRequest();
|
||||
// Resaving the node to call the hook_node_links_alter(), which is used to
|
||||
// update information on the page. See statistics_node_links_alter().
|
||||
$this->node->save();
|
||||
|
||||
$field_counter = $this->getSession()->getPage()->find('css', '.statistics-counter');
|
||||
return $field_counter ? (int) explode(' ', $field_counter->getText())[0] : NULL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,11 @@ class MigrateNodeCounterTest extends MigrateDrupal6TestBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'content_translation',
|
||||
'language',
|
||||
'menu_ui',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
'node',
|
||||
'statistics',
|
||||
'text',
|
||||
@@ -29,16 +33,20 @@ class MigrateNodeCounterTest extends MigrateDrupal6TestBase {
|
||||
|
||||
$this->installEntitySchema('node');
|
||||
$this->installConfig('node');
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->installSchema('statistics', ['node_counter']);
|
||||
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd6_filter_format',
|
||||
'd6_user_role',
|
||||
'd6_node_settings',
|
||||
'd6_user',
|
||||
'd6_node_type',
|
||||
'd6_language_content_settings',
|
||||
'd6_node',
|
||||
'statistics_node_counter'
|
||||
'd6_node_translation',
|
||||
'statistics_node_counter',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -51,6 +59,13 @@ class MigrateNodeCounterTest extends MigrateDrupal6TestBase {
|
||||
$this->assertNodeCounter(3, 1, 0, 1471428153);
|
||||
$this->assertNodeCounter(4, 1, 1, 1478755275);
|
||||
$this->assertNodeCounter(5, 1, 1, 1478755314);
|
||||
$this->assertNodeCounter(10, 5, 1, 1521137459);
|
||||
$this->assertNodeCounter(12, 3, 0, 1521137469);
|
||||
|
||||
// Tests that translated node counts include all translation counts.
|
||||
$this->executeMigration('statistics_node_translation_counter');
|
||||
$this->assertNodeCounter(10, 8, 2, 1521137463);
|
||||
$this->assertNodeCounter(12, 5, 1, 1521137470);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,11 @@ class MigrateNodeCounterTest extends MigrateDrupal7TestBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'content_translation',
|
||||
'language',
|
||||
'menu_ui',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
'node',
|
||||
'statistics',
|
||||
'text',
|
||||
@@ -29,14 +33,18 @@ class MigrateNodeCounterTest extends MigrateDrupal7TestBase {
|
||||
|
||||
$this->installEntitySchema('node');
|
||||
$this->installConfig('node');
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->installSchema('statistics', ['node_counter']);
|
||||
|
||||
$this->executeMigrations([
|
||||
'language',
|
||||
'd7_user_role',
|
||||
'd7_user',
|
||||
'd7_node_type',
|
||||
'd7_language_content_settings',
|
||||
'd7_node',
|
||||
'statistics_node_counter'
|
||||
'd7_node_translation',
|
||||
'statistics_node_counter',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -47,6 +55,11 @@ class MigrateNodeCounterTest extends MigrateDrupal7TestBase {
|
||||
$this->assertNodeCounter(1, 2, 0, 1421727536);
|
||||
$this->assertNodeCounter(2, 1, 0, 1471428059);
|
||||
$this->assertNodeCounter(4, 1, 1, 1478755275);
|
||||
|
||||
// Tests that translated node counts include all translation counts.
|
||||
$this->executeMigration('statistics_node_translation_counter');
|
||||
$this->assertNodeCounter(2, 2, 0, 1471428153);
|
||||
$this->assertNodeCounter(4, 2, 2, 1478755314);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\statistics\Unit;
|
||||
|
||||
use Drupal\statistics\StatisticsViewsResult;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\statistics\StatisticsViewsResult
|
||||
* @group statistics
|
||||
*/
|
||||
class StatisticsViewsResultTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests migration of node counter.
|
||||
*
|
||||
* @covers ::__construct
|
||||
*
|
||||
* @dataProvider providerTestStatisticsCount
|
||||
*/
|
||||
public function testStatisticsCount($total_count, $day_count, $timestamp) {
|
||||
$statistics = new StatisticsViewsResult($total_count, $day_count, $timestamp);
|
||||
$this->assertSame((int) $total_count, $statistics->getTotalCount());
|
||||
$this->assertSame((int) $day_count, $statistics->getDayCount());
|
||||
$this->assertSame((int) $timestamp, $statistics->getTimestamp());
|
||||
}
|
||||
|
||||
public function providerTestStatisticsCount() {
|
||||
return [
|
||||
[2, 0, 1421727536],
|
||||
[1, 0, 1471428059],
|
||||
[1, 1, 1478755275],
|
||||
['1', '1', '1478755275'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user