| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Tests\Unit\EditPage; |
| 22 |
|
| 23 |
use MediaWiki\EditPage\TextboxBuilder; |
| 24 |
use MediaWikiUnitTestCase; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
class TextboxBuilderTest extends MediaWikiUnitTestCase { |
| 32 |
|
| 33 |
public static function provideAddNewLineAtEnd() { |
| 34 |
return [ |
| 35 |
[ '', '' ], |
| 36 |
[ 'foo', "foo\n" ], |
| 37 |
]; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public function testAddNewLineAtEnd( $input, $expected ) { |
| 44 |
$builder = new TextboxBuilder(); |
| 45 |
$this->assertSame( $expected, $builder->addNewLineAtEnd( $input ) ); |
| 46 |
} |
| 47 |
|
| 48 |
public static function provideMergeClassesIntoAttributes() { |
| 49 |
return [ |
| 50 |
[ |
| 51 |
[], |
| 52 |
[], |
| 53 |
[], |
| 54 |
], |
| 55 |
[ |
| 56 |
[ 'mw-new-classname' ], |
| 57 |
[], |
| 58 |
[ 'class' => 'mw-new-classname' ], |
| 59 |
], |
| 60 |
[ |
| 61 |
[], |
| 62 |
[ 'title' => 'My Title' ], |
| 63 |
[ 'title' => 'My Title' ], |
| 64 |
], |
| 65 |
[ |
| 66 |
[ 'mw-new-classname' ], |
| 67 |
[ 'title' => 'My Title' ], |
| 68 |
[ 'title' => 'My Title', 'class' => 'mw-new-classname' ], |
| 69 |
], |
| 70 |
[ |
| 71 |
[ 'mw-new-classname' ], |
| 72 |
[ 'class' => 'mw-existing-classname' ], |
| 73 |
[ 'class' => 'mw-existing-classname mw-new-classname' ], |
| 74 |
], |
| 75 |
[ |
| 76 |
[ 'mw-new-classname', 'mw-existing-classname' ], |
| 77 |
[ 'class' => 'mw-existing-classname' ], |
| 78 |
[ 'class' => 'mw-existing-classname mw-new-classname' ], |
| 79 |
], |
| 80 |
]; |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
public function testMergeClassesIntoAttributes( $inputClasses, $inputAttributes, $expected ) { |
| 87 |
$builder = new TextboxBuilder(); |
| 88 |
$this->assertSame( |
| 89 |
$expected, |
| 90 |
$builder->mergeClassesIntoAttributes( $inputClasses, $inputAttributes ) |
| 91 |
); |
| 92 |
} |
| 93 |
|
| 94 |
} |