We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17460
    • 14 Posts
    Hi Forum

    I’m developing a little snippet. Before modx I used to test my php code with a unit-test framework called simpletest.
    The php script im creating requests some parameters from the global modx instance. But inside the testframework i can’t use my script - because i don’t have this modx instance. If I try to create a new one i get the following error:
    $modx = new DocumentParser();
    results in php exception: Could not load DBAPI class.


    What are the minimum requirements / parameters to construct a modx object instance? How can I setup a unit-test under "real" context?
      • 22303 MODX Staff
      • 10,725 Posts
      I assume since you are trying to instantiate DocumentParser that you are using Evolution. This is much easier in Revolution (2.0.0, currently in beta), but see index.php for how it instantiates the DocumentParser in Evolution.
        • 17460
        • 14 Posts
        Yes I use Evolution (1.0.2).
        After a look into the index file I saw, that the DocumentParser object needs the included config file before it can be created.

        In my snippet I’m trying to read values from the $modx->config. It seemed as if this is only possible if the $modx->executeParser() was executed first. But that execution forced my testframework to end up in an endless-loop.
        Now i just found the $modx->getSettings() method. After this call I can use my Testframework as usual.