aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit/includes/FormOptionsInitializationTest.php
diff options
context:
space:
mode:
authorMáté Szabó <mszabo@wikia-inc.com>2019-06-30 15:23:53 +0200
committerMáté Szabó <mszabo@wikia-inc.com>2019-06-30 15:23:53 +0200
commit344481f60d92ac9295129c5089c0fe467ff497b9 (patch)
treedb19c9c01b006294ef684340f27e8942aca79d24 /tests/phpunit/unit/includes/FormOptionsInitializationTest.php
parente93b90e4290093e3165c66338db24c7dbe84cf48 (diff)
downloadmediawikicore-344481f60d92ac9295129c5089c0fe467ff497b9.tar.gz
mediawikicore-344481f60d92ac9295129c5089c0fe467ff497b9.zip
Move trivially compatible tests to the unit tests suite
This changeset resumes work on T89432 and related tickets by porting an initial set of tests to the new unit test suite separated out in I69b92db3e70093570e05cc0a64c7780a278b321a. The tests were only ported if they worked immediately without requiring any changes other than changing the test case class to MediaWikiUnitTestCase and moving the test to the new suite. If a test failed for any reason (even trivial misconfiguration), it was NOT ported. With this change, the unit tests suite now consits of a total of 455 tests. As before, you can run these tests via the following command: $ composer phpunit:unit Bug: T84948 Bug: T89432 Bug: T87781 Change-Id: Ibb8175981092d7f41864e641cc3c118af70a5c76
Diffstat (limited to 'tests/phpunit/unit/includes/FormOptionsInitializationTest.php')
-rw-r--r--tests/phpunit/unit/includes/FormOptionsInitializationTest.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/phpunit/unit/includes/FormOptionsInitializationTest.php b/tests/phpunit/unit/includes/FormOptionsInitializationTest.php
new file mode 100644
index 000000000000..708956d260f1
--- /dev/null
+++ b/tests/phpunit/unit/includes/FormOptionsInitializationTest.php
@@ -0,0 +1,70 @@
+<?php
+
+use Wikimedia\TestingAccessWrapper;
+
+/**
+ * Test class for FormOptions initialization
+ * Ensure the FormOptions::add() does what we want it to do.
+ *
+ * Copyright © 2011, Antoine Musso
+ *
+ * @author Antoine Musso
+ */
+class FormOptionsInitializationTest extends \MediaWikiUnitTestCase {
+ /**
+ * @var FormOptions
+ */
+ protected $object;
+
+ /**
+ * A new fresh and empty FormOptions object to test initialization
+ * with.
+ */
+ protected function setUp() {
+ parent::setUp();
+ $this->object = TestingAccessWrapper::newFromObject( new FormOptions() );
+ }
+
+ /**
+ * @covers FormOptions::add
+ */
+ public function testAddStringOption() {
+ $this->object->add( 'foo', 'string value' );
+ $this->assertEquals(
+ [
+ 'foo' => [
+ 'default' => 'string value',
+ 'consumed' => false,
+ 'type' => FormOptions::STRING,
+ 'value' => null,
+ ]
+ ],
+ $this->object->options
+ );
+ }
+
+ /**
+ * @covers FormOptions::add
+ */
+ public function testAddIntegers() {
+ $this->object->add( 'one', 1 );
+ $this->object->add( 'negone', -1 );
+ $this->assertEquals(
+ [
+ 'negone' => [
+ 'default' => -1,
+ 'value' => null,
+ 'consumed' => false,
+ 'type' => FormOptions::INT,
+ ],
+ 'one' => [
+ 'default' => 1,
+ 'value' => null,
+ 'consumed' => false,
+ 'type' => FormOptions::INT,
+ ]
+ ],
+ $this->object->options
+ );
+ }
+}