c619dab805ebda7675c09ae7375f7938f916862d
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiTestCase.php
1 <?php
2
3 abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
4 public $suite;
5 public $regex = '';
6 public $runDisabled = false;
7
8 /**
9 * @var Array of TestUser
10 */
11 public static $users;
12
13 /**
14 * @var DatabaseBase
15 */
16 protected $db;
17 protected $tablesUsed = array(); // tables with data
18
19 private static $useTemporaryTables = true;
20 private static $reuseDB = false;
21 private static $dbSetup = false;
22 private static $oldTablePrefix = false;
23
24 /**
25 * Holds the paths of temporary files/directories created through getNewTempFile,
26 * and getNewTempDirectory
27 *
28 * @var array
29 */
30 private $tmpfiles = array();
31
32 /**
33 * Holds original values of MediaWiki configuration settings
34 * to be restored in tearDown().
35 * See also setMwGlobal().
36 * @var array
37 */
38 private $mwGlobals = array();
39
40 /**
41 * Table name prefixes. Oracle likes it shorter.
42 */
43 const DB_PREFIX = 'unittest_';
44 const ORA_DB_PREFIX = 'ut_';
45
46 protected $supportedDBs = array(
47 'mysql',
48 'sqlite',
49 'postgres',
50 'oracle'
51 );
52
53 function __construct( $name = null, array $data = array(), $dataName = '' ) {
54 parent::__construct( $name, $data, $dataName );
55
56 $this->backupGlobals = false;
57 $this->backupStaticAttributes = false;
58 }
59
60 function run( PHPUnit_Framework_TestResult $result = NULL ) {
61 /* Some functions require some kind of caching, and will end up using the db,
62 * which we can't allow, as that would open a new connection for mysql.
63 * Replace with a HashBag. They would not be going to persist anyway.
64 */
65 ObjectCache::$instances[CACHE_DB] = new HashBagOStuff;
66
67 if( $this->needsDB() ) {
68 // set up a DB connection for this test to use
69
70 self::$useTemporaryTables = !$this->getCliArg( 'use-normal-tables' );
71 self::$reuseDB = $this->getCliArg('reuse-db');
72
73 $this->db = wfGetDB( DB_MASTER );
74
75 $this->checkDbIsSupported();
76
77 if( !self::$dbSetup ) {
78 // switch to a temporary clone of the database
79 self::setupTestDB( $this->db, $this->dbPrefix() );
80
81 if ( ( $this->db->getType() == 'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) {
82 $this->resetDB();
83 }
84 }
85
86 $this->addCoreDBData();
87 $this->addDBData();
88
89 parent::run( $result );
90
91 $this->resetDB();
92 } else {
93 parent::run( $result );
94 }
95 }
96
97 /**
98 * obtains a new temporary file name
99 *
100 * The obtained filename is enlisted to be removed upon tearDown
101 *
102 * @returns string: absolute name of the temporary file
103 */
104 protected function getNewTempFile() {
105 $fname = tempnam( wfTempDir(), 'MW_PHPUnit_' . get_class( $this ) . '_' );
106 $this->tmpfiles[] = $fname;
107 return $fname;
108 }
109
110 /**
111 * obtains a new temporary directory
112 *
113 * The obtained directory is enlisted to be removed (recursively with all its contained
114 * files) upon tearDown.
115 *
116 * @returns string: absolute name of the temporary directory
117 */
118 protected function getNewTempDirectory() {
119 // Starting of with a temporary /file/.
120 $fname = $this->getNewTempFile();
121
122 // Converting the temporary /file/ to a /directory/
123 //
124 // The following is not atomic, but at least we now have a single place,
125 // where temporary directory creation is bundled and can be improved
126 unlink( $fname );
127 $this->assertTrue( wfMkdirParents( $fname ) );
128 return $fname;
129 }
130
131 /**
132 * setUp and tearDown should (where significant)
133 * happen in reverse order.
134 */
135 protected function setUp() {
136 parent::setUp();
137
138 /*
139 //@todo: global variables to restore for *every* test
140 array(
141 'wgLang',
142 'wgContLang',
143 'wgLanguageCode',
144 'wgUser',
145 'wgTitle',
146 );
147 */
148
149 // Cleaning up temporary files
150 foreach ( $this->tmpfiles as $fname ) {
151 if ( is_file( $fname ) || ( is_link( $fname ) ) ) {
152 unlink( $fname );
153 } elseif ( is_dir( $fname ) ) {
154 wfRecursiveRemoveDir( $fname );
155 }
156 }
157
158 // Clean up open transactions
159 if ( $this->needsDB() && $this->db ) {
160 while( $this->db->trxLevel() > 0 ) {
161 $this->db->rollback();
162 }
163 }
164 }
165
166 protected function tearDown() {
167 // Cleaning up temporary files
168 foreach ( $this->tmpfiles as $fname ) {
169 if ( is_file( $fname ) || ( is_link( $fname ) ) ) {
170 unlink( $fname );
171 } elseif ( is_dir( $fname ) ) {
172 wfRecursiveRemoveDir( $fname );
173 }
174 }
175
176 // Clean up open transactions
177 if ( $this->needsDB() && $this->db ) {
178 while( $this->db->trxLevel() > 0 ) {
179 $this->db->rollback();
180 }
181 }
182
183 // Restore mw globals
184 foreach ( $this->mwGlobals as $key => $value ) {
185 $GLOBALS[$key] = $value;
186 }
187 $this->mwGlobals = array();
188
189 parent::tearDown();
190 }
191
192 /**
193 * Individual test functions may override globals (either directly or through this
194 * setMwGlobals() function), however one must call this method at least once for
195 * each key within the setUp().
196 * That way the key is added to the array of globals that will be reset afterwards
197 * in the tearDown(). And, equally important, that way all other tests are executed
198 * with the same settings (instead of using the unreliable local settings for most
199 * tests and fix it only for some tests).
200 *
201 * @example
202 * <code>
203 * protected function setUp() {
204 * $this->setMwGlobals( 'wgRestrictStuff', true );
205 * }
206 *
207 * function testFoo() {}
208 *
209 * function testBar() {}
210 * $this->assertTrue( self::getX()->doStuff() );
211 *
212 * $this->setMwGlobals( 'wgRestrictStuff', false );
213 * $this->assertTrue( self::getX()->doStuff() );
214 * }
215 *
216 * function testQuux() {}
217 * </code>
218 *
219 * @param array|string $pairs Key to the global variable, or an array
220 * of key/value pairs.
221 * @param mixed $value Value to set the global to (ignored
222 * if an array is given as first argument).
223 */
224 protected function setMwGlobals( $pairs, $value = null ) {
225
226 // Normalize (string, value) to an array
227 if( is_string( $pairs ) ) {
228 $pairs = array( $pairs => $value );
229 }
230
231 foreach ( $pairs as $key => $value ) {
232 // NOTE: make sure we only save the global once or a second call to
233 // setMwGlobals() on the same global would override the original
234 // value.
235 if ( !array_key_exists( $key, $this->mwGlobals ) ) {
236 $this->mwGlobals[$key] = $GLOBALS[$key];
237 }
238
239 // Override the global
240 $GLOBALS[$key] = $value;
241 }
242 }
243
244 /**
245 * Merges the given values into a MW global array variable.
246 * Useful for setting some entries in a configuration array, instead of
247 * setting the entire array.
248 *
249 * @param String $name The name of the global, as in wgFooBar
250 * @param Array $values The array containing the entries to set in that global
251 *
252 * @throws MWException if the designated global is not an array.
253 */
254 protected function mergeMwGlobalArrayValue( $name, $values ) {
255 if ( !isset( $GLOBALS[$name] ) ) {
256 $merged = $values;
257 } else {
258 if ( !is_array( $GLOBALS[$name] ) ) {
259 throw new MWException( "MW global $name is not an array." );
260 }
261
262 // NOTE: do not use array_merge, it screws up for numeric keys.
263 $merged = $GLOBALS[$name];
264 foreach ( $values as $k => $v ) {
265 $merged[$k] = $v;
266 }
267 }
268
269 $this->setMwGlobals( $name, $merged );
270 }
271
272 function dbPrefix() {
273 return $this->db->getType() == 'oracle' ? self::ORA_DB_PREFIX : self::DB_PREFIX;
274 }
275
276 function needsDB() {
277 # if the test says it uses database tables, it needs the database
278 if ( $this->tablesUsed ) {
279 return true;
280 }
281
282 # if the test says it belongs to the Database group, it needs the database
283 $rc = new ReflectionClass( $this );
284 if ( preg_match( '/@group +Database/im', $rc->getDocComment() ) ) {
285 return true;
286 }
287
288 return false;
289 }
290
291 /**
292 * Stub. If a test needs to add additional data to the database, it should
293 * implement this method and do so
294 */
295 function addDBData() {}
296
297 private function addCoreDBData() {
298 # disabled for performance
299 #$this->tablesUsed[] = 'page';
300 #$this->tablesUsed[] = 'revision';
301
302 if ( $this->db->getType() == 'oracle' ) {
303
304 # Insert 0 user to prevent FK violations
305 # Anonymous user
306 $this->db->insert( 'user', array(
307 'user_id' => 0,
308 'user_name' => 'Anonymous' ), __METHOD__, array( 'IGNORE' ) );
309
310 # Insert 0 page to prevent FK violations
311 # Blank page
312 $this->db->insert( 'page', array(
313 'page_id' => 0,
314 'page_namespace' => 0,
315 'page_title' => ' ',
316 'page_restrictions' => NULL,
317 'page_counter' => 0,
318 'page_is_redirect' => 0,
319 'page_is_new' => 0,
320 'page_random' => 0,
321 'page_touched' => $this->db->timestamp(),
322 'page_latest' => 0,
323 'page_len' => 0 ), __METHOD__, array( 'IGNORE' ) );
324
325 }
326
327 User::resetIdByNameCache();
328
329 //Make sysop user
330 $user = User::newFromName( 'UTSysop' );
331
332 if ( $user->idForName() == 0 ) {
333 $user->addToDatabase();
334 $user->setPassword( 'UTSysopPassword' );
335
336 $user->addGroup( 'sysop' );
337 $user->addGroup( 'bureaucrat' );
338 $user->saveSettings();
339 }
340
341
342 //Make 1 page with 1 revision
343 $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
344 if ( !$page->getId() == 0 ) {
345 $page->doEditContent(
346 new WikitextContent( 'UTContent' ),
347 'UTPageSummary',
348 EDIT_NEW,
349 false,
350 User::newFromName( 'UTSysop' ) );
351 }
352 }
353
354 /**
355 * Restores MediaWiki to using the table set (table prefix) it was using before
356 * setupTestDB() was called. Useful if we need to perform database operations
357 * after the test run has finished (such as saving logs or profiling info).
358 */
359 public static function teardownTestDB() {
360 if ( !self::$dbSetup ) {
361 return;
362 }
363
364 CloneDatabase::changePrefix( self::$oldTablePrefix );
365
366 self::$oldTablePrefix = false;
367 self::$dbSetup = false;
368 }
369
370 /**
371 * Creates an empty skeleton of the wiki database by cloning its structure
372 * to equivalent tables using the given $prefix. Then sets MediaWiki to
373 * use the new set of tables (aka schema) instead of the original set.
374 *
375 * This is used to generate a dummy table set, typically consisting of temporary
376 * tables, that will be used by tests instead of the original wiki database tables.
377 *
378 * @note: the original table prefix is stored in self::$oldTablePrefix. This is used
379 * by teardownTestDB() to return the wiki to using the original table set.
380 *
381 * @note: this method only works when first called. Subsequent calls have no effect,
382 * even if using different parameters.
383 *
384 * @param DatabaseBase $db The database connection
385 * @param String $prefix The prefix to use for the new table set (aka schema).
386 *
387 * @throws MWException if the database table prefix is already $prefix
388 */
389 public static function setupTestDB( DatabaseBase $db, $prefix ) {
390 global $wgDBprefix;
391 if ( $wgDBprefix === $prefix ) {
392 throw new MWException( 'Cannot run unit tests, the database prefix is already "' . $prefix . '"' );
393 }
394
395 if ( self::$dbSetup ) {
396 return;
397 }
398
399 $tablesCloned = self::listTables( $db );
400 $dbClone = new CloneDatabase( $db, $tablesCloned, $prefix );
401 $dbClone->useTemporaryTables( self::$useTemporaryTables );
402
403 self::$dbSetup = true;
404 self::$oldTablePrefix = $wgDBprefix;
405
406 if ( ( $db->getType() == 'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) {
407 CloneDatabase::changePrefix( $prefix );
408 return;
409 } else {
410 $dbClone->cloneTableStructure();
411 }
412
413 if ( $db->getType() == 'oracle' ) {
414 $db->query( 'BEGIN FILL_WIKI_INFO; END;' );
415 }
416 }
417
418 /**
419 * Empty all tables so they can be repopulated for tests
420 */
421 private function resetDB() {
422 if( $this->db ) {
423 if ( $this->db->getType() == 'oracle' ) {
424 if ( self::$useTemporaryTables ) {
425 wfGetLB()->closeAll();
426 $this->db = wfGetDB( DB_MASTER );
427 } else {
428 foreach( $this->tablesUsed as $tbl ) {
429 if( $tbl == 'interwiki') continue;
430 $this->db->query( 'TRUNCATE TABLE '.$this->db->tableName($tbl), __METHOD__ );
431 }
432 }
433 } else {
434 foreach( $this->tablesUsed as $tbl ) {
435 if( $tbl == 'interwiki' || $tbl == 'user' ) continue;
436 $this->db->delete( $tbl, '*', __METHOD__ );
437 }
438 }
439 }
440 }
441
442 function __call( $func, $args ) {
443 static $compatibility = array(
444 'assertInternalType' => 'assertType',
445 'assertNotInternalType' => 'assertNotType',
446 'assertInstanceOf' => 'assertType',
447 'assertEmpty' => 'assertEmpty2',
448 );
449
450 if ( method_exists( $this->suite, $func ) ) {
451 return call_user_func_array( array( $this->suite, $func ), $args);
452 } elseif ( isset( $compatibility[$func] ) ) {
453 return call_user_func_array( array( $this, $compatibility[$func] ), $args);
454 } else {
455 throw new MWException( "Called non-existant $func method on "
456 . get_class( $this ) );
457 }
458 }
459
460 private function assertEmpty2( $value, $msg ) {
461 return $this->assertTrue( $value == '', $msg );
462 }
463
464 static private function unprefixTable( $tableName ) {
465 global $wgDBprefix;
466 return substr( $tableName, strlen( $wgDBprefix ) );
467 }
468
469 static private function isNotUnittest( $table ) {
470 return strpos( $table, 'unittest_' ) !== 0;
471 }
472
473 public static function listTables( $db ) {
474 global $wgDBprefix;
475
476 $tables = $db->listTables( $wgDBprefix, __METHOD__ );
477 $tables = array_map( array( __CLASS__, 'unprefixTable' ), $tables );
478
479 // Don't duplicate test tables from the previous fataled run
480 $tables = array_filter( $tables, array( __CLASS__, 'isNotUnittest' ) );
481
482 if ( $db->getType() == 'sqlite' ) {
483 $tables = array_flip( $tables );
484 // these are subtables of searchindex and don't need to be duped/dropped separately
485 unset( $tables['searchindex_content'] );
486 unset( $tables['searchindex_segdir'] );
487 unset( $tables['searchindex_segments'] );
488 $tables = array_flip( $tables );
489 }
490 return $tables;
491 }
492
493 protected function checkDbIsSupported() {
494 if( !in_array( $this->db->getType(), $this->supportedDBs ) ) {
495 throw new MWException( $this->db->getType() . " is not currently supported for unit testing." );
496 }
497 }
498
499 public function getCliArg( $offset ) {
500
501 if( isset( MediaWikiPHPUnitCommand::$additionalOptions[$offset] ) ) {
502 return MediaWikiPHPUnitCommand::$additionalOptions[$offset];
503 }
504
505 }
506
507 public function setCliArg( $offset, $value ) {
508
509 MediaWikiPHPUnitCommand::$additionalOptions[$offset] = $value;
510
511 }
512
513 /**
514 * Don't throw a warning if $function is deprecated and called later
515 *
516 * @param $function String
517 * @return null
518 */
519 function hideDeprecated( $function ) {
520 wfSuppressWarnings();
521 wfDeprecated( $function );
522 wfRestoreWarnings();
523 }
524
525 /**
526 * Asserts that the given database query yields the rows given by $expectedRows.
527 * The expected rows should be given as indexed (not associative) arrays, with
528 * the values given in the order of the columns in the $fields parameter.
529 * Note that the rows are sorted by the columns given in $fields.
530 *
531 * @since 1.20
532 *
533 * @param $table String|Array the table(s) to query
534 * @param $fields String|Array the columns to include in the result (and to sort by)
535 * @param $condition String|Array "where" condition(s)
536 * @param $expectedRows Array - an array of arrays giving the expected rows.
537 *
538 * @throws MWException if this test cases's needsDB() method doesn't return true.
539 * Test cases can use "@group Database" to enable database test support,
540 * or list the tables under testing in $this->tablesUsed, or override the
541 * needsDB() method.
542 */
543 protected function assertSelect( $table, $fields, $condition, array $expectedRows ) {
544 if ( !$this->needsDB() ) {
545 throw new MWException( 'When testing database state, the test cases\'s needDB()' .
546 ' method should return true. Use @group Database or $this->tablesUsed.');
547 }
548
549 $db = wfGetDB( DB_SLAVE );
550
551 $res = $db->select( $table, $fields, $condition, wfGetCaller(), array( 'ORDER BY' => $fields ) );
552 $this->assertNotEmpty( $res, "query failed: " . $db->lastError() );
553
554 $i = 0;
555
556 foreach ( $expectedRows as $expected ) {
557 $r = $res->fetchRow();
558 self::stripStringKeys( $r );
559
560 $i += 1;
561 $this->assertNotEmpty( $r, "row #$i missing" );
562
563 $this->assertEquals( $expected, $r, "row #$i mismatches" );
564 }
565
566 $r = $res->fetchRow();
567 self::stripStringKeys( $r );
568
569 $this->assertFalse( $r, "found extra row (after #$i)" );
570 }
571
572 /**
573 * Utility method taking an array of elements and wrapping
574 * each element in it's own array. Useful for data providers
575 * that only return a single argument.
576 *
577 * @since 1.20
578 *
579 * @param array $elements
580 *
581 * @return array
582 */
583 protected function arrayWrap( array $elements ) {
584 return array_map(
585 function( $element ) {
586 return array( $element );
587 },
588 $elements
589 );
590 }
591
592 /**
593 * Assert that two arrays are equal. By default this means that both arrays need to hold
594 * the same set of values. Using additional arguments, order and associated key can also
595 * be set as relevant.
596 *
597 * @since 1.20
598 *
599 * @param array $expected
600 * @param array $actual
601 * @param boolean $ordered If the order of the values should match
602 * @param boolean $named If the keys should match
603 */
604 protected function assertArrayEquals( array $expected, array $actual, $ordered = false, $named = false ) {
605 if ( !$ordered ) {
606 $this->objectAssociativeSort( $expected );
607 $this->objectAssociativeSort( $actual );
608 }
609
610 if ( !$named ) {
611 $expected = array_values( $expected );
612 $actual = array_values( $actual );
613 }
614
615 call_user_func_array(
616 array( $this, 'assertEquals' ),
617 array_merge( array( $expected, $actual ), array_slice( func_get_args(), 4 ) )
618 );
619 }
620
621 /**
622 * Put each HTML element on its own line and then equals() the results
623 *
624 * Use for nicely formatting of PHPUnit diff output when comparing very
625 * simple HTML
626 *
627 * @since 1.20
628 *
629 * @param String $expected HTML on oneline
630 * @param String $actual HTML on oneline
631 * @param String $msg Optional message
632 */
633 protected function assertHTMLEquals( $expected, $actual, $msg='' ) {
634 $expected = str_replace( '>', ">\n", $expected );
635 $actual = str_replace( '>', ">\n", $actual );
636
637 $this->assertEquals( $expected, $actual, $msg );
638 }
639
640 /**
641 * Does an associative sort that works for objects.
642 *
643 * @since 1.20
644 *
645 * @param array $array
646 */
647 protected function objectAssociativeSort( array &$array ) {
648 uasort(
649 $array,
650 function( $a, $b ) {
651 return serialize( $a ) > serialize( $b ) ? 1 : -1;
652 }
653 );
654 }
655
656 /**
657 * Utility function for eliminating all string keys from an array.
658 * Useful to turn a database result row as returned by fetchRow() into
659 * a pure indexed array.
660 *
661 * @since 1.20
662 *
663 * @param $r mixed the array to remove string keys from.
664 */
665 protected static function stripStringKeys( &$r ) {
666 if ( !is_array( $r ) ) {
667 return;
668 }
669
670 foreach ( $r as $k => $v ) {
671 if ( is_string( $k ) ) {
672 unset( $r[$k] );
673 }
674 }
675 }
676
677 /**
678 * Asserts that the provided variable is of the specified
679 * internal type or equals the $value argument. This is useful
680 * for testing return types of functions that return a certain
681 * type or *value* when not set or on error.
682 *
683 * @since 1.20
684 *
685 * @param string $type
686 * @param mixed $actual
687 * @param mixed $value
688 * @param string $message
689 */
690 protected function assertTypeOrValue( $type, $actual, $value = false, $message = '' ) {
691 if ( $actual === $value ) {
692 $this->assertTrue( true, $message );
693 }
694 else {
695 $this->assertType( $type, $actual, $message );
696 }
697 }
698
699 /**
700 * Asserts the type of the provided value. This can be either
701 * in internal type such as boolean or integer, or a class or
702 * interface the value extends or implements.
703 *
704 * @since 1.20
705 *
706 * @param string $type
707 * @param mixed $actual
708 * @param string $message
709 */
710 protected function assertType( $type, $actual, $message = '' ) {
711 if ( class_exists( $type ) || interface_exists( $type ) ) {
712 $this->assertInstanceOf( $type, $actual, $message );
713 }
714 else {
715 $this->assertInternalType( $type, $actual, $message );
716 }
717 }
718
719 /**
720 * Returns true iff the given namespace defaults to Wikitext
721 * according to $wgNamespaceContentModels
722 *
723 * @param int $ns The namespace ID to check
724 *
725 * @return bool
726 * @since 1.21
727 */
728 protected function isWikitextNS( $ns ) {
729 global $wgNamespaceContentModels;
730
731 if ( isset( $wgNamespaceContentModels[$ns] ) ) {
732 return $wgNamespaceContentModels[$ns] === CONTENT_MODEL_WIKITEXT;
733 }
734
735 return true;
736 }
737
738 /**
739 * Returns the ID of a namespace that defaults to Wikitext.
740 * Throws an MWException if there is none.
741 *
742 * @return int the ID of the wikitext Namespace
743 * @since 1.21
744 */
745 protected function getDefaultWikitextNS() {
746 global $wgNamespaceContentModels;
747
748 static $wikitextNS = null; // this is not going to change
749 if ( $wikitextNS !== null ) {
750 return $wikitextNS;
751 }
752
753 // quickly short out on most common case:
754 if ( !isset( $wgNamespaceContentModels[NS_MAIN] ) ) {
755 return NS_MAIN;
756 }
757
758 // NOTE: prefer content namespaces
759 $namespaces = array_unique( array_merge(
760 MWNamespace::getContentNamespaces(),
761 array( NS_MAIN, NS_HELP, NS_PROJECT ), // prefer these
762 MWNamespace::getValidNamespaces()
763 ) );
764
765 $namespaces = array_diff( $namespaces, array(
766 NS_FILE, NS_CATEGORY, NS_MEDIAWIKI, NS_USER // don't mess with magic namespaces
767 ));
768
769 $talk = array_filter( $namespaces, function ( $ns ) {
770 return MWNamespace::isTalk( $ns );
771 } );
772
773 // prefer non-talk pages
774 $namespaces = array_diff( $namespaces, $talk );
775 $namespaces = array_merge( $namespaces, $talk );
776
777 // check default content model of each namespace
778 foreach ( $namespaces as $ns ) {
779 if ( !isset( $wgNamespaceContentModels[$ns] ) ||
780 $wgNamespaceContentModels[$ns] === CONTENT_MODEL_WIKITEXT ) {
781
782 $wikitextNS = $ns;
783 return $wikitextNS;
784 }
785 }
786
787 // give up
788 // @todo: Inside a test, we could skip the test as incomplete.
789 // But frequently, this is used in fixture setup.
790 throw new MWException( "No namespace defaults to wikitext!" );
791 }
792 }