You are here

public function PhotosAccessTest::checkAlbumAccess in Album Photos 8.5

Same name and namespace in other branches
  1. 6.0.x photos_access/tests/src/Functional/PhotosAccessTest.php \Drupal\Tests\photos\Functional\PhotosAccessTest::checkAlbumAccess()

Test access to photo album, photos node, photos_image and raw image file.

Parameters

\Drupal\photos\Entity\PhotosImage $photosImage: The photos_image entity.

int $viewCode: The expected response code.

int $editCode: The expected response code.

string $fileUrl: The image file URL to test.

1 call to PhotosAccessTest::checkAlbumAccess()
PhotosAccessTest::testAlbumPrivacySettings in photos_access/tests/src/Functional/PhotosAccessTest.php
Test album privacy settings.

File

photos_access/tests/src/Functional/PhotosAccessTest.php, line 325

Class

PhotosAccessTest
Test photos_access album privacy settings.

Namespace

Drupal\Tests\photos\Functional

Code

public function checkAlbumAccess(PhotosImage $photosImage, $viewCode = 200, $editCode = 403, $fileUrl = NULL) {
  if ($fileUrl) {
    $this
      ->drupalGet($fileUrl);
    $this
      ->assertResponse($viewCode);
  }

  // View image page.
  $this
    ->drupalGet('photos/' . $photosImage
    ->getAlbumId() . '/' . $photosImage
    ->id());
  $this
    ->assertResponse($viewCode);

  // Views album page.
  $this
    ->drupalGet('photos/views-test/' . $photosImage
    ->getAlbumId());
  $this
    ->assertResponse($viewCode);

  // View node page.
  $this
    ->drupalGet('node/' . $photosImage
    ->getAlbumId());
  $this
    ->assertResponse($viewCode);

  // Edit node page.
  $this
    ->drupalGet('node/' . $photosImage
    ->getAlbumId() . '/edit');
  $this
    ->assertResponse($editCode);
}