Commit 869cafcd 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: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent c5d9c584
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"fabpot/goutte": ">=3.1.2", "fabpot/goutte": ">=3.1.2",
"guzzlehttp/guzzle": ">=6.2.1", "guzzlehttp/guzzle": ">=6.2.1",
"phpunit/phpunit": ">=3.7.38" "phpunit/phpunit": "^6.0"
}, },
"autoload": { "autoload": {
......
...@@ -186,7 +186,7 @@ class UnitTestBootstrap { ...@@ -186,7 +186,7 @@ class UnitTestBootstrap {
* mocking events (or just ignoring them) * mocking events (or just ignoring them)
* mocking the file system * mocking the file system
*/ */
class MaharaUnitTest extends PHPUnit_Framework_TestCase { class MaharaUnitTest extends PHPUnit\Framework\TestCase {
/** @var array list of common last names */ /** @var array list of common last names */
public $lastnames = array( public $lastnames = array(
......
...@@ -81,6 +81,9 @@ class ArtefactTest extends MaharaUnitTest { ...@@ -81,6 +81,9 @@ class ArtefactTest extends MaharaUnitTest {
$this->fail("Artefact wasn't deleted properly!"); $this->fail("Artefact wasn't deleted properly!");
} }
catch (Exception $e) {} catch (Exception $e) {}
$fromdb = get_field('artefact', 'artefacttype', 'id', $todeleteid);
$this->assertEquals(null, $fromdb);
} }
/** /**
......
...@@ -121,6 +121,9 @@ class ViewTest extends MaharaUnitTest { ...@@ -121,6 +121,9 @@ class ViewTest extends MaharaUnitTest {
$this->fail("View wasn't deleted properly!"); $this->fail("View wasn't deleted properly!");
} }
catch (Exception $e) {} catch (Exception $e) {}
$fromdb = get_field('view', 'type', 'id', $todeleteid);
$this->assertEquals(null, $fromdb);
} }
public function testView_get_artefact_instances() { public function testView_get_artefact_instances() {
......
...@@ -143,10 +143,11 @@ class WebServiceTestBase extends MaharaUnitTest { ...@@ -143,10 +143,11 @@ class WebServiceTestBase extends MaharaUnitTest {
// construct a test service from all available functions // construct a test service from all available functions
$dbservice = get_record('external_services', 'name', $this->servicename); $dbservice = get_record('external_services', 'name', $this->servicename);
if (empty($dbservice)) { 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); insert_record('external_services', $service);
$dbservice = get_record('external_services', 'name', $this->servicename); $dbservice = get_record('external_services', 'name', $this->servicename);
} }
$dbfunctions = get_records_array('external_functions', null, null, 'name'); $dbfunctions = get_records_array('external_functions', null, null, 'name');
foreach ($dbfunctions as $function) { foreach ($dbfunctions as $function) {
$sfexists = record_exists('external_services_functions', 'externalserviceid', $dbservice->id, 'functionname', $function->name); $sfexists = record_exists('external_services_functions', 'externalserviceid', $dbservice->id, 'functionname', $function->name);
...@@ -155,6 +156,7 @@ class WebServiceTestBase extends MaharaUnitTest { ...@@ -155,6 +156,7 @@ class WebServiceTestBase extends MaharaUnitTest {
insert_record('external_services_functions', $service_function); insert_record('external_services_functions', $service_function);
$dbservice->mtime = db_format_timestamp(time()); $dbservice->mtime = db_format_timestamp(time());
update_record('external_services', $dbservice); 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 { ...@@ -176,11 +178,10 @@ class WebServiceTestBase extends MaharaUnitTest {
$this->consumer = (object) $store->getConsumer($this->consumer_key, $dbuser->id); $this->consumer = (object) $store->getConsumer($this->consumer_key, $dbuser->id);
// Now do the request and access token // 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 // authorise
$verifier = $store->authorizeConsumerRequestToken($this->request_token['token'], $dbuser->id, 'localhost'); $verifier = $store->authorizeConsumerRequestToken($this->request_token['token'], $dbuser->id, 'localhost');
// exchange access token // exchange access token
$options = array(); $options = array();
$options['verifier'] = $verifier; $options['verifier'] = $verifier;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment