function DiskSpaceValidatorTest::testDiskSpaceValidation

Tests disk space validation.

@dataProvider providerDiskSpaceValidation

Parameters

bool $shared_disk: Whether the root and vendor directories are on the same logical disk.

array $free_space: The free space that should be reported for various paths. The keys are the paths, and the values are the free space that should be reported, in a format that can be parsed by \Drupal\Component\Utility\Bytes::toNumber().

\Drupal\package_manager\ValidationResult[] $expected_results: The expected validation results.

File

core/modules/package_manager/tests/src/Kernel/DiskSpaceValidatorTest.php, line 149

Class

DiskSpaceValidatorTest
@covers \Drupal\package_manager\Validator\DiskSpaceValidator @group package_manager @internal

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testDiskSpaceValidation(bool $shared_disk, array $free_space, array $expected_results) : void {
    $free_space = array_flip($this->resolvePlaceholdersInArrayValuesWithRealPaths(array_flip($free_space)));
    
    /** @var \Drupal\Tests\package_manager\Kernel\TestDiskSpaceValidator $validator */
    $validator = $this->container
        ->get(DiskSpaceValidator::class);
    $validator->sharedDisk = $shared_disk;
    $validator->freeSpace = array_map([
        Bytes::class,
        'toNumber',
    ], $free_space);
    $this->assertStatusCheckResults($expected_results);
    $this->assertResults($expected_results, PreCreateEvent::class);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.