appSecretRequiredForFeatures example



        if (\count($manifest->getTax()?->getTaxProviders() ?? []) > 0) {
            $usedFeatures[] = 'Tax providers';
        }

        if (\count($manifest->getWebhooks()?->getWebhooks() ?? []) > 0) {
            $usedFeatures[] = 'Webhooks';
        }

        if (\count($usedFeatures) > 0) {
            throw AppException::appSecretRequiredForFeatures($app->getName()$usedFeatures);
        }
    }
}


    public function testInvalidConfiguration(): void
    {
        $e = AppException::invalidConfiguration('InvalidlyConfiguredApp', new AppNameError('InvalidlyConfiguredApp'));

        static::assertEquals(AppException::INVALID_CONFIGURATION, $e->getErrorCode());
    }

    public function testAppSecretRequiredForFeatures(): void
    {
        $e = AppException::appSecretRequiredForFeatures('MyApp', ['Modules']);

        static::assertEquals(AppException::FEATURES_REQUIRE_APP_SECRET, $e->getErrorCode());
        static::assertEquals('App "MyApp" could not be installed/updated because it uses features Modules but has no secret', $e->getMessage());

        $e = AppException::appSecretRequiredForFeatures('MyApp', ['Modules', 'Payments', 'Webhooks']);

        static::assertEquals(AppException::FEATURES_REQUIRE_APP_SECRET, $e->getErrorCode());
        static::assertEquals('App "MyApp" could not be installed/updated because it uses features Modules, Payments and Webhooks but has no secret', $e->getMessage());
    }
}
Home | Imprint | This part of the site doesn't use cookies.