wiki.techinc.nl/tests/phpunit/unit/includes/FormOptionsInitializationTest.php

71 lines
1.3 KiB
PHP
Raw Normal View History

2011-02-28 20:58:34 +00:00
<?php
use Wikimedia\TestingAccessWrapper;
2011-02-28 20:58:34 +00:00
/**
* Test class for FormOptions initialization
* Ensure the FormOptions::add() does what we want it to do.
*
* Copyright © 2011, Antoine Musso
2011-02-28 20:58:34 +00:00
*
* @author Antoine Musso
2011-02-28 20:58:34 +00:00
*/
class FormOptionsInitializationTest extends \MediaWikiUnitTestCase {
2011-02-28 20:58:34 +00:00
/**
* @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() );
2011-02-28 20:58:34 +00:00
}
/**
* @covers FormOptions::add
*/
2011-02-28 20:58:34 +00:00
public function testAddStringOption() {
$this->object->add( 'foo', 'string value' );
2011-02-28 20:58:34 +00:00
$this->assertEquals(
[
'foo' => [
'default' => 'string value',
2011-02-28 20:58:34 +00:00
'consumed' => false,
'type' => FormOptions::STRING,
'value' => null,
]
],
$this->object->options
2011-02-28 20:58:34 +00:00
);
}
/**
* @covers FormOptions::add
*/
2011-02-28 20:58:34 +00:00
public function testAddIntegers() {
$this->object->add( 'one', 1 );
$this->object->add( 'negone', -1 );
2011-02-28 20:58:34 +00:00
$this->assertEquals(
[
'negone' => [
'default' => -1,
'value' => null,
2011-02-28 20:58:34 +00:00
'consumed' => false,
'type' => FormOptions::INT,
],
'one' => [
'default' => 1,
'value' => null,
2011-02-28 20:58:34 +00:00
'consumed' => false,
'type' => FormOptions::INT,
]
],
$this->object->options
2011-02-28 20:58:34 +00:00
);
}
}