Update to Drupal 8.1.1. For more information, see https://www.drupal.org/node/2718713
This commit is contained in:
parent
c0a0d5a94c
commit
9eae24d844
669 changed files with 3873 additions and 1553 deletions
65
core/modules/forum/tests/src/Kernel/ForumValidationTest.php
Normal file
65
core/modules/forum/tests/src/Kernel/ForumValidationTest.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\forum\Kernel;
|
||||
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
|
||||
/**
|
||||
* Tests forum validation constraints.
|
||||
*
|
||||
* @group forum
|
||||
*/
|
||||
class ForumValidationTest extends EntityKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['node', 'options', 'comment', 'taxonomy', 'forum'];
|
||||
|
||||
/**
|
||||
* Tests the forum validation constraints.
|
||||
*/
|
||||
public function testValidation() {
|
||||
// Add a forum.
|
||||
$forum = Term::create([
|
||||
'name' => 'forum 1',
|
||||
'vid' => 'forums',
|
||||
'forum_container' => 0,
|
||||
]);
|
||||
|
||||
// Add a container.
|
||||
$container = Term::create([
|
||||
'name' => 'container 1',
|
||||
'vid' => 'forums',
|
||||
'forum_container' => 1,
|
||||
]);
|
||||
|
||||
// Add a forum post.
|
||||
$forum_post = Node::create([
|
||||
'type' => 'forum',
|
||||
'title' => 'Do these pants make my butt look big?',
|
||||
]);
|
||||
|
||||
$violations = $forum_post->validate();
|
||||
$this->assertEqual(count($violations), 1);
|
||||
$this->assertEqual($violations[0]->getMessage(), 'This value should not be null.');
|
||||
|
||||
// Add the forum term.
|
||||
$forum_post->set('taxonomy_forums', $forum);
|
||||
$violations = $forum_post->validate();
|
||||
$this->assertEqual(count($violations), 0);
|
||||
|
||||
// Try to use a container.
|
||||
$forum_post->set('taxonomy_forums', $container);
|
||||
$violations = $forum_post->validate();
|
||||
$this->assertEqual(count($violations), 1);
|
||||
$this->assertEqual($violations[0]->getMessage(), t('The item %forum is a forum container, not a forum. Select one of the forums below instead.', [
|
||||
'%forum' => $container->label(),
|
||||
]));
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue