summaryrefslogtreecommitdiff
path: root/bin/wiki/vendor/addwiki/mediawiki-api-base/tests/Unit/SimpleRequestTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'bin/wiki/vendor/addwiki/mediawiki-api-base/tests/Unit/SimpleRequestTest.php')
-rw-r--r--bin/wiki/vendor/addwiki/mediawiki-api-base/tests/Unit/SimpleRequestTest.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/bin/wiki/vendor/addwiki/mediawiki-api-base/tests/Unit/SimpleRequestTest.php b/bin/wiki/vendor/addwiki/mediawiki-api-base/tests/Unit/SimpleRequestTest.php
new file mode 100644
index 00000000..df979992
--- /dev/null
+++ b/bin/wiki/vendor/addwiki/mediawiki-api-base/tests/Unit/SimpleRequestTest.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Mediawiki\Api\Test\Unit;
+
+use Mediawiki\Api\SimpleRequest;
+use PHPUnit_Framework_TestCase;
+
+/**
+ * @author Addshore
+ *
+ * @covers Mediawiki\Api\SimpleRequest
+ */
+class SimpleRequestTest extends PHPUnit_Framework_TestCase {
+
+ /**
+ * @dataProvider provideValidConstruction
+ */
+ public function testValidConstruction( $action, $params, $expected, $headers = [] ) {
+ $request = new SimpleRequest( $action, $params, $headers );
+ $this->assertEquals( $expected, $request->getParams() );
+ $this->assertEquals( $headers, $request->getHeaders() );
+ }
+
+ public function provideValidConstruction() {
+ return [
+ [ 'action', [], [ 'action' => 'action' ] ],
+ [ '1123', [], [ 'action' => '1123' ] ],
+ [ 'a', [ 'b' => 'c' ], [ 'action' => 'a', 'b' => 'c' ] ],
+ [ 'a', [ 'b' => 'c', 'd' => 'e' ], [ 'action' => 'a', 'b' => 'c', 'd' => 'e' ] ],
+ [ 'a', [ 'b' => 'c|d|e|f' ], [ 'action' => 'a', 'b' => 'c|d|e|f' ] ],
+ [ 'foo', [], [ 'action' => 'foo' ] ,[ 'foo' => 'bar' ] ],
+ ];
+ }
+
+ /**
+ * @dataProvider provideInvalidConstruction
+ */
+ public function testInvalidConstruction( $action, $params ) {
+ $this->setExpectedException( 'InvalidArgumentException' );
+ new SimpleRequest( $action, $params );
+ }
+
+ public function provideInvalidConstruction() {
+ return [
+ [ [], [] ],
+ ];
+ }
+
+}