Example1Test.php in Decoupled Blocks: Vue.js 8
File
tests/src/Functional/Example1Test.php
View source
<?php
namespace Drupal\Tests\pdb_vue\Functional;
use Drupal\Tests\BrowserTestBase;
class Example1Test extends BrowserTestBase {
public static $modules = [
'block',
'pdb',
'pdb_vue',
];
protected $defaultTheme = 'stark';
public function testNoExamplesInProductionMode() {
$assert = $this
->assertSession();
$this
->drupalLogin($this
->drupalCreateUser([
'access administration pages',
'administer blocks',
]));
$this
->drupalGet('admin/structure/block/library/stark');
$assert
->responseContains('Place block');
$assert
->responseNotContains('Vue');
}
public function testExample1BlockAppears() {
$assert = $this
->assertSession();
$config = $this
->config('pdb_vue.settings');
$config
->set('version', 'vue2');
$config
->set('development_mode', TRUE);
$config
->save();
$this
->drupalLogin($this
->drupalCreateUser([
'access administration pages',
'administer blocks',
]));
$this
->drupalGet('admin/structure/block/library/stark');
$assert
->responseContains('Vue Example 1');
$this
->drupalPlaceBlock('vue_component:vue_example_1');
$this
->drupalGet('<front>');
$assert
->responseContains('vue-example-1');
$assert
->responseContains('//cdnjs.cloudflare.com/ajax/libs/vue/');
$assert
->responseContains('vue-example-1.js');
}
public function testExample1V3BlockAppears() {
$assert = $this
->assertSession();
$config = $this
->config('pdb_vue.settings');
$config
->set('version', 'vue3');
$config
->set('development_mode', TRUE);
$config
->save();
$this
->drupalLogin($this
->drupalCreateUser([
'access administration pages',
'administer blocks',
]));
$this
->drupalGet('admin/structure/block/library/stark');
$assert
->responseContains('Vue3 Example 1');
$this
->drupalPlaceBlock('vue_component:vue3_example_1');
$this
->drupalGet('<front>');
$assert
->responseContains('vue3-example-1');
$assert
->responseContains('//cdn.jsdelivr.net/npm/vue@3');
$assert
->responseContains('vue3-example-1.js');
}
}