PHPackages                             aligent/oro-fixtures - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. aligent/oro-fixtures

ActiveLibrary[Testing &amp; Quality](/categories/testing)

aligent/oro-fixtures
====================

An OroCommerce Bundle to use Alice fixtures to populate development environments with test data.

v5.0.0(3y ago)0168[1 issues](https://github.com/aligent/oro-fixtures/issues)1GPL-3.0-onlyPHPCI passing

Since Jun 15Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/aligent/oro-fixtures)[ Packagist](https://packagist.org/packages/aligent/oro-fixtures)[ RSS](/packages/aligent-oro-fixtures/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (10)Versions (12)Used By (1)

Oro Fixtures Bundle
===================

[](#oro-fixtures-bundle)

Description
-----------

[](#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
-------------------------

[](#installation-instructions)

1. Install this module via Composer

    ```
     composer require --dev aligent/oro-fixtures

    ```
2. Add the below to your `src/AppKernel.php` `registerBundles` function

    ```
    if (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();
    }
    ```
3. Clear cache

    ```
     php bin/console cache:clear --env=dev

    ```

Initializers
------------

[](#initializers)

Intializers provide a way for Alice fixtures to reference entities that already exist in the database.

This bundle comes with the below initializers:

InitializerDescriptionExampleAdminUserInitializerFirst user with `ROLE_ADMINISTRATOR``@admin_user`CustomerUserRoleInitializerAll customer user roles`@buyer`, `@admin`ProductUnitInitializerAll product unit codes prefixed with `unit``@unit_each`RootCategoryInitializerThe master catalogs root category`@root_category`WarehouseInitializerThe snake case version of the name of each warehouse (Enterprise only) prefixed with `warehouse``Some Warehouse` becomes `@warehouse_some_warehouse`BusinessUnitInitializerAll of the existing business units suffixed with `_business_unit``North Office` becomes `@north_office_business_unit`DefaultPriceListInitializerThe default price list`@default_price_list`OrganizationInitializerIf more than one organization exists the normalized name of of the organization prefixed by `org_`. If only one exists it is named `default_organization``@default_organization` or `Our Business` becomes `@org_our_business`SegmentTypeInitializerThe available segment types`@dynamic_segment_type` or `static_segment_type`WebsiteInitializerAll website names prefixed by `website_``Some Store` becomes `@website_some_store`CustomerGroupInitializerAll customer group names prefixed with `group_``Registered Buyers` becomes `@group_registered_buyers`InventoryStatusInitializerAll inventory status ids prefixed by `inventory_status_``@inventory_status_in_stock` or `@inventory_status_out_of_stock`ProductFamilyInitializerAll Attribute family names prefixed with `product_family_``Clothing Attributes` becomes `@product_family_clothing_attributes`CustomerTaxCodeInitializerThe customer tax code lowercased and prefixed with `customer_tax_code_``GST_FREE` becomes `@customer_tax_code_gst_free`Adding and Running Fixtures
---------------------------

[](#adding-and-running-fixtures)

1. Ensure your database has been initialized with an empty installation of OroCommerce (i.e. DO NOT ADD DEMO DATA)
2. Snapshot your database to create a rollback point
3. In your bundle create the Demo fixture directory e.g. `src/Acme/BaseBundle/Migrations/Data/Demo/ORM`
4. 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'
    ```
5. In the demo fixtures directory create a new fixture that extends the `AbstractAliceFixture` and implement the `getFixtures`. This can point to a single file or a directory of yml files.

    ```
