wiki.techinc.nl/tests/phpunit/unit/includes/FormOptionsInitializationTest.php
libraryupgrader 5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00

70 lines
1.3 KiB
PHP

<?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(): void {
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
);
}
}