NodeTypeFormTest.php in Node Option Premium 8
File
tests/src/Functional/Form/NodeTypeFormTest.php
View source
<?php
namespace Drupal\Tests\nopremium\Functional\Form;
use Drupal\Tests\nopremium\Functional\NopremiumBrowserTestBase;
class NodeTypeFormTest extends NopremiumBrowserTestBase {
public function testWithNewContentType() {
$this
->drupalLogin($this->admin);
$edit = [
'name' => 'Foo',
'type' => 'foo',
'options[premium]' => TRUE,
];
$this
->drupalPostForm('admin/structure/types/add', $edit, 'Save content type');
$config = $this
->config('core.base_field_override.node.foo.premium');
$this
->assertEquals(TRUE, $config
->get('default_value')[0]['value']);
}
public function testWithExistingContentType() {
$this
->drupalLogin($this->admin);
$this
->drupalCreateContentType([
'type' => 'foo',
]);
$config = $this
->config('core.base_field_override.node.foo.premium');
$this
->assertNull($config
->get('default_value'));
$edit = [
'options[premium]' => TRUE,
];
$this
->drupalPostForm('admin/structure/types/manage/foo', $edit, 'Save content type');
$config = $this
->config('core.base_field_override.node.foo.premium');
$this
->assertEquals(TRUE, $config
->get('default_value')[0]['value']);
}
}