function ContentEntityExampleTest::testPaths
Same name in other branches
- 3.x modules/content_entity_example/tests/src/Functional/ContentEntityExampleTest.php \Drupal\Tests\content_entity_example\Functional\ContentEntityExampleTest::testPaths()
- 8.x-1.x content_entity_example/tests/src/Functional/ContentEntityExampleTest.php \Drupal\Tests\content_entity_example\Functional\ContentEntityExampleTest::testPaths()
Test all paths exposed by the module, by permission.
File
-
modules/
content_entity_example/ tests/ src/ Functional/ ContentEntityExampleTest.php, line 118
Class
- ContentEntityExampleTest
- Tests the basic functions of the Content Entity Example module.
Namespace
Drupal\Tests\content_entity_example\FunctionalCode
public function testPaths() {
$assert = $this->assertSession();
// Generate a contact so that we can test the paths against it.
$contact = Contact::create([
'name' => 'Smith',
'first_name' => 'Joe',
'role' => 'administrator',
]);
$contact->save();
// Gather the test data.
$data = $this->providerTestPaths($contact->id());
// Run the tests.
foreach ($data as $datum) {
// drupalCreateUser() doesn't know what to do with an empty permission
// array, so we help it out.
if ($datum[2]) {
$user = $this->drupalCreateUser([
$datum[2],
]);
$this->drupalLogin($user);
}
else {
$user = $this->drupalCreateUser();
$this->drupalLogin($user);
}
$this->drupalGet($datum[1]);
$assert->statusCodeEquals($datum[0]);
}
}