Run ELGG unit tests

Hi all,

I would like to run the unit tests that Elgg includes from a scratch installation.

I have downloaded Elgg 2.3.8 on my computer: https://elgg.org/about/getelgg?forward=elgg-2.3.8.zip

After the installation, Elgg is running fine. I have activated the "Develop tool" and I went to the "Unit test" section from the right panel. After click on "Execute" I got this error:

"Some required classes for testing aren't available, please make sure you've installed the Elgg Composer dev-dependencies."

This button is executing this file: ./vendor/elgg/elgg/engine/tests/suite.php, and the classes that are checking are these ones:

"if (!class_exists('TextReporter') || !class_exists('TestSuite'))"

I can´t find those classed, so for that I executed the following on the elgg root folder: composer install

After that I have new subfolders in the vendor folder: 

Before the command:

autoload.php  bin  bower-asset composer  container-interop  doctrine  elgg  fortawesome  imagine  ircmaxell  league  michelf  misd  mrclay  psr  symfony  tedivm  true  zendframework

 

After the command:

autoload.php  bower-asset  container-interop  elgg    imagine    league   misd    phpdocumentor  phpunit  sebastian  tedivm  webmozart
bin       composer    doctrine       fortawesome  ircmaxell  michelf  mrclay  phpspec       psr      symfony   true   zendframework

 

At least, after that, I can find a TestCase class here:

../elgg/mod/code_review/classes/CodeReview/Foo/TestClass.php:class TestClass {
../elgg/vendor/sebastian/comparator/tests/_files/TestClass.php:class TestClass {

 

I can´t get any further sorry. To be honest, I don´t know very well what I am doing, I only need to run those unit tests on my Elgg 2.3.8 installation. Can someone help me, please?

Thanks a lot in advance.

  • Thanks for your reply @Nikolai,

    Unfortunately, I need to use Elgg 2.3 because is the version implemented for my solution, and I am not thinking of migrating to Elgg 3 yet I am afraid.

    So, is there a way to run the unit tests in Elgg 2.3?


    Kind regards.

  • First of all you might better install Elgg from scratch using composer. For Elgg 2 the instructions to install from command line are to be found at https://learn.elgg.org/en/2.3/intro/install.html#upload-elgg. The "composer global require ..." command is no longer necessary on Elgg 3 so you might not have executed it yet.

    I've never used the unit test, so I'm not sure what else might be necessary to get it working. But I would guess that you might need to call composer with the --require-dev parameter to get the dev dependencies installed (as mentioned in the error message you posted).

  • @John.iwt

    Unfortunately, I need to use Elgg 2.3 because is the version implemented for my solution, and I am not thinking of migrating to Elgg 3 yet I am afraid.

    Please check if you can't upgrade to Elgg 3.x soon because hopefully in Q2 we'll release Elgg 4 and than the support for Elgg 2.3 will drop.

    Just so you know.

    After the installation, Elgg is running fine. I have activated the "Develop tool" and I went to the "Unit test" section from the right panel.

    Don't try to run the unit tests from the site always use the command line. Don't ask why it was implemented as an option on the site. This option has been removed in Elgg 3 and you can only run the unit tests from the command line.

  • Thanks, guys for your answers.

    I will try the installation from scratch for Elgg 2.3 by using composer as suggested by @iionly and let you know.

    I will also consider @Jerome answer to not use the option from the site. And also the option of migrating to Elgg 3 soon.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking