Download the PHP package becklyn/test-helpers without Composer
On this page you can find all versions of the php package becklyn/test-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download becklyn/test-helpers
More information about becklyn/test-helpers
Files in becklyn/test-helpers
Package test-helpers
Short Description Common test helpers
License BSD-3-Clause
Homepage https://github.com/Becklyn/test-helpers
Informations about the package test-helpers
Test Helpers
Installation
Usage
The bundle contains various base tests, that can be used in bundles / libraries.
Schema Validation Test
This test receives a list of directories and tests that there are no mapping errors in doctrine annotations.
Usage
Extend it in your tests
directory:
tests/ValidateEntitySchemaTest
:
There are two extension points:
-
getRootDir(): string
must return the absolute path to the root of your app. By default it assumes that your test is directly in the tests directory top level. Change it, if that isn't the case. getEntityDirs(): string[]
must return the list of absolute paths, where files with mapping info are stored. By default set togetRootDir()/src/Entity
.
No Missing Translations Test
This tests checks that there are no translations used that are missing in the library.
You need to install the package
becklyn/translations-extractor
, preferably via thecomposer-bin-plugin
:
Translations will be extracted from:
- Validation constraint annotations in entities (on the class itself and its properties)
- Form field options in
AbstractType
s - Usages of the
BackendTranslator
(Mayd-specific) - Usages of
ExecutionContext(Interface)
in@Callback
methods - Symfony:
$this->get('translator')->trans('foobar')
in controllers - Symfony:
$this->get('translator')->transChoice('foobar')
in controllers - Symfony:
$this->addFlash()
and$this->getFlashBag()->add()
in controllers - Symfony: Form type choices
- Defaults messages from custom validation constraint message properties
- Specific constructor parameters of special classes
Usage
Extend it in your tests
directory:
tests/ValidateEntitySchemaTest
:
There are several extension points:
getLocales(): string[]
returns the list of locales to validate. By default set to["de", "en"]
.getDirectoriesWithUsages(): string[]
returns the absolute paths to where there is code that is using translations (like forms, entities, templates, etc..). By default set to["getRootDir()/src"]
.getDirectoriesWithTranslations(): string[]
: returns the absolute paths to where the translations are stored. The translations files are expected to be in theyaml
format. By default set to["getRootDir()/src/Resources/translations"]
.getIgnoredKeys[]: (complex)
: returns the list of keys that should be ignored when validating for missing keys. See below for details. By default set to[]
.getRootDir(): string[]
: must return the absolute path to the root of your app. By default it assumes that your test is directly in the tests directory top level. Change it, if that isn't the case.getMockedFunctions(): string[]
: the names of the twig functions that are defined by this project / library. They need to be mocked, as otherwise Twig will throw exceptions.getMockedFilters(): string[]
: the names of the twig filters that are defined by this project / library. They need to be mocked, as otherwise Twig will throw exceptions.getMockedTests(): string[]
: the names of the twig tests that are defined by this project / library. They need to be mocked, as otherwise Twig will throw exceptions.
Defining Ignored Keys
The ignored keys are an indexed array, where
- the key is a valid RegEx pattern. *Be sure to make it as specific as possible (e.g. by using
^
and$
). - the value is the list of domains (
string[]
) where this ignore should apply. Instead of an array you can passtrue
to ignore it in any domain.
All versions of test-helpers with dependencies
ext-json Version *
doctrine/orm Version ^2.11.1
symfony/process Version ^v5.4.3 || ^v6.0.3
symfony/translation Version ^v5.4.3 || ^v6.0.3