public function CreatePhotosAlbumTest::testCreatePhotosAlbum in Album Photos 8.4
Same name and namespace in other branches
- 8.5 tests/src/Kernel/CreatePhotosAlbumTest.php \Drupal\Tests\photos\Kernel\CreatePhotosAlbumTest::testCreatePhotosAlbum()
- 6.0.x tests/src/Kernel/CreatePhotosAlbumTest.php \Drupal\Tests\photos\Kernel\CreatePhotosAlbumTest::testCreatePhotosAlbum()
Tests creating a photo album node.
File
- tests/
src/ Kernel/ CreatePhotosAlbumTest.php, line 60
Class
- CreatePhotosAlbumTest
- Tests creating photo album node.
Namespace
Drupal\Tests\photos\KernelCode
public function testCreatePhotosAlbum() {
$user = $this
->createUser();
$container = \Drupal::getContainer();
$container
->get('current_user')
->setAccount($user);
// Create a test node.
$albumTitle = $this
->randomMachineName();
$album = Node::create([
'type' => 'photos',
'title' => $albumTitle,
'language' => 'en',
]);
$album
->save();
// Test PhotosAlbum::userAlbumOptions.
$choice = new \stdClass();
$choice->option = [
$album
->id() => $albumTitle,
];
$testOutput[$album
->id()] = $choice;
$albumOptions = PhotosAlbum::userAlbumOptions($user
->id(), 0);
$this
->assertSame($albumOptions[$album
->id()]->option, $testOutput[$album
->id()]->option);
}