validateTranslations example

'de-DE' => 'Swag App Test',
        ]$metaData->getLabel());
        static::assertEquals([]$metaData->getDescription());

        $array = $metaData->toArray('en-GB');
        static::assertEquals([]$array['description']);
    }

    public function testValidateTranslationsReturnsMissingTranslationErrorIfTranslationIsMissing(): void
    {
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/../_fixtures/invalid-translations-manifest.xml');
        $error = $manifest->getMetadata()->validateTranslations();

        static::assertInstanceOf(MissingTranslationError::class$error);
        static::assertEquals('Missing translations for "Metadata": - label: de-DE, fr-FR', $error->getMessage());
    }

    public function testValidateTranslationsReturnsNull(): void
    {
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/../_fixtures/test-manifest.xml');
        $error = $manifest->getMetadata()->validateTranslations();

        
use Shopware\Core\Framework\Log\Package;

/** * @internal only for use by the app-system */
#[Package('core')] class TranslationValidator extends AbstractManifestValidator
{
    public function validate(Manifest $manifest, ?Context $context): ErrorCollection
    {
        $errors = new ErrorCollection();
        $error = $manifest->getMetadata()->validateTranslations();

        if ($error !== null) {
            $errors->add($error);
        }

        return $errors;
    }
}
'de-DE' => 'Swag App Test',
        ]$metaData->getLabel());
        static::assertEquals([]$metaData->getDescription());

        $array = $metaData->toArray('en-GB');
        static::assertEquals([]$array['description']);
    }

    public function testValidateTranslationsReturnsMissingTranslationErrorIfTranslationIsMissing(): void
    {
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/../_fixtures/invalidTranslations/manifest.xml');
        $error = $manifest->getMetadata()->validateTranslations();

        static::assertInstanceOf(MissingTranslationError::class$error);
        static::assertEquals('Missing translations for "Metadata": - label: de-DE, fr-FR', $error->getMessage());
    }

    public function testValidateTranslationsReturnsNull(): void
    {
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/../_fixtures/test/manifest.xml');
        $error = $manifest->getMetadata()->validateTranslations();

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