diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php |
first commit
Diffstat (limited to 'www/wiki/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php')
-rw-r--r-- | www/wiki/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/www/wiki/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php b/www/wiki/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php new file mode 100644 index 00000000..6190516e --- /dev/null +++ b/www/wiki/tests/phpunit/includes/changes/ChangesListFilterGroupTest.php @@ -0,0 +1,79 @@ +<?php + +/** + * @covers ChangesListFilterGroup + */ +class ChangesListFilterGroupTest extends MediaWikiTestCase { + /** + * phpcs:disable Generic.Files.LineLength + * @expectedException MWException + * @expectedExceptionMessage Group names may not contain '_'. Use the naming convention: 'camelCase' + * phpcs:enable + */ + public function testReservedCharacter() { + new MockChangesListFilterGroup( + [ + 'type' => 'some_type', + 'name' => 'group_name', + 'priority' => 1, + 'filters' => [], + ] + ); + } + + public function testAutoPriorities() { + $group = new MockChangesListFilterGroup( + [ + 'type' => 'some_type', + 'name' => 'groupName', + 'isFullCoverage' => true, + 'priority' => 1, + 'filters' => [ + [ 'name' => 'hidefoo' ], + [ 'name' => 'hidebar' ], + [ 'name' => 'hidebaz' ], + ], + ] + ); + + $filters = $group->getFilters(); + $this->assertEquals( + [ + -2, + -3, + -4, + ], + array_map( + function ( $f ) { + return $f->getPriority(); + }, + array_values( $filters ) + ) + ); + } + + // Get without warnings + public function testGetFilter() { + $group = new MockChangesListFilterGroup( + [ + 'type' => 'some_type', + 'name' => 'groupName', + 'isFullCoverage' => true, + 'priority' => 1, + 'filters' => [ + [ 'name' => 'foo' ], + ], + ] + ); + + $this->assertEquals( + 'foo', + $group->getFilter( 'foo' )->getName() + ); + + $this->assertEquals( + null, + $group->getFilter( 'bar' ) + ); + } +} |