public function ViewsBaseUrlFieldTest::setUp in Views base url 8
Same name and namespace in other branches
- 2.0.x tests/src/Functional/ViewsBaseUrlFieldTest.php \Drupal\Tests\views_base_url\Functional\ViewsBaseUrlFieldTest::setUp()
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ ViewsBaseUrlFieldTest.php, line 81
Class
- ViewsBaseUrlFieldTest
- Basic test for views base url.
Namespace
Drupal\Tests\views_base_url\FunctionalCode
public function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'create article content',
]);
$random = new Random();
/** @var \Drupal\Core\Path\AliasStorageInterface $path_alias_storage */
$path_alias_storage = $this->container
->get('path.alias_storage');
/** @var \Drupal\Core\Path\AliasStorageInterface $path_alias_storage */
$this->pathAliasManager = $this->container
->get('path.alias_manager');
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$this->fileSystem = $this->container
->get('file_system');
// Create $this->nodeCount nodes.
$this
->drupalLogin($this->adminUser);
for ($i = 1; $i <= $this->nodeCount; $i++) {
// Create node.
$title = $random
->name();
$image = current($this
->drupalGetTestFiles('image'));
$edit = [
'title[0][value]' => $title,
'files[field_image_0]' => $this->fileSystem
->realpath($image->uri),
];
$this
->drupalPostForm('node/add/article', $edit, t('Save'));
$this
->drupalPostForm(NULL, [
'field_image[0][alt]' => $title,
], t('Save'));
$this->nodes[$i] = $this
->drupalGetNodeByTitle($title);
$path_alias_storage
->save('/node/' . $this->nodes[$i]
->id(), "/content/{$title}");
}
$this
->drupalLogout();
}