| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\Context\RequestContext; |
| 4 |
use MediaWiki\HookContainer\HookRunner; |
| 5 |
use MediaWiki\SpecialPage\SpecialPage; |
| 6 |
use MediaWiki\Specials\Contribute\Card\ContributeCard; |
| 7 |
use MediaWiki\Specials\Contribute\Card\ContributeCardActionLink; |
| 8 |
use MediaWiki\Specials\Contribute\ContributeFactory; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
class ContributeFactoryTest extends MediaWikiIntegrationTestCase { |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
public function testGetCards() { |
| 21 |
$context = RequestContext::getMain(); |
| 22 |
$services = $this->getServiceContainer(); |
| 23 |
$hookContainer = $services->getHookContainer(); |
| 24 |
$factory = new ContributeFactory( |
| 25 |
$context, |
| 26 |
new HookRunner( $hookContainer ) |
| 27 |
); |
| 28 |
$cards = $factory->getCards(); |
| 29 |
$this->assertIsArray( $cards ); |
| 30 |
$this->assertNotEmpty( $cards ); |
| 31 |
$defaltCard = $cards[ count( $cards ) - 1 ]; |
| 32 |
$expectedCard = ( new ContributeCard( |
| 33 |
$context->msg( 'newpage' )->text(), |
| 34 |
$context->msg( 'newpage-desc' )->text(), |
| 35 |
'article', |
| 36 |
new ContributeCardActionLink( |
| 37 |
SpecialPage::getSafeTitleFor( 'Wantedpages' )->getLocalURL(), |
| 38 |
$context->msg( 'view-missing-pages' )->text() |
| 39 |
) ) )->toArray(); |
| 40 |
$this->assertArrayEquals( [ 'title', 'icon', 'description', 'action' ], array_keys( $defaltCard ) ); |
| 41 |
$this->assertArrayEquals( $expectedCard, $defaltCard ); |
| 42 |
} |
| 43 |
|
| 44 |
} |