ViewUnpublishedDependencyTest.php in view_unpublished 8
File
tests/src/Kernel/ViewUnpublishedDependencyTest.php
View source
<?php
namespace Drupal\Tests\view_unpublished\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\views\Views;
class ViewUnpublishedDependencyTest extends KernelTestBase {
public static $modules = [
'field',
'node',
'system',
'text',
'user',
'view_unpublished',
'views',
];
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('user');
$this
->installEntitySchema('node');
$this
->installConfig('node');
}
public function testDependencyNotAdded() {
$module_deps = $this
->config('views.view.content')
->get('dependencies.module');
$this
->assertArrayNotHasKey('view_unpublished', array_flip($module_deps));
$view = Views::getView('content');
$view
->save();
$module_deps = $this
->config('views.view.content')
->get('dependencies.module');
$this
->assertArrayNotHasKey('view_unpublished', array_flip($module_deps));
}
public function testDependencyRemoved() {
$module_deps = $this
->config('views.view.content')
->get('dependencies.module');
$module_deps[] = 'view_unpublished';
$this
->config('views.view.content')
->set('dependencies.module', $module_deps)
->save(TRUE);
$this->container
->get('view_unpublished.install_helper')
->removeDependency();
$module_deps = $this
->config('views.view.content')
->get('dependencies.module');
$this
->assertNotEmpty($module_deps);
$this
->assertArrayNotHasKey('view_unpublished', array_flip($module_deps));
}
}