Download the PHP package whitedigital-eu/config-pack without Composer
On this page you can find all versions of the php package whitedigital-eu/config-pack. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download whitedigital-eu/config-pack
More information about whitedigital-eu/config-pack
Files in whitedigital-eu/config-pack
Package config-pack
Short Description PhpCsFixer configuration to use in other organization repositories
License MIT
Informations about the package config-pack
config-pack
WARNING
When upgrading from v1 to v2, it is better to runcomposer updatewithout scripts and plugins, as v2 does not requiresymfony/phpunit-bridgeanymore and uninstalling it may change or delete test related files, like.env.testorphpunit.xml.dist:
composer update -nW --no-scripts --no-plugins whitedigital-eu/config-pack
Installation
Usage
PhpCsFixer:
In PhpStorm:
- point to same config file in settings of PHP CS Fixer
- check "allow risky rules" checkbox
- choose custom ruleset
- point to php-cs-fixer binary
PhpUnit:
or if tests/bootstrap.php differs from one in whitedigital-eu/config-pack:
PhpStan
In PhpStorm:
- point to same config file in settings of PHPStan
- point to your project's autoload, usually
vendor/autoload.php - point to phpstan binary
Functional usage (since v2.2)
ConfigPack only works in dev and test environments, make sure you set this config only for dev and test.
/** config/bundles.php */
WhiteDigital\Config\ConfigPack::class => ['dev' => true, 'test' => true]
Faker
This package now comes with fakerphp/faker as a dependency thus making usage of fake data
generation easier. If used without AbstractTestCase or AbstractFixture, you can easily
use faker using FakerTrait.
As Faker is used with this library's configuration, setFaker function call is mandatory before using any faker functionality.
Faker is autowired automatically. FakerTrait primarily passes through functions from faker factory, most useful methods
are defined as methods in annotation so IDE can see them.
By default Faker uses lv_LV as locale and 2022 as seed. If different values are needed, you can configure them:
AbstractTestCase
As most of tests for testing api-platform apis are somewhat similar, AbstractTestCase defines a lot of useful functions
to make testing apis a lot easier.
In overall, with using AbstractTestCase usual api test should look like this:
This tests:
GET: /api/customers/{id}
GET: /api/customer/{not_existing_id}
GET: /api/customers
POST: /api/customers
PATCH: /api/customers/{id}
DELETE: /api/customers/{id}
Tests by default uses authentication, you can configure login_email and login_password in config_pack configuration:
AbstractFixture
Similarly to AbstractTestCase, AbstractFixture defines base functions for doctrine fixtures.
It also uses FakerTrait to simplify data generation.
AbstractFixture defines some useful functions:
getEntity -> getEntity(Entity::class): returns entity object for given class if fixture, where this class
is created, is added to dependencies and dependant fixture defines reference.
getImage and getFile: coupled with whitedigital-eu/storage-item-resource library, these functions return
entity for StorageItem based on need -> image or text file.
reference: set current fixture to references to be used elsewhere where this fixture is a dependency
getClassifier: explicitly returns Classifier if project contains any classifiers and
project Classifier fixture extends BaseClassifierFixture.
BaseClassifierFixture
If your project have any classifier logic, you can extend BaseClassifierFixture and it will make classifier creation easier.
You need to have an entity with at least this structure to make this work:
And you need to have a Backed enum (here called ClassifierType).
Example of ClassifierType is something like this:
With BaseClassifierFixture classifiers can be created using two ways:
simple:
with data:
dependant:
All versions of config-pack with dependencies
friendsofphp/php-cs-fixer Version *
phpstan/phpstan Version *
phpstan/phpstan-doctrine Version *
phpstan/phpstan-symfony Version *
phpunit/phpunit Version >=10.0
roave/security-advisories Version dev-latest