MediaWiki  1.23.14
ORMTableTest.php
Go to the documentation of this file.
1 <?php
37 
42  protected function getTableClass() {
43  return 'PageORMTableForTesting';
44  }
45 
50  public function getTable() {
51  $class = $this->getTableClass();
52 
53  return $class::singleton();
54  }
55 
60  public function getRowClass() {
61  return $this->getTable()->getRowClass();
62  }
63 
67  public function testSingleton() {
68  $class = $this->getTableClass();
69 
70  $this->assertInstanceOf( $class, $class::singleton() );
71  $this->assertTrue( $class::singleton() === $class::singleton() );
72  }
73 
77  public function testIgnoreErrorsOverride() {
78  $table = $this->getTable();
79 
80  $db = $table->getReadDbConnection();
81  $db->ignoreErrors( true );
82 
83  try {
84  $table->rawSelect( "this is invalid" );
85  $this->fail( "An invalid query should trigger a DBQueryError even if ignoreErrors is enabled." );
86  } catch ( DBQueryError $ex ) {
87  $this->assertTrue( true, "just making phpunit happy" );
88  }
89 
90  $db->ignoreErrors( false );
91  }
92 }
93 
101 
107  public function getName() {
108  return 'page';
109  }
110 
116  public function getRowClass() {
117  return 'Title';
118  }
119 
125  public function newRow( array $data, $loadDefaults = false ) {
126  return Title::makeTitle( $data['namespace'], $data['title'] );
127  }
128 
134  public function getFields() {
135  return array(
136  'id' => 'int',
137  'namespace' => 'int',
138  'title' => 'str',
139  );
140  }
141 
147  protected function getFieldPrefix() {
148  return 'page_';
149  }
150 }
ORMTableTest\testSingleton
testSingleton()
Definition: ORMTableTest.php:67
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ORMTableTest\getTableClass
getTableClass()
Definition: ORMTableTest.php:42
ORMTable
Definition: ORMTable.php:31
ORMTableTest\getRowClass
getRowClass()
Definition: ORMTableTest.php:60
fail
as a message key or array as accepted by ApiBase::dieUsageMsg after processing request parameters Return false to let the request fail
Definition: hooks.txt:375
PageORMTableForTesting\getName
getName()
Definition: ORMTableTest.php:107
PageORMTableForTesting\getFieldPrefix
getFieldPrefix()
Definition: ORMTableTest.php:147
DBQueryError
Definition: DatabaseError.php:306
PageORMTableForTesting
Dummy ORM table for testing, reading Title objects from the page table.
Definition: ORMTableTest.php:100
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
DatabaseBase\ignoreErrors
ignoreErrors( $ignoreErrors=null)
Turns on (false) or off (true) the automatic generation and sending of a "we're sorry,...
Definition: Database.php:388
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
PageORMTableForTesting\getRowClass
getRowClass()
Definition: ORMTableTest.php:116
MediaWikiTestCase\$db
DatabaseBase $db
Definition: MediaWikiTestCase.php:31
ORMTableTest
@covers PageORMTableForTesting
Definition: ORMTableTest.php:36
ORMTableTest\testIgnoreErrorsOverride
testIgnoreErrorsOverride()
Definition: ORMTableTest.php:77
PageORMTableForTesting\newRow
newRow(array $data, $loadDefaults=false)
Definition: ORMTableTest.php:125
PageORMTableForTesting\getFields
getFields()
Definition: ORMTableTest.php:134
ORMTableTest\getTable
getTable()
Definition: ORMTableTest.php:50