You are here

public function AssetTest::testLoadAll in Mini site 8

Test Asset::save().

@covers \Drupal\minisite\Asset::loadAll

File

tests/src/Functional/AssetTest.php, line 242

Class

AssetTest
Class AssetTest.

Namespace

Drupal\Tests\minisite\Functional

Code

public function testLoadAll() {
  $asset1 = new Asset('node', $this->contentType, 1, Language::LANGCODE_DEFAULT, 'field_minisite_test', $this
    ->getStubAssetPath());
  $asset1
    ->save();
  $asset2 = new Asset('node', $this->contentType, 1, Language::LANGCODE_DEFAULT, 'field_minisite_test', $this
    ->getStubAssetPath());
  $asset2
    ->save();
  $asset3 = new Asset('node', $this->contentType, 1, Language::LANGCODE_DEFAULT, 'field_minisite_test', $this
    ->getStubAssetPath());
  $asset3
    ->save();
  $loaded = Asset::loadAll();
  $this
    ->assertEquals(3, count($loaded));
  $this
    ->assertEquals($asset3
    ->id(), $loaded[0]
    ->id());
  $this
    ->assertEquals($asset2
    ->id(), $loaded[1]
    ->id());
  $this
    ->assertEquals($asset1
    ->id(), $loaded[2]
    ->id());
}