You are here

public function UnsupportedFileSchemeTest::testFileSchemeEligibility in Acquia Content Hub 8.2

Tests file scheme eligibility.

Throws

\Exception

File

modules/acquia_contenthub_publisher/tests/src/Unit/EventSubscriber/EntityEligibility/UnsupportedFileSchemeTest.php, line 27

Class

UnsupportedFileSchemeTest
Tests unsupported file schemes.

Namespace

Drupal\Tests\acquia_contenthub_publisher\Unit\EventSubscriber\EntityEligibility

Code

public function testFileSchemeEligibility() {

  // Setup our files for testing.
  $supported_file = $this
    ->prophesize(FileInterface::class);
  $unsupported_file = $this
    ->prophesize(FileInterface::class);

  // Setup our manager's response to our files.
  $manager = $this
    ->prophesize(FileSchemeHandlerManagerInterface::class);
  $manager
    ->isSupportedFileScheme($supported_file
    ->reveal())
    ->willReturn(TRUE);
  $manager
    ->isSupportedFileScheme($unsupported_file
    ->reveal())
    ->willReturn(FALSE);

  // This is the thing we're actually going to test.
  $subscriber = new FileSchemeIsSupported($manager
    ->reveal());

  // Test supported files.
  $supported_event = new ContentHubEntityEligibilityEvent($supported_file
    ->reveal(), 'insert');
  $subscriber
    ->onEnqueueCandidateEntity($supported_event);
  $this
    ->assertTrue($supported_event
    ->getEligibility());

  // Test unsupported files.
  $unsupported_event = new ContentHubEntityEligibilityEvent($unsupported_file
    ->reveal(), 'insert');
  $subscriber
    ->onEnqueueCandidateEntity($unsupported_event);
  $this
    ->assertFalse($unsupported_event
    ->getEligibility());
}