Added tests for the PHP's MibewAPIInteraction class

This commit is contained in:
Dmitriy Simushev 2012-08-22 10:49:06 +00:00
parent b0225eadeb
commit 6c6a26225f
2 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,61 @@
<?php
require_once dirname(__FILE__) . '/../../../../webim/libs/classes/mibew_api_interaction.php';
require_once dirname(__FILE__) . '/mibew_api_test_interaction.php';
/**
* Test class for MibewAPIInteraction.
*/
class MibewAPIInteractionTest extends PHPUnit_Framework_TestCase {
/**
* An instance of the MibewAPITestInteraction
* @var MibewAPITestInteraction
*/
protected $object = null;
protected function setUp() {
$this->object = new MibewAPITestInteraction();
}
protected function tearDown() {
unset($this->object);
}
public function testGetObligatoryArguments() {
// Test obligatory arguments for all functions
$this->assertEquals(
$this->object->getObligatoryArguments('some_default_function'),
array('return', 'references')
);
// Test obligatory argumens for specific function
$this->assertEquals(
$this->object->getObligatoryArguments('foo'),
array('return', 'references', 'bar')
);
}
public function testGetObligatoryArgumentsDefaults() {
// Test default values for obligatory arguments for all functions
$this->assertEquals(
$this->object->getObligatoryArgumentsDefaults('some_default_function'),
array(
'return' => array(),
'references' => array()
)
);
// Test default values for obligatory argumens for specific function
$this->assertEquals(
$this->object->getObligatoryArgumentsDefaults('foo'),
array(
'return' => array(),
'references' => array(),
'bar' => 127
)
);
}
}
?>

View File

@ -0,0 +1,24 @@
<?php
/**
* Test interaction type for the Mibew API
*/
class MibewAPITestInteraction extends MibewAPIInteraction {
protected $obligatoryArguments = array(
'*' => array(
'return' => array(),
'references' => array()
),
'foo' => array(
'bar' => 127
)
);
public $reservedFunctionNames = array(
'result'
);
}
?>