How can I start Elgg engine within separate test script?

Hello everyone!

I want to execute heavy tests on elgg. I designed my tests to execute as script and save the results in a JSON file. But it seems that my script was not designed correctly...

I included the following lines to the beginning of it and some pieces of my script works correctly:


Nevertheless, it seems that the plugins activated in my Elgg installation are not working (may I need to call some function?). And the following function to clean the content created previously are not working, either.

function clean_content() {
    $hidden = access_get_show_hidden_status();
    $data = new ElggBatch('elgg_get_entities_from_metadata', array(
        'type' => 'object',
        'limit' => 0,
        'metadata_names' => '__faker',
    foreach ($data as $d) {
        echo 'Data ' . print_r($d) . "deleted.\n";


Any suggestions?

  • How do you know they are not working? Are you e.g. getting an error message?

  • No, I am not getting any error message.
    But I have the same code in a plugin that works fine, so there must be something wrong with the script.

    I have explored more my script and its execution. The main problem is that the plugins are not loaded (or linked). Can I linked in some way?

  • "The plugins"? So none of the plugins on the whole site are being loaded? Or none of your own plugins?

    What are you calling after you've done:


    How does the code continue after that?

  • In my site I have loaded plugins (some they were from Elgg, others from third parties and the rest are mine). The fact is when I use an object or function produced by plugins(third parties or mine) loaded do not found the references.

    The code follows with the creation of contents of several types like comments and posts (with the hypeWall plugin).

  • Which version of Elgg are you using? Is it some Elgg 2 version or some Elgg 1 version? As far as I know booting the engine the way you do it will work only on Elgg 2.0 and newer. On earlier versions it's done with

    dirname(__DIR__) . "/engine/start.php";

    (relative to root dir of your Elgg installation).

    And the batch might find no results if the access level of the entities is not public (and you are not calling your script while logged in). You might want to ignore the access level in your script in addition to showing also hidden entities:

        $access = elgg_set_ignore_access(true);
        $access_status = access_get_show_hidden_status();
  • Perfect! My problem was solved.

    Juho and iionly thank you very much!

    I have got installed a 2.0 Elgg version, so my call to Elgg is correct. The solution was to include the code to ignore the access level.