Acceptance Testing XXII - MODX 2 and MODX 3 in One Command

A trick for running MODX 2 and MODX 3 tests with a single command

In the previous two articles, we created a test that will run in both MODX 2 and MODX 3 and looked at some options for running it. One restriction was that we couldn't run the test in both MODX versions with a single command. In this one we'll see a workaround for that issue.

MODX logo

This article assumes that you've installed and configured Composer, Codeception, PhpUnit, MODX, Java, WebDriver, and ChromeDriver as described in earlier articles, and that you've created the acceptance test support files from those articles.

The Problem

In the previous article we saw that running out test in both MODX 2 and MODX 3 with a single command couldn't be done. The reason is that the MODX constants like MODX_CORE_PATH can't be changed. Since they need to have different values in MODX 2 and MODX 3, the tests will fail.

The Solution

The answer is to create a batch file that will run the test in MODX 2 and MODX 3 with separate commands:

Create a file called run18.bat in the _build/ directory with this code:

echo "Running MODX2 tests"
call codecept run acceptance T18_ResourceProtectionMODX3Cest --env firefox,modx2 --env chrome,modx2

echo "Running MODX3 tests"
call codecept run acceptance T18_ResourceProtectionMODX3Cest --env firefox,modx3 --env chrome,modx3

That will run the MODX 2 and MODX 3 tests in separate environments. I'm running on windows 10, so it's possible that you'll have to modify things to match your platform if you're running something else.

You might wonder why we prefix each command line with call. The reason is that some of the processes in our test use batch files of their own. The call makes sure that that each command returns control to *our* batch file when finished. Without it, only the first command will run.

Coming Up

In the next article, we'll modify our test to check the permission system for elements.

For more information on how to use MODX to create a web site, see my web site Bob's Guides, or better yet, buy my book: MODX: The Official Guide.

Looking for high-quality, MODX-friendly hosting? As of May 2016, Bob's Guides is hosted at A2 hosting. (More information in the box below.)

      Previous Article << —— >>

Comments (0)

Please login to comment.