dachcom-digital/pimcore-codeception-framework

Pimcore Codeception Framework

3.0.x-dev 2024-11-15 07:34 UTC

This package is auto-updated.

Last update: 2024-11-15 07:34:52 UTC


README

This Package allows you to create fast and simple testing environments. It's also used by all pimcore Bundles created by DACHCOM.DIGITAL.

Support Table

Upgrade Notes

3.0.0

  • Yaml extension changed from yml to yaml
  • _support path has changed to Support. All Dachcom\Codeception\* namespaces have changed to Dachcom\Codeception\Support\*
  • Using rsync for setup_files so you need to adjust your setup_files stack accordingly (see example below)
  • You need to define PIMCORE config_location in your ci configuration (See section "Configuration Location" below)
  • You have to add additional PIMCORE Bundles to the bundles config section (see example below)
  • [SECURITY] \Pimcore\Bundle\AdminBundle\EventListener\CsrfProtectionListener is disabled while executing tests
  • Pimcore\Model\DataObject namespace changed from _output/var/classes/DataObject/DataObject to _output/var/classes/DataObject
  • TestKernel Class can be defined via TEST_KERNEL_CLASS env var

Configuration

All test files need to be stored in /tests.

Environment Variables

Bootstrap

Create a file called _bootstrap.php in tests/_bootstrap.php

<?php

$frameworkPath = getenv('PIMCORE_CODECEPTION_FRAMEWORK');
$bundleTestPath = getenv('TEST_BUNDLE_TEST_DIR');

$bootstrap = sprintf('%s/src/_bootstrap.php', $frameworkPath);

include_once $bootstrap;

Setup File

Create a file called config.yaml in tests/_etc/config.yaml.

bundles:
    - { namespace: \MyTestBundle\MyTestBundle }
    - { namespace: \Pimcore\Bundle\SeoBundle\PimcoreSeoBundle, priority: 0, execute_installer: true } # if you need the seo bundle
setup_files:
    - { path: app/config.yaml, dest: ./config/ }
    - { path: app/system_settings.yaml, dest: ./var/config/system_settings/ }
    - { path: app/controller/DefaultController.php, dest: ./src/Controller/ }
    - { path: app/templates/default.html.twig, dest: ./templates/default/ }
    - { path: app/templates/snippet.html.twig, dest: ./templates/default/ }
preload_files:
    - { path: Services/MySpecialTestService.php }
additional_composer_packages:
    - { package: pimcore/admin-ui-classic-bundle, version: ^1.0 } # this one is most likely needed
    - { package: vendor/foo-bar, version: ^1.0}                   # additional packages

Configuration Location

In your app/config.yaml you should move all config locations to settings-store, see pimcore ci example

Attention! Do not set system_settings to settings-store!

Setup File Parameters

  • bundles (required): At least your test bundle should be registered here. Add more, if needed
  • setup_files (optional): All your template files which should to be available during test cycles. These files need to be stored under /tests/_etc/config
  • preload_files (optional): These files will be included at kernel setup. Since these files are not included via composer autoload, we need to define them here
  • additional_composer_packages (optional): Install additional composer packages which are not available in root composer.json

Bundle Configuration Files

This Framework allows you to use multiple (bundle) configuration setups. You need to add at least one default config file called default_config.yaml and store it in /tests/_etc/config/bundle.

Using Bundle Configuration Files

TBD

Classes

If you want to provide some classes to install, all the definitions need to stored at /tests/_etc/classes.

Actors

[MODULE] PimcoreAdminCsv

[MODULE] PimcoreAdminJson

[MODULE] PimcoreBackend

[MODULE] PimcoreBundleCore

[MODULE] PimcoreCore

[MODULE] PimcoreUser

[MODULE] Browser/PhpBrowser

[MODULE] Browser/WebDriver

License

DACHCOM.DIGITAL AG, Löwenhofstrasse 15, 9424 Rheineck, Schweiz
dachcom.com, dcdi@dachcom.ch
Copyright © 2024 DACHCOM.DIGITAL. All rights reserved.

For licensing details please visit LICENSE.md