AdminTest.php in Background Image 8
File
tests/src/Functional/AdminTest.php
View source
<?php
namespace Drupal\Tests\background_image\Functional;
class AdminTest extends BackgroundImageTestBase {
public static $modules = [
'user',
'node',
'field',
'image',
'options',
'background_image',
];
protected $adminUser;
protected function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'administer background image',
'add background image',
'edit background image',
]);
}
public function testListAddEdit() {
$collection = 'admin/config/media/background_image';
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($collection);
$this
->assertSession()
->pageTextContains('There are no background images to display.');
$label = 'Global label';
$this
->addImageForm(-1, $label);
$files = $this
->drupalGetTestFiles('image');
$file = \Drupal::service('file_system')
->realpath($files[0]->uri);
$edit = [
'files[image_0]' => $file,
];
$this
->drupalPostForm(NULL, $edit, t('Save'));
$session = $this
->assertSession();
$session
->pageTextContains("The background image {$label} has been added.");
$session
->pageTextContains("Global: {$label}");
$this
->drupalGet('admin/config/media/background_image/1/edit');
$session = $this
->assertSession();
$session
->statusCodeEquals(200);
$session
->pageTextContains("Global: {$label}");
}
}
Classes
Name |
Description |
AdminTest |
Tests adding image and viewing them through UI. |