aligent / oro-fixtures
An OroCommerce Bundle to use Alice fixtures to populate development environments with test data.
Requires
- oro/commerce: 5.0.*
- oro/platform: 5.0.*
Requires (Dev)
- friendsofphp/php-cs-fixer: ~2.18.2 || ~3.1.0
- nelmio/alice: ~3.8.0 || ~3.9.0
- phpmd/phpmd: ^2.12
- phpstan/phpstan: ^1.7
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
- symfony/phpunit-bridge: ~4.4.24 || ~6.1.0
- theofidry/alice-data-fixtures: ~1.4.0 || ~1.5.0
This package is auto-updated.
Last update: 2024-10-30 01:40:33 UTC
README
Description
This bundle provides an abstract fixture class that can be extended to load Alice fixtures. Providing an easy way to load small subsets of demo/test data for developer environments. These fixtures can then be easily shared with any Behat tests created for your bundles.
This bundle is not intended to be loaded in production and will only load it's required services in dev mode.
Installation Instructions
-
Install this module via Composer
composer require --dev aligent/oro-fixtures
-
Add the below to your
src/AppKernel.php
registerBundles
functionif (class_exists('Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle') && class_exists('Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle')) { $bundles[] = new Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle(); $bundles[] = new Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle(); }
-
Clear cache
php bin/console cache:clear --env=dev
Initializers
Intializers provide a way for Alice fixtures to reference entities that already exist in the database.
This bundle comes with the below initializers:
Adding and Running Fixtures
-
Ensure your database has been initialized with an empty installation of OroCommerce (i.e. DO NOT ADD DEMO DATA)
-
Snapshot your database to create a rollback point
-
In your bundle create the Demo fixture directory e.g.
src/Acme/BaseBundle/Migrations/Data/Demo/ORM
-
Create a subdirectory called
data
e.g.src/Acme/BaseBundle/Migrations/Data/Demo/ORM/data
and add an alice fixture e.g.Oro\Bundle\ProductBundle\Entity\ProductName: product_A_1_name: string: 'Product A 1' Oro\Bundle\ProductBundle\Entity\ProductUnitPrecision: unit_precisionA1: unit: '@unit_each' precision: '1' Oro\Bundle\ProductBundle\Entity\Product: product_A_1: type: 'simple' sku: 'PROD_A_1' organization: '@organization' attributeFamily: '@defaultProductFamily' primaryUnitPrecision: '@unit_precisionA1' __calls: - addName: ['@product_A_1_name'] status: 'enabled' inventoryStatus: '@enumInventoryStatuses' Oro\Bundle\PricingBundle\Entity\ProductPrice: price_A_1: product: '@product_A_1' priceList: '@defaultPriceList' currency: 'AUD' quantity: 1 unit: '@unit_each' value: 12 Oro\Bundle\PricingBundle\Entity\PriceListToProduct: priceRelation_A_1: product: '@product_A_1' priceList: '@defaultPriceList'
-
In the demo fixtures directory create a new fixture that extends the
AbstractAliceFixture
and implement thegetFixtures
. This can point to a single file or a directory of yml files.<?php namespace Acme\BaseBundle\Migrations\Data\Demo\ORM; use Aligent\FixturesBundle\Fixtures\AbstractAliceFixture; class ExampleDemoDataFixture extends AbstractAliceFixture { protected function getFixtures(): string { return __DIR__ . '/data'; } }
-
To execute the fixtures run:
bin/console oro:migration:data:load --env=dev --fixtures-type=demo --bundles=AcmeBaseBundle --bundles=AcmeAnotherBundle
Support
If you have any issues with this bundle, please feel free to open GitHub issue with version and steps to reproduce.
Contribution
Any contribution is highly appreciated. The best way to contribute code is to open a pull request on GitHub.
Developer
Adam Hall adam.hall@aligent.com.au.
License
Copyright
(C) 2022 Aligent Consulting