public function AssetInjectorJsTest::testJsInjector in Asset Injector 8.2
Test a created css injector is added to the page and the css file exists.
Throws
\Exception
File
- tests/
src/ Functional/ AssetInjectorJsTest.php, line 78
Class
- AssetInjectorJsTest
- Class AssetInjectorJsTest.
Namespace
Drupal\Tests\asset_injector\FunctionalCode
public function testJsInjector() {
$this
->testJsPermissionGranted();
$this
->drupalGet('admin/config/development/asset-injector/js/add');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains($this
->t('Code'));
$this
->submitForm([
'label' => $this
->t('Blocks'),
'id' => $this
->t('blocks'),
'code' => '.block {border:1px solid black;}',
], $this
->t('Save'));
$this
->getSession()
->getPage()
->hasContent('asset_injector/js/blocks');
/** @var \Drupal\asset_injector\Entity\AssetInjectorJs $asset */
foreach (asset_injector_get_assets(NULL, [
'asset_injector_js',
]) as $asset) {
$path = parse_url(file_create_url($asset
->internalFileUri()), PHP_URL_PATH);
$path = str_replace(base_path(), '/', $path);
$this
->drupalGet($path);
$this
->assertSession()
->statusCodeEquals(200);
}
}