Documentation

UpgradeSnapshotTest extends TestCase
in package

The UpgradeSnapshotTest walks through a list of MySQL snapshots. It loads each of them into the CiviCRM database and runs the upgrader.

The test can be controlled by setting environment variables:

  • [required] CIVICRM_UPGRADE_EVIL=1: Enable the test to perform highly destructive operations. The test will not run unless you enable it.
  • [optional] UPGRADE_TEST_FILTER=...: Focus testing on a specific SQL datadump.
  • [optional] DEBUG=1: Enable extra output for subcommands
  • [optional] DEBUG=2: Enable very verbose output for subcommands

The test is generally dependent on two major tools:

  • civicrm-upgrade-examples: This command from civicrm/upgrade-test provides a list of available examples.
  • cv: This provides way to interact with the site.

Here are a few examples of using the test:

Run all tests

$ CIVICRM_UPGRADE_EVIL=1 phpunit9 tests/phpunit/Upgrade

Run tests with detailed command output

$ CIVICRM_UPGRADE_EVIL=1 DEBUG=2 phpunit9 tests/phpunit/Upgrade

Focus on snapshots from 5.45.*

$ CIVICRM_UPGRADE_EVIL=1 UPGRADE_TEST_FILTER='5.45.*' phpunit9 tests/phpunit/Upgrade

Focus on snapshots from 4.7.30 through 5.70

$ CIVICRM_UPGRADE_EVIL=1 UPGRADE_TEST_FILTER='@4.7.30..5.70' phpunit9 tests/phpunit/Upgrade

Tags
group

upgrade

Table of Contents

Properties

$limit  : int
When scanning available examples, choose up-to $limit snapshots for testing.
$logDir  : mixed

Methods

getExamples()  : array<string|int, mixed>
Get a list of MySQL example files.
setUp()  : void
setUpBeforeClass()  : void
testSnapshot()  : void
Load a SQL snapshot and run the upgrade.
formatLog()  : string

Properties

$limit

When scanning available examples, choose up-to $limit snapshots for testing.

private static int $limit = 10

The algorithm in civicrm-upgrade-examples will choose a stable and wide-spread list of versions.

Methods

getExamples()

Get a list of MySQL example files.

public static getExamples() : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

Ex: [['/path/to/civicrm-5.99.88.mysql.gz']]

testSnapshot()

Load a SQL snapshot and run the upgrade.

public testSnapshot(string $snapshot) : void
Parameters
$snapshot : string

Ex: '/path/to/civicrm-5.99.88.mysql.gz'

Tags
dataProvider

getExamples

formatLog()

private formatLog(string $logFile, string $content) : string
Parameters
$logFile : string
$content : string
Return values
string

        
On this page

Search results