SystemCheck example

$versionParser->parseConstraints('>=1.3.0'),
                    Link::TYPE_REQUIRE
                ),
                'php' => new Link(
                    'shopware/platform',
                    'php',
                    $versionParser->parseConstraints('>=7.4.3'),
                    Link::TYPE_REQUIRE
                ),
            ],
            [
                new SystemCheck(
                    'php',
                    RequirementCheck::STATUS_SUCCESS,
                    '>=7.4.3',
                    '7.4.3'
                ),
            ],
        ];

        yield 'platform repo with not satisfied requirement' => [
            'shopware/platform',
            [
                
/** * @internal * * @covers \Shopware\Core\Installer\Requirements\Struct\RequirementCheck * @covers \Shopware\Core\Installer\Requirements\Struct\SystemCheck */
class SystemCheckTest extends TestCase
{
    public function testGetters(): void
    {
        $check = new SystemCheck('name', RequirementCheck::STATUS_SUCCESS, 'requiredValue', 'installedValue');

        static::assertEquals('name', $check->getName());
        static::assertEquals('requiredValue', $check->getRequiredValue());
        static::assertEquals('installedValue', $check->getInstalledValue());
        static::assertEquals(RequirementCheck::STATUS_SUCCESS, $check->getStatus());
    }

    public function testEmptyNameThrowsException(): void
    {
        $this->expectException(\RuntimeException::class);
        $this->expectExceptionMessage('Empty name for RequirementCheck provided.');
        
$platform = $this->composer->getPackage();
        }

        foreach ($platform->getRequires() as $require => $link) {
            if (!PlatformRepository::isPlatformPackage($require)) {
                continue;
            }

            $result = $this->systemEnvironment->findPackage($require$link->getConstraint());

            if ($result) {
                $checks->add(new SystemCheck(
                    $require,
                    RequirementCheck::STATUS_SUCCESS,
                    $link->getConstraint()->getPrettyString(),
                    $result->getPrettyVersion()
                ));

                continue;
            }

            $extension = $this->systemEnvironment->findPackage($require, '*');

            

    public function testGetPathChecks(array $elements, array $expected): void
    {
        $collection = new RequirementsCheckCollection($elements);

        static::assertSame($expectedarray_values($collection->getPathChecks()->getElements()));
    }

    public static function pathCheckProvider(): \Generator
    {
        $pathCheck = new PathCheck('name', RequirementCheck::STATUS_SUCCESS);
        $systemCheck = new SystemCheck('name', RequirementCheck::STATUS_SUCCESS, 'required', 'installed');

        yield 'empty checks' => [
            [],
            [],
        ];

        yield 'single path check' => [
            [$pathCheck],
            [$pathCheck],
        ];

        


    public static function configRequirements(): \Generator
    {
        yield 'all checks pass with minimum requirements' => [
            [
                'max_execution_time' => '30',
                'memory_limit' => '512M',
                'opcache.memory_consumption' => '256',
            ],
            [
                new SystemCheck('max_execution_time', RequirementCheck::STATUS_SUCCESS, '30', '30'),
                new SystemCheck('memory_limit', RequirementCheck::STATUS_SUCCESS, '512M', '512M'),
                new SystemCheck('opcache.memory_consumption', RequirementCheck::STATUS_SUCCESS, '256M', '256M'),
            ],
        ];

        yield 'all checks pass with higher configs' => [
            [
                'max_execution_time' => '60',
                'memory_limit' => '1024M',
                'opcache.memory_consumption' => '512',
            ],
            [
$checks->add($this->checkMaxExecutionTime());
        $checks->add($this->checkMemoryLimit());
        $checks->add($this->checkOpCache());

        return $checks;
    }

    private function checkMaxExecutionTime(): SystemCheck
    {
        $configuredValue = (int) $this->iniConfigReader->get('max_execution_time');

        return new SystemCheck(
            'max_execution_time',
            ($configuredValue >= self::MAX_EXECUTION_TIME_REQUIREMENT || $configuredValue === 0) ? RequirementCheck::STATUS_SUCCESS : RequirementCheck::STATUS_ERROR,
            (string) self::MAX_EXECUTION_TIME_REQUIREMENT,
            (string) $configuredValue
        );
    }

    private function checkMemoryLimit(): SystemCheck
    {
        $configuredValue = $this->iniConfigReader->get('memory_limit');

        
Home | Imprint | This part of the site doesn't use cookies.