IpAnonymizeTestCase.php in IP Anonymize 8
File
tests/src/Functional/IpAnonymizeTestCase.php
View source
<?php
namespace Drupal\Tests\ip_anon\Functional;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\Traits\Core\CronRunTrait;
class IpAnonymizeTestCase extends BrowserTestBase {
use CronRunTrait;
use StringTranslationTrait;
protected $defaultTheme = 'stark';
public static $modules = [
'ip_anon',
'dblog',
];
public function testIpAnonymize() {
$admin_user = $this
->drupalCreateUser([
'administer site configuration',
]);
$this
->drupalLogin($admin_user);
$this
->assertNotEmpty($this
->getIp());
$this
->drupalGet('admin/config/people/ip_anon');
$config['policy'] = 1;
$config['period_watchdog'] = 0;
$this
->submitForm($config, $this
->t('Save configuration'));
$this
->cronRun();
$this
->assertEmpty($this
->getIp());
}
protected function getIp() {
return $this->container
->get('database')
->select('watchdog', 'w')
->fields('w', [
'hostname',
])
->orderBy('wid')
->range(0, 1)
->execute()
->fetchField();
}
}