GoogleAnalyticsCounterSettingsTest.php in Google Analytics Counter 8.3
File
tests/src/Functional/GoogleAnalyticsCounterSettingsTest.php
View source
<?php
namespace Drupal\Tests\google_analytics_counter\Functional;
use Drupal\Tests\BrowserTestBase;
class GoogleAnalyticsCounterSettingsTest extends BrowserTestBase {
const ADMIN_SETTINGS_PATH = 'admin/config/system/google-analytics-counter';
protected $adminUser;
public static $modules = [
'system',
'node',
];
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
}
public function testGoogleAnalyticsCounterSettingsForm() {
$this->container
->get('module_installer')
->install([
'google_analytics_counter',
]);
$this
->resetAll();
$this
->config('google_analytics_counter.settings')
->set('general_settings.gac_type_page', 1)
->save();
$this->adminUser = $this
->drupalCreateUser([
'administer site configuration',
'administer google analytics counter',
]);
$this
->drupalLogin($this->adminUser);
$queue_name = 'google_analytics_counter_worker';
$queue = \Drupal::queue($queue_name);
$queue
->createItem([
$this
->randomMachineName() => $this
->randomMachineName(),
]);
$this
->drupalGet(self::ADMIN_SETTINGS_PATH);
$assert = $this
->assertSession();
$assert
->statusCodeEquals(200);
$assert
->fieldExists('cron_interval');
$assert
->fieldExists('chunk_to_fetch');
$assert
->fieldExists('api_dayquota');
$assert
->fieldExists('cache_length');
$assert
->fieldExists('queue_time');
$assert
->fieldExists('start_date');
$assert
->fieldExists('custom_start_date');
$assert
->fieldExists('custom_end_date');
$edit = [
'cron_interval' => 0,
'chunk_to_fetch' => 5000,
'api_dayquota' => 50000,
'cache_length' => 24,
];
$this
->submitForm($edit, t('Save configuration'));
$assert
->pageTextContains(t('The configuration options have been saved.'));
}
}