-
Notifications
You must be signed in to change notification settings - Fork 39
/
ServerGeneralExampleTest.php
50 lines (41 loc) · 1.41 KB
/
ServerGeneralExampleTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Drupal\Tests\server_general\ExistingSite;
use Drupal\taxonomy\Entity\Vocabulary;
/**
* A model test case using traits from Drupal Test Traits.
*/
class ServerGeneralExampleTest extends ServerGeneralTestBase {
/**
* An example test method; note that Drupal API's and Mink are available.
*
* @throws \Drupal\Core\Entity\EntityStorageException
* @throws \Drupal\Core\Entity\EntityMalformedException
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testNews() {
// Creates a user. Will be automatically cleaned up at the end of the test.
$author = $this->createUser();
// Create a taxonomy term. Will be automatically cleaned up at the end of
// the test.
$vocab = Vocabulary::load('tags');
$term = $this->createTerm($vocab);
// Create a "Llama" article. Will be automatically cleaned up at end of
// test.
$node = $this->createNode([
'title' => 'Llama',
'type' => 'news',
'field_tags' => [
'target_id' => $term->id(),
],
'uid' => $author->id(),
'moderation_state' => 'published',
]);
$this->assertEquals($author->id(), $node->getOwnerId());
// We can browse pages.
$this->drupalGet($node->toUrl());
$this->assertSession()->statusCodeEquals(200);
// We can login and browse admin pages.
$this->drupalLogin($author);
$this->drupalGet($node->toUrl('edit-form'));
}
}