aligent/oro-fixtures
Composer 安装命令:
composer require aligent/oro-fixtures
包简介
An OroCommerce Bundle to use Alice fixtures to populate development environments with test data.
README 文档
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.phpregisterBundlesfunctionif (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:
| Initializer | Description | Example |
|---|---|---|
| AdminUserInitializer | First user with ROLE_ADMINISTRATOR |
@admin_user |
| CustomerUserRoleInitializer | All customer user roles | @buyer, @admin |
| ProductUnitInitializer | All product unit codes prefixed with unit |
@unit_each |
| RootCategoryInitializer | The master catalogs root category | @root_category |
| WarehouseInitializer | The snake case version of the name of each warehouse (Enterprise only) prefixed with warehouse |
Some Warehouse becomes @warehouse_some_warehouse |
| BusinessUnitInitializer | All of the existing business units suffixed with _business_unit |
North Office becomes @north_office_business_unit |
| DefaultPriceListInitializer | The default price list | @default_price_list |
| OrganizationInitializer | If 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 |
| SegmentTypeInitializer | The available segment types | @dynamic_segment_type or static_segment_type |
| WebsiteInitializer | All website names prefixed by website_ |
Some Store becomes @website_some_store |
| CustomerGroupInitializer | All customer group names prefixed with group_ |
Registered Buyers becomes @group_registered_buyers |
| InventoryStatusInitializer | All inventory status ids prefixed by inventory_status_ |
@inventory_status_in_stock or @inventory_status_out_of_stock |
| ProductFamilyInitializer | All Attribute family names prefixed with product_family_ |
Clothing Attributes becomes @product_family_clothing_attributes |
| CustomerTaxCodeInitializer | The customer tax code lowercased and prefixed with customer_tax_code_ |
GST_FREE becomes @customer_tax_code_gst_free |
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
datae.g.src/Acme/BaseBundle/Migrations/Data/Demo/ORM/dataand 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
AbstractAliceFixtureand 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
aligent/oro-fixtures 适用场景与选型建议
aligent/oro-fixtures 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 175 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 06 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 aligent/oro-fixtures 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aligent/oro-fixtures 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 175
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2022-06-15