Commit 0c45acaa authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1786867: Updating PHPUnit testing system



To allow for using newer PHPUnit version that uses Namespaced clases

behatnotneeded

Change-Id: I9e33c2542dda76691b32df78335ce511b06174c7
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent 92ffdc2d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
        "emuse/behat-html-formatter": "^0.1",
        "fabpot/goutte": "^3.2",
        "guzzlehttp/guzzle": "^6.3.0",
        "phpunit/phpunit": "^4.5"
        "phpunit/phpunit": "^6.0"
    },

    "autoload": {
+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ class UnitTestBootstrap {
 * mocking events (or just ignoring them)
 * mocking the file system
 */
class MaharaUnitTest extends PHPUnit_Framework_TestCase {
class MaharaUnitTest extends PHPUnit\Framework\TestCase {

    /** @var array list of common last names */
    public $lastnames = array(
+3 −0
Original line number Diff line number Diff line
@@ -81,6 +81,9 @@ class ArtefactTest extends MaharaUnitTest {
            $this->fail("Artefact wasn't deleted properly!");
        }
        catch (Exception $e) {}

        $fromdb = get_field('artefact', 'artefacttype', 'id', $todeleteid);
        $this->assertEquals(null, $fromdb);
    }

    /**
+3 −0
Original line number Diff line number Diff line
@@ -121,6 +121,9 @@ class ViewTest extends MaharaUnitTest {
            $this->fail("View wasn't deleted properly!");
        }
        catch (Exception $e) {}

        $fromdb = get_field('view', 'type', 'id', $todeleteid);
        $this->assertEquals(null, $fromdb);
    }

    public function testView_get_artefact_instances() {
+4 −3
Original line number Diff line number Diff line
@@ -143,10 +143,11 @@ class WebServiceTestBase extends MaharaUnitTest {
        // construct a test service from all available functions
        $dbservice = get_record('external_services', 'name', $this->servicename);
        if (empty($dbservice)) {
            $service = array('name' => $this->servicename, 'tokenusers' => 0, 'restrictedusers' => 0, 'enabled' => 1, 'component' => 'webservice', 'ctime' => db_format_timestamp(time()));
            $service = array('name' => $this->servicename, 'tokenusers' => 1, 'restrictedusers' => 0, 'enabled' => 1, 'component' => 'webservice', 'ctime' => db_format_timestamp(time()));
            insert_record('external_services', $service);
            $dbservice = get_record('external_services', 'name', $this->servicename);
        }

        $dbfunctions = get_records_array('external_functions', null, null, 'name');
        foreach ($dbfunctions as $function) {
            $sfexists = record_exists('external_services_functions', 'externalserviceid', $dbservice->id, 'functionname', $function->name);
@@ -155,6 +156,7 @@ class WebServiceTestBase extends MaharaUnitTest {
                insert_record('external_services_functions', $service_function);
                $dbservice->mtime = db_format_timestamp(time());
                update_record('external_services', $dbservice);
                $sfexists = record_exists('external_services_functions', 'externalserviceid', $dbservice->id, 'functionname', $function->name);
            }
        }

@@ -176,11 +178,10 @@ class WebServiceTestBase extends MaharaUnitTest {
        $this->consumer = (object) $store->getConsumer($this->consumer_key, $dbuser->id);

        // Now do the request and access token
        $this->request_token  = $store->addConsumerRequestToken($this->consumer_key, array());
        $this->request_token  = $store->addConsumerRequestToken($this->consumer_key, array('token_ttl' => 50000));

        // authorise
        $verifier = $store->authorizeConsumerRequestToken($this->request_token['token'], $dbuser->id, 'localhost');

        // exchange access token
        $options = array();
        $options['verifier'] = $verifier;