MediaWiki  REL1_31
SpecialBooksourcesTest.php
Go to the documentation of this file.
1 <?php
3  public static function provideISBNs() {
4  return [
5  [ '978-0-300-14424-6', true ],
6  [ '0-14-020652-3', true ],
7  [ '020652-3', false ],
8  [ '9781234567897', true ],
9  [ '1-4133-0454-0', true ],
10  [ '978-1413304541', true ],
11  [ '0136091814', true ],
12  [ '0136091812', false ],
13  [ '9780136091813', true ],
14  [ '9780136091817', false ],
15  [ '123456789X', true ],
16 
17  // T69021
18  [ '1413304541', false ],
19  [ '141330454X', false ],
20  [ '1413304540', true ],
21  [ '14133X4540', false ],
22  [ '97814133X4541', false ],
23  [ '978035642615X', false ],
24  [ '9781413304541', true ],
25  [ '9780356426150', true ],
26  ];
27  }
28 
33  public function testIsValidISBN( $isbn, $isValid ) {
34  $this->assertSame( $isValid, SpecialBookSources::isValidISBN( $isbn ) );
35  }
36 
37  protected function newSpecialPage() {
38  return new SpecialBookSources();
39  }
40 
44  public function testExecute() {
45  list( $html, ) = $this->executeSpecialPage( 'Invalid', null, 'qqx' );
46  $this->assertContains( '(booksources-invalid-isbn)', $html );
47  list( $html, ) = $this->executeSpecialPage( '0-7475-3269-9', null, 'qqx' );
48  $this->assertNotContains( '(booksources-invalid-isbn)', $html );
49  $this->assertContains( '(booksources-text)', $html );
50  }
51 }
SpecialBooksourcesTest\testExecute
testExecute()
SpecialBookSources::execute.
Definition: SpecialBooksourcesTest.php:44
SpecialBooksourcesTest\newSpecialPage
newSpecialPage()
Returns a new instance of the special page under test.
Definition: SpecialBooksourcesTest.php:37
$html
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition: hooks.txt:2013
SpecialBooksourcesTest
Definition: SpecialBooksourcesTest.php:2
true
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:2006
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
SpecialPageTestBase
Base class for testing special pages.
Definition: SpecialPageTestBase.php:14
SpecialBookSources\isValidISBN
static isValidISBN( $isbn)
Return whether a given ISBN (10 or 13) is valid.
Definition: SpecialBooksources.php:71
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
SpecialBooksourcesTest\testIsValidISBN
testIsValidISBN( $isbn, $isValid)
SpecialBookSources::isValidISBN provideISBNs.
Definition: SpecialBooksourcesTest.php:33
SpecialPageTestBase\executeSpecialPage
executeSpecialPage( $subPage='', WebRequest $request=null, $language=null, User $user=null)
Definition: SpecialPageTestBase.php:57
SpecialBookSources
Special page outputs information on sourcing a book with a particular ISBN The parser creates links t...
Definition: SpecialBooksources.php:31
SpecialBooksourcesTest\provideISBNs
static provideISBNs()
Definition: SpecialBooksourcesTest.php:3
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187