You are here

class InstallFunctionsTest in Flysystem 3.0.x

Same name and namespace in other branches
  1. 8 tests/src/Unit/InstallFunctionsTest.php \Drupal\Tests\flysystem\Unit\InstallFunctionsTest
  2. 3.x tests/src/Unit/InstallFunctionsTest.php \Drupal\Tests\flysystem\Unit\InstallFunctionsTest
  3. 2.0.x tests/src/Unit/InstallFunctionsTest.php \Drupal\Tests\flysystem\Unit\InstallFunctionsTest

Tests flysystem.install functions.

@group flysystem

Hierarchy

Expanded class hierarchy of InstallFunctionsTest

File

tests/src/Unit/InstallFunctionsTest.php, line 17

Namespace

Drupal\Tests\flysystem\Unit
View source
class InstallFunctionsTest extends UnitTestCase {

  /**
   * The Flysystem factory prophecy object.
   *
   * @var \Prophecy\Prophecy\ObjectProphecy
   */
  protected $factory;

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    if (!defined('REQUIREMENT_ERROR')) {
      define('REQUIREMENT_ERROR', 2);
    }
    require_once dirname(dirname(dirname(__DIR__))) . '/flysystem.install';
    $this->factory = $this
      ->prophesize(FlysystemFactory::class);
    $container = new ContainerBuilder();
    $container
      ->set('flysystem_factory', $this->factory
      ->reveal());
    $container
      ->set('string_translation', $this
      ->getStringTranslationStub());
    \Drupal::setContainer($container);
  }

  /**
   * Tests flysystem_requirements() handles update.
   */
  public function testFlysystemRequirementsHandlesUpdate() {
    $dependencies_exist = (int) class_exists(FlysystemStreamWrapper::class);
    $return = flysystem_requirements('update');
    $this
      ->assertSame(1 - $dependencies_exist, count($return));
  }

  /**
   * Tests flysystem_requirements() handles install.
   */
  public function testFlysystemRequirementsHandlesInstall() {
    $dependencies_exist = (int) class_exists(FlysystemStreamWrapper::class);
    $return = flysystem_requirements('install');
    $this
      ->assertSame(1 - $dependencies_exist, count($return));
  }

  /**
   * Tests flysystem_requirements() handles runtime.
   */
  public function testFlysystemRequirementsHandlesRuntime() {
    $dependencies_exist = (int) class_exists(FlysystemStreamWrapper::class);
    $this->factory
      ->ensure()
      ->willReturn([
      'testscheme' => [
        [
          'message' => 'Test message',
          'context' => [],
          'severity' => RfcLogLevel::ERROR,
        ],
      ],
    ]);
    $return = flysystem_requirements('runtime');
    $this
      ->assertSame(2 - $dependencies_exist, count($return));
    $this
      ->assertSame('Test message', (string) $return['flysystem:testscheme']['description']);
  }

  /**
   * Tests flysystem_requirements() detects invalid schemes.
   */
  public function testFlysystemRequirementsHandlesInvalidSchemes() {
    new Settings([
      'flysystem' => [
        'test_scheme' => [],
      ],
    ]);
    $requirements = flysystem_requirements('update');
    $this
      ->assertTrue(isset($requirements['flysystem_invalid_scheme']));
  }

  /**
   * Tests flysystem_install() calls ensure().
   */
  public function testFlysystemInstallCallsEnsure() {
    $this->factory
      ->ensure()
      ->shouldBeCalled();
    flysystem_install();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
InstallFunctionsTest::$factory protected property The Flysystem factory prophecy object.
InstallFunctionsTest::setUp public function Overrides UnitTestCase::setUp
InstallFunctionsTest::testFlysystemInstallCallsEnsure public function Tests flysystem_install() calls ensure().
InstallFunctionsTest::testFlysystemRequirementsHandlesInstall public function Tests flysystem_requirements() handles install.
InstallFunctionsTest::testFlysystemRequirementsHandlesInvalidSchemes public function Tests flysystem_requirements() detects invalid schemes.
InstallFunctionsTest::testFlysystemRequirementsHandlesRuntime public function Tests flysystem_requirements() handles runtime.
InstallFunctionsTest::testFlysystemRequirementsHandlesUpdate public function Tests flysystem_requirements() handles update.
PhpUnitWarnings::$deprecationWarnings private static property Deprecation warnings from PHPUnit to raise with @trigger_error().
PhpUnitWarnings::addWarning public function Converts PHPUnit deprecation warnings to E_USER_DEPRECATED.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals Deprecated protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUpBeforeClass public static function