summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php')
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php95
1 files changed, 95 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php
new file mode 100644
index 00000000..30ad86de
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php
@@ -0,0 +1,95 @@
+<?php
+
+namespace SFS\Tests;
+
+use SFS\ApiSemanticFormsSelect;
+use ApiMain;
+use RequestContext;
+use WebRequest;
+use FauxRequest;
+
+/**
+ * @covers \SFS\ApiSemanticFormsSelect
+ * @group semantic-forms-select
+ *
+ * @license GNU GPL v2+
+ * @since 1.3
+ *
+ * @author mwjames
+ */
+class ApiSemanticFormsSelectTest extends \PHPUnit_Framework_TestCase {
+
+ private $ApiSFS;
+ private $ApiMain;
+
+ protected function setUp() {
+ parent::setUp();
+ $parameters = [ 'action' => 'sformsselect', 'approach' => 'smw',
+ 'query' => 'abc', 'sep' => ',' ];
+
+ $this->ApiMain = new ApiMain(
+ $this->newRequestContext( $parameters ), true
+ );
+ $this->ApiSFS = new ApiSemanticFormsSelect(
+ $this->ApiMain, 'sformsselect'
+ );
+ }
+
+ protected function tearDown() {
+ unset( $this->ApiSFS );
+ unset( $this->ApiMain );
+ parent::tearDown();
+ }
+
+
+ public function testCanConstruct() {
+
+ $apiMain = new ApiMain( $this->newRequestContext( [] ), true );
+
+ $instance = new ApiSemanticFormsSelect(
+ $apiMain, 'sformsselect'
+ );
+
+ $this->assertInstanceOf(
+ '\SFS\ApiSemanticFormsSelect', $this->ApiSFS
+ );
+ }
+
+ public function testExecute() {
+
+ $this->assertTrue(
+ $this->ApiSFS->execute()
+ );
+ }
+
+ public function testGetDescription() {
+ $tdata = [ 'API for providing SemanticFormsSelect values' ];
+ $this->assertEquals( $this->ApiSFS->getDescription(), $tdata );
+ }
+
+ public function testGetParamDescription() {
+ $tdata = [ 'approach' => 'The actual approach: function or smw',
+ 'query' => 'The query of the former' ];
+ $this->assertEquals( $this->ApiSFS->getParamDescription(), $tdata );
+ }
+
+ public function testGetVersion() {
+ $tdata = 'SFS\ApiSemanticFormsSelect: 1.1';
+ $this->assertEquals( $this->ApiSFS->getVersion(), $tdata );
+ }
+
+
+ private function newRequestContext( $request = [] ) {
+
+ $context = new RequestContext();
+
+ if ( $request instanceof WebRequest ) {
+ $context->setRequest( $request );
+ } else {
+ $context->setRequest( new FauxRequest( $request, true ) );
+ }
+
+ return $context;
+ }
+
+}