AkamaiCacheControlFormTest.php in Akamai 8.3
File
src/Tests/AkamaiCacheControlFormTest.php
View source
<?php
namespace Drupal\akamai\Tests;
use Drupal\Tests\BrowserTestBase;
class AkamaiCacheControlFormTest extends BrowserTestBase {
protected $node;
protected $privilegedUser;
public static $modules = [
'system_test',
'node',
'user',
'akamai',
];
protected function setUp() {
parent::setUp();
$this->privilegedUser = $this
->drupalCreateUser([
'administer akamai',
'purge akamai cache',
]);
$this
->drupalLogin($this->privilegedUser);
$this
->drupalCreateContentType([
'type' => 'article',
]);
$this->node = $this
->drupalCreateNode([
'type' => 'article',
]);
$edit['basepath'] = 'http://www.example.com';
$this
->drupalPostForm('admin/config/akamai/config', $edit, t('Save configuration'));
}
public function testValidUrlPurging() {
$edit['paths'] = 'links';
$edit['domain_override'] = 'staging';
$edit['action'] = 'invalidate';
$edit['method'] = 'url';
$this
->drupalPostForm('admin/config/akamai/cache-clear', $edit, t('Start Refreshing Content'));
$this
->assertText(t('Please provide at least one valid URL for purging.'), 'Invalid URL rejected.');
$edit['paths'] = 'https://www.google.com';
$edit['domain_override'] = 'staging';
$edit['action'] = 'invalidate';
$edit['method'] = 'url';
$this
->drupalPostForm('admin/config/akamai/cache-clear', $edit, t('Start Refreshing Content'));
$this
->assertText(t('Please enter only relative paths, not full URLs'), 'External URL rejected.');
}
}