Merge "Drop cache interwiki"
[mediawiki.git] / tests / phpunit / includes / specials / SpecialBookSourcesTest.php
blobf9cfae00f7f01b90e26f727b4f709886ff1b5e54
1 <?php
3 use MediaWiki\Specials\SpecialBookSources;
4 use MediaWiki\Title\TitleFactory;
6 class SpecialBookSourcesTest extends SpecialPageTestBase {
7 public static function provideISBNs() {
8 return [
9 [ '978-0-300-14424-6', true ],
10 [ '0-14-020652-3', true ],
11 [ '020652-3', false ],
12 [ '9781234567897', true ],
13 [ '1-4133-0454-0', true ],
14 [ '978-1413304541', true ],
15 [ '0136091814', true ],
16 [ '0136091812', false ],
17 [ '9780136091813', true ],
18 [ '9780136091817', false ],
19 [ '123456789X', true ],
21 // T69021
22 [ '1413304541', false ],
23 [ '141330454X', false ],
24 [ '1413304540', true ],
25 [ '14133X4540', false ],
26 [ '97814133X4541', false ],
27 [ '978035642615X', false ],
28 [ '9781413304541', true ],
29 [ '9780356426150', true ],
33 /**
34 * @covers \MediaWiki\Specials\SpecialBookSources::isValidISBN
35 * @dataProvider provideISBNs
37 public function testIsValidISBN( $isbn, $isValid ) {
38 $this->assertSame( $isValid, SpecialBookSources::isValidISBN( $isbn ) );
41 protected function newSpecialPage() {
42 $services = $this->getServiceContainer();
43 return new SpecialBookSources(
44 $services->getRevisionLookup(),
45 $services->getTitleFactory()
49 /**
50 * @covers \MediaWiki\Specials\SpecialBookSources::execute
52 public function testExecute() {
53 $this->setService( 'TitleFactory', $this->createMock( TitleFactory::class ) );
54 [ $html, ] = $this->executeSpecialPage( 'Invalid', null, 'qqx' );
55 $this->assertStringContainsString( '(booksources-invalid-isbn)', $html );
56 [ $html, ] = $this->executeSpecialPage( '0-7475-3269-9', null, 'qqx' );
57 $this->assertStringNotContainsString( '(booksources-invalid-isbn)', $html );
58 $this->assertStringContainsString( '(booksources-text)', $html );