Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 0820e16

Browse files
committed
ENH: refs #0448. Add a test for the web api info reporting methods
1 parent bad7f54 commit 0820e16

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

modules/api/tests/controllers/ApiCallMethodsTest.php

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,6 @@ public function testBitstreamCount()
644644
$this->assertEquals($resp->data->size, $expectedSize);
645645
}
646646

647-
648-
649-
650647
/** test item creation and deletion */
651648
public function testCreateitemDeleteitem()
652649
{
@@ -706,8 +703,70 @@ public function testCreateitemDeleteitem()
706703
$this->assertFalse($itemDao, 'Item should have been deleted, but was not.');
707704
}
708705

706+
/** Test the server info reporting methods */
707+
public function testInfoMethods()
708+
{
709+
// Test midas.version
710+
$this->params['method'] = 'midas.version';
711+
$resp = $this->_callJsonApi();
712+
$this->_assertStatusOk($resp);
713+
$this->assertEquals($resp->data->version, Zend_Registry::get('configDatabase')->version);
714+
715+
// Test midas.modules.list
716+
$this->resetAll();
717+
$this->params['method'] = 'midas.modules.list';
718+
$resp = $this->_callJsonApi();
719+
$this->_assertStatusOk($resp);
720+
$this->assertNotEmpty($resp->data->modules);
721+
$this->assertTrue(in_array('api', $resp->data->modules));
722+
723+
// Test midas.methods.list
724+
$this->resetAll();
725+
$this->params['method'] = 'midas.methods.list';
726+
$resp = $this->_callJsonApi();
727+
$this->_assertStatusOk($resp);
728+
$this->assertNotEmpty($resp->data->methods);
729+
foreach($resp->data->methods as $method)
730+
{
731+
$this->assertNotEmpty($method->name);
732+
$this->assertNotEmpty($method->help);
733+
$this->assertTrue(isset($method->help->description));
734+
$this->assertTrue(isset($method->help->params));
735+
$this->assertTrue(isset($method->help->example));
736+
$this->assertTrue(isset($method->help->return));
737+
738+
// Test a specific method's params list
739+
if($method->name == 'login')
740+
{
741+
$this->assertNotEmpty($method->help->params->appname);
742+
$this->assertNotEmpty($method->help->params->apikey);
743+
$this->assertNotEmpty($method->help->params->email);
744+
}
745+
}
709746

747+
// Test midas.info
748+
$this->resetAll();
749+
$this->params['method'] = 'midas.info';
750+
$resp = $this->_callJsonApi();
751+
$this->_assertStatusOk($resp);
710752

753+
// We should get version
754+
$this->assertEquals($resp->data->version, Zend_Registry::get('configDatabase')->version);
711755

756+
// We should get modules list
757+
$this->assertNotEmpty($resp->data->modules);
758+
$this->assertTrue(in_array('api', $resp->data->modules));
712759

760+
// We should get methods list
761+
$this->assertNotEmpty($resp->data->methods);
762+
foreach($resp->data->methods as $method)
763+
{
764+
$this->assertNotEmpty($method->name);
765+
$this->assertNotEmpty($method->help);
766+
$this->assertTrue(isset($method->help->description));
767+
$this->assertTrue(isset($method->help->params));
768+
$this->assertTrue(isset($method->help->example));
769+
$this->assertTrue(isset($method->help->return));
770+
}
771+
}
713772
}

0 commit comments

Comments
 (0)