craue/translations-tests

Common code for testing translations in your Symfony project.

1.1.0 2020-12-09 09:03 UTC

This package is auto-updated.

Last update: 2021-06-04 12:37:33 UTC


README

Build Status

This repository contains just some common code for testing translations in your Symfony project.

Installation

Let Composer download and install the bundle by running

composer require --dev craue/translations-tests

in a shell.

Usage

// src/app/Tests/TranslationsTest.php
namespace Application\Tests;

use Craue\TranslationsTests\YamlTranslationsTest;

/**
 * @group unit
 */
class TranslationsTest extends YamlTranslationsTest {

	// only add this method to override the default implementation returning "en"
	protected function defineDefaultLocale() {
		return 'de';
	}

	// specify all locations with translation files
	protected function defineTranslationFiles() {
		return array_merge(
			glob(__DIR__ . '/../../Resources/translations/*.yml'),
			glob(__DIR__ . '/../../Resources/*Bundle/translations/*.yml'),
			glob(__DIR__ . '/../../../src/*/*Bundle/Resources/translations/*.yml')
		);
	}

}