TaxonomyBehaviorSettingsFormTest.php in Rabbit Hole 8
File
modules/rh_taxonomy/tests/src/Functional/TaxonomyBehaviorSettingsFormTest.php
View source
<?php
namespace Drupal\Tests\rh_taxonomy\Functional;
use Drupal\Core\Url;
use Drupal\Tests\rabbit_hole\Functional\RabbitHoleBehaviorSettingsFormTestBase;
use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait;
class TaxonomyBehaviorSettingsFormTest extends RabbitHoleBehaviorSettingsFormTestBase {
use TaxonomyTestTrait;
protected $bundle;
protected $entityType = 'taxonomy_term';
protected $bundleEntityTypeName = 'taxonomy_vocabulary';
public static $modules = [
'rh_taxonomy',
'taxonomy',
];
protected function createEntityBundle() {
$this->bundle = $this
->createVocabulary();
return $this->bundle
->id();
}
protected function createEntityBundleFormSubmit($action, $override) {
$this
->drupalLogin($this->adminUser);
$edit = [
'name' => $this
->randomString(),
'vid' => mb_strtolower($this
->randomMachineName()),
'rh_action' => $action,
'rh_override' => $override,
];
$this
->drupalGet('/admin/structure/taxonomy/add');
$this
->assertRabbitHoleSettings();
$this
->submitForm($edit, 'Save');
$this->bundle = $this
->loadBundle($edit['vid']);
return $edit['vid'];
}
protected function createEntity($action = NULL) {
$values = [];
if (isset($action)) {
$values['rh_action'] = $action;
}
return $this
->createTerm($this->bundle, $values)
->id();
}
protected function getCreateEntityUrl() {
return Url::fromRoute('entity.taxonomy_term.add_form', [
'taxonomy_vocabulary' => $this->bundle
->id(),
]);
}
protected function getEditEntityUrl($id) {
return Url::fromRoute('entity.taxonomy_term.edit_form', [
'taxonomy_term' => $id,
]);
}
protected function getEditBundleUrl($bundle) {
return Url::fromRoute('entity.taxonomy_vocabulary.edit_form', [
'taxonomy_vocabulary' => $bundle,
]);
}
protected function getAdminPermissions() {
return [
'administer taxonomy',
'access taxonomy overview',
];
}
}