class InstallFunctionsTest in Flysystem 8
Same name and namespace in other branches
- 3.x tests/src/Unit/InstallFunctionsTest.php \Drupal\Tests\flysystem\Unit\InstallFunctionsTest
- 2.0.x tests/src/Unit/InstallFunctionsTest.php \Drupal\Tests\flysystem\Unit\InstallFunctionsTest
- 3.0.x tests/src/Unit/InstallFunctionsTest.php \Drupal\Tests\flysystem\Unit\InstallFunctionsTest
Tests flysystem.install functions.
@group flysystem
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\flysystem\Unit\InstallFunctionsTest
Expanded class hierarchy of InstallFunctionsTest
File
- tests/
src/ Unit/ InstallFunctionsTest.php, line 18
Namespace
Drupal\Tests\flysystem\UnitView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InstallFunctionsTest:: |
protected | property | The Flysystem factory prophecy object. | |
InstallFunctionsTest:: |
public | function |
Overrides UnitTestCase:: |
|
InstallFunctionsTest:: |
public | function | Tests flysystem_install() calls ensure(). | |
InstallFunctionsTest:: |
public | function | Tests flysystem_requirements() handles install. | |
InstallFunctionsTest:: |
public | function | Tests flysystem_requirements() detects invalid schemes. | |
InstallFunctionsTest:: |
public | function | Tests flysystem_requirements() handles runtime. | |
InstallFunctionsTest:: |
public | function | Tests flysystem_requirements() handles update. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |