EdgescapeTest.php in Akamai 8.3
File
tests/src/Functional/EdgescapeTest.php
View source
<?php
namespace Drupal\Tests\akamai\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\akamai\Helper\Edgescape;
use Drupal\block_content\Entity\BlockContent;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\Core\Url;
class EdgescapeTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'akamai',
'token',
'block',
'block_content',
];
public function testTokenOutputFromHeader() {
$user = $this
->drupalCreateUser([
'administer blocks',
'administer akamai',
]);
$this
->drupalLogin($user);
$akamai_config_path = Url::fromRoute('akamai.settings')
->getInternalPath();
$edit[Edgescape::EDGESCAPE_SUPPORT] = TRUE;
$this
->drupalPostForm($akamai_config_path, $edit, t('Save configuration'));
$label = 'tokenblock';
$bundle = BlockContentType::create([
'id' => $label,
'label' => $label,
'revision' => FALSE,
]);
$bundle
->save();
$block_content = BlockContent::create([
'type' => $label,
'label' => '',
'info' => 'Test token title block',
'body[value]' => 'This is the test token title block.',
]);
$block_content
->save();
$block = $this
->drupalPlaceBlock('block_content:' . $block_content
->uuid(), [
'label' => 'Country Code: [akamai:edgescape:country_code]',
]);
$header_value = 'country_code=RAX,continent=NA';
$this
->drupalGet($akamai_config_path, [], [
Edgescape::EDGESCAPE_HEADER => $header_value,
]);
$this
->assertRaw('Country Code: RAX');
}
}