wiki.techinc.nl/tests/phpunit/unit/includes/FormOptionsInitializationTest.php
Func 4d1da6f7f8 phpunit: Update @covers annotations for namespaced classes
We renamed many classes to be namespaced, but the `@covers` and
`@coversDefaultClass` annotations weren't updated properly.

PHPUnit didn't support short cover annotations with `use` statements,
these didn't trigger any errors yet, because they are class alias.

This patch is populated by a modified version of PhpunitAnnotationsSniff.

Change-Id: I6c602290a30099239b17d2dc0d67b1488b4eaeeb
2023-05-27 17:43:12 +08:00

71 lines
1.4 KiB
PHP

<?php
use MediaWiki\Html\FormOptions;
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 MediaWiki\Html\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 MediaWiki\Html\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
);
}
}