UploadBrowseTest.php in Mini site 8
File
tests/src/Functional/UploadBrowseTest.php
View source
<?php
namespace Drupal\Tests\minisite\Functional;
class UploadBrowseTest extends MinisiteTestBase {
protected static $modules = [
'block',
];
protected function setUp() {
parent::setUp();
$this
->drupalPlaceBlock('system_breadcrumb_block');
}
public function testUploadAndBrowsing() {
$test_archive_assets = array_keys($this
->getTestFilesStubValid());
$node_title = $this
->randomMachineName();
$field_name = $this
->createFieldAndNode($this->contentType, $node_title);
$node = $this
->drupalGetNodeByTitle($node_title);
$nid = $node
->id();
$this
->assertMinisiteUploaded($node, $field_name, $test_archive_assets);
$test_archive = $this
->getUploadedArchiveFile($node, $field_name);
$this
->browseFixtureMinisite($node, $test_archive
->getFilename());
$this
->drupalPostForm("node/{$nid}/delete", [], $this
->t('Delete'));
$this
->assertResponse(200);
$this
->assertMinisiteRemoved($node, $field_name, $test_archive_assets);
}
public function testUploadAndRemoval() {
$test_archive_assets = array_keys($this
->getTestFilesStubValid());
$node_title = $this
->randomMachineName();
$field_name = $this
->createFieldAndNode($this->contentType, $node_title);
$node = $this
->drupalGetNodeByTitle($node_title);
$nid = $node
->id();
$this
->assertMinisiteUploaded($node, $field_name, $test_archive_assets);
$test_archive = $this
->getUploadedArchiveFile($node, $field_name);
$this
->browseFixtureMinisite($node, $test_archive
->getFilename());
$this
->drupalPostForm("node/{$nid}/edit", [], $this
->t('Remove'));
$this
->drupalPostForm(NULL, [], $this
->t('Save'));
$this
->assertResponse(200);
$this
->assertMinisiteRemoved($node, $field_name, $test_archive_assets);
}
}