10 class ApiParseTest
extends ApiTestCase
{
12 protected static $pageId;
13 protected static $revIds = [];
15 public function addDBDataOnce() {
16 $title = Title
::newFromText( __CLASS__
);
18 $status = $this->editPage( __CLASS__
, 'Test for revdel' );
19 self
::$pageId = $status->value
['revision']->getPage();
20 self
::$revIds['revdel'] = $status->value
['revision']->getId();
22 $status = $this->editPage( __CLASS__
, 'Test for suppressed' );
23 self
::$revIds['suppressed'] = $status->value
['revision']->getId();
25 $status = $this->editPage( __CLASS__
, 'Test for oldid' );
26 self
::$revIds['oldid'] = $status->value
['revision']->getId();
28 $status = $this->editPage( __CLASS__
, 'Test for latest' );
29 self
::$revIds['latest'] = $status->value
['revision']->getId();
31 $this->revisionDelete( self
::$revIds['revdel'] );
32 $this->revisionDelete(
33 self
::$revIds['suppressed'],
34 [ Revision
::DELETED_TEXT
=> 1, Revision
::DELETED_RESTRICTED
=> 1 ]
37 Title
::clearCaches(); // Otherwise it has the wrong latest revision for some reason
41 * Assert that the given result of calling $this->doApiRequest() with
42 * action=parse resulted in $html, accounting for the boilerplate that the
43 * parser adds around the parsed page. Also asserts that warnings match
44 * the provided $warning.
46 * @param string $html Expected HTML
47 * @param array $res Returned from doApiRequest()
48 * @param string|null $warnings Exact value of expected warnings, null for
51 protected function assertParsedTo( $expected, array $res, $warnings = null ) {
52 $this->doAssertParsedTo( $expected, $res, $warnings, [ $this, 'assertSame' ] );
56 * Same as above, but asserts that the HTML matches a regexp instead of a
57 * literal string match.
59 * @param string $html Expected HTML
60 * @param array $res Returned from doApiRequest()
61 * @param string|null $warnings Exact value of expected warnings, null for
64 protected function assertParsedToRegExp( $expected, array $res, $warnings = null ) {
65 $this->doAssertParsedTo( $expected, $res, $warnings, [ $this, 'assertRegExp' ] );
68 private function doAssertParsedTo( $expected, array $res, $warnings, callable
$callback ) {
69 $html = $res[0]['parse']['text'];
71 $expectedStart = '<div class="mw-parser-output">';
72 $this->assertSame( $expectedStart, substr( $html, 0, strlen( $expectedStart ) ) );
74 $html = substr( $html, strlen( $expectedStart ) );
76 if ( $res[1]->getBool( 'disablelimitreport' ) ) {
77 $expectedEnd = "</div>";
78 $this->assertSame( $expectedEnd, substr( $html, -strlen( $expectedEnd ) ) );
80 $html = substr( $html, 0, strlen( $html ) - strlen( $expectedEnd ) );
82 $expectedEnd = '#\n<!-- \nNewPP limit report\n(?>.+?\n-->)\n' .
83 '<!--\nTransclusion expansion time report \(%,ms,calls,template\)\n(?>.*?\n-->)\n' .
84 '</div>(\n<!-- Saved in parser cache (?>.*?\n -->)\n)?$#s';
85 $this->assertRegExp( $expectedEnd, $html );
87 $html = preg_replace( $expectedEnd, '', $html );
90 call_user_func( $callback, $expected, $html );
92 if ( $warnings === null ) {
93 $this->assertCount( 1, $res[0] );
95 $this->assertCount( 2, $res[0] );
96 // This deliberately fails if there are extra warnings
97 $this->assertSame( [ 'parse' => [ 'warnings' => $warnings ] ], $res[0]['warnings'] );
102 * Set up an interwiki entry for testing.
104 protected function setupInterwiki() {
105 $dbw = wfGetDB( DB_MASTER
);
109 'iw_prefix' => 'madeuplanguage',
110 'iw_url' => "https://example.com/wiki/$1",
119 $this->setMwGlobals( 'wgExtraInterlanguageLinkPrefixes', [ 'madeuplanguage' ] );
120 $this->tablesUsed
[] = 'interwiki';
124 * Set up a skin for testing.
126 * @todo Should this code be in MediaWikiTestCase or something?
128 protected function setupSkin() {
129 $factory = new SkinFactory();
130 $factory->register( 'testing', 'Testing', function () {
131 $skin = $this->getMockBuilder( SkinFallback
::class )
132 ->setMethods( [ 'getDefaultModules', 'setupSkinUserCss' ] )
134 $skin->expects( $this->once() )->method( 'getDefaultModules' )
136 'core' => [ 'foo', 'bar' ],
137 'content' => [ 'baz' ]
139 $skin->expects( $this->once() )->method( 'setupSkinUserCss' )
140 ->will( $this->returnCallback( function ( OutputPage
$out ) {
141 $out->addModuleStyles( 'foo.styles' );
145 $this->setService( 'SkinFactory', $factory );
148 public function testParseByName() {
149 $res = $this->doApiRequest( [
153 $this->assertParsedTo( "<p>Test for latest\n</p>", $res );
155 $res = $this->doApiRequest( [
158 'disablelimitreport' => 1,
160 $this->assertParsedTo( "<p>Test for latest\n</p>", $res );
163 public function testParseById() {
164 $res = $this->doApiRequest( [
166 'pageid' => self
::$pageId,
168 $this->assertParsedTo( "<p>Test for latest\n</p>", $res );
171 public function testParseByOldId() {
172 $res = $this->doApiRequest( [
174 'oldid' => self
::$revIds['oldid'],
176 $this->assertParsedTo( "<p>Test for oldid\n</p>", $res );
177 $this->assertArrayNotHasKey( 'textdeleted', $res[0]['parse'] );
178 $this->assertArrayNotHasKey( 'textsuppressed', $res[0]['parse'] );
181 public function testRevDel() {
182 $res = $this->doApiRequest( [
184 'oldid' => self
::$revIds['revdel'],
187 $this->assertParsedTo( "<p>Test for revdel\n</p>", $res );
188 $this->assertArrayHasKey( 'textdeleted', $res[0]['parse'] );
189 $this->assertArrayNotHasKey( 'textsuppressed', $res[0]['parse'] );
192 public function testRevDelNoPermission() {
193 $this->setExpectedException( ApiUsageException
::class,
194 "You don't have permission to view deleted revision text." );
196 $this->doApiRequest( [
198 'oldid' => self
::$revIds['revdel'],
199 ], null, null, static::getTestUser()->getUser() );
202 public function testSuppressed() {
203 $this->setGroupPermissions( 'sysop', 'viewsuppressed', true );
205 $res = $this->doApiRequest( [
207 'oldid' => self
::$revIds['suppressed']
210 $this->assertParsedTo( "<p>Test for suppressed\n</p>", $res );
211 $this->assertArrayHasKey( 'textsuppressed', $res[0]['parse'] );
212 $this->assertArrayHasKey( 'textdeleted', $res[0]['parse'] );
215 public function testNonexistentPage() {
217 $this->doApiRequest( [
219 'page' => 'DoesNotExist',
222 $this->fail( "API did not return an error when parsing a nonexistent page" );
223 } catch ( ApiUsageException
$ex ) {
224 $this->assertTrue( ApiTestCase
::apiExceptionHasCode( $ex, 'missingtitle' ),
225 "Parse request for nonexistent page must give 'missingtitle' error: "
226 . var_export( self
::getErrorFormatter()->arrayFromStatus( $ex->getStatusValue() ), true )
231 public function testTitleProvided() {
232 $res = $this->doApiRequest( [
234 'title' => 'Some interesting page',
235 'text' => '{{PAGENAME}} has attracted my attention',
238 $this->assertParsedTo( "<p>Some interesting page has attracted my attention\n</p>", $res );
241 public function testSection() {
242 $name = ucfirst( __FUNCTION__
);
244 $this->editPage( $name,
245 "Intro\n\n== Section 1 ==\n\nContent 1\n\n== Section 2 ==\n\nContent 2" );
247 $res = $this->doApiRequest( [
253 $this->assertParsedToRegExp( '!<h2>.*Section 1.*</h2>\n<p>Content 1\n</p>!', $res );
256 public function testInvalidSection() {
257 $this->setExpectedException( ApiUsageException
::class,
258 'The "section" parameter must be a valid section ID or "new".' );
260 $this->doApiRequest( [
262 'section' => 'T-new',
266 public function testSectionNoContent() {
267 $name = ucfirst( __FUNCTION__
);
269 $status = $this->editPage( $name,
270 "Intro\n\n== Section 1 ==\n\nContent 1\n\n== Section 2 ==\n\nContent 2" );
272 $this->setExpectedException( ApiUsageException
::class,
273 "Missing content for page ID {$status->value['revision']->getPage()}." );
275 $this->db
->delete( 'revision', [ 'rev_id' => $status->value
['revision']->getId() ] );
277 // Suppress warning in WikiPage::getContentModel
278 Wikimedia\
suppressWarnings();
280 $this->doApiRequest( [
286 Wikimedia\restoreWarnings
();
290 public function testNewSectionWithPage() {
291 $this->setExpectedException( ApiUsageException
::class,
292 '"section=new" cannot be combined with the "oldid", "pageid" or "page" ' .
293 'parameters. Please use "title" and "text".' );
295 $this->doApiRequest( [
302 public function testNonexistentOldId() {
303 $this->setExpectedException( ApiUsageException
::class,
304 'There is no revision with ID 2147483647.' );
306 $this->doApiRequest( [
308 'oldid' => pow( 2, 31 ) - 1,
312 public function testUnfollowedRedirect() {
313 $name = ucfirst( __FUNCTION__
);
315 $this->editPage( $name, "#REDIRECT [[$name 2]]" );
316 $this->editPage( "$name 2", "Some ''text''" );
318 $res = $this->doApiRequest( [
323 // Can't use assertParsedTo because the parser output is different for
325 $this->assertRegExp( "/Redirect to:.*$name 2/", $res[0]['parse']['text'] );
326 $this->assertArrayNotHasKey( 'warnings', $res[0] );
329 public function testFollowedRedirect() {
330 $name = ucfirst( __FUNCTION__
);
332 $this->editPage( $name, "#REDIRECT [[$name 2]]" );
333 $this->editPage( "$name 2", "Some ''text''" );
335 $res = $this->doApiRequest( [
341 $this->assertParsedTo( "<p>Some <i>text</i>\n</p>", $res );
344 public function testFollowedRedirectById() {
345 $name = ucfirst( __FUNCTION__
);
347 $id = $this->editPage( $name, "#REDIRECT [[$name 2]]" )->value
['revision']->getPage();
348 $this->editPage( "$name 2", "Some ''text''" );
350 $res = $this->doApiRequest( [
356 $this->assertParsedTo( "<p>Some <i>text</i>\n</p>", $res );
359 public function testInvalidTitle() {
360 $this->setExpectedException( ApiUsageException
::class, 'Bad title "|".' );
362 $this->doApiRequest( [
368 public function testTitleWithNonexistentRevId() {
369 $this->setExpectedException( ApiUsageException
::class,
370 'There is no revision with ID 2147483647.' );
372 $this->doApiRequest( [
374 'title' => __CLASS__
,
375 'revid' => pow( 2, 31 ) - 1,
379 public function testTitleWithNonMatchingRevId() {
380 $name = ucfirst( __FUNCTION__
);
382 $res = $this->doApiRequest( [
385 'revid' => self
::$revIds['latest'],
386 'text' => 'Some text',
389 $this->assertParsedTo( "<p>Some text\n</p>", $res,
390 'r' . self
::$revIds['latest'] . " is not a revision of $name." );
393 public function testRevId() {
394 $res = $this->doApiRequest( [
396 'revid' => self
::$revIds['latest'],
397 'text' => 'My revid is {{REVISIONID}}!',
400 $this->assertParsedTo( "<p>My revid is " . self
::$revIds['latest'] . "!\n</p>", $res );
403 public function testTitleNoText() {
404 $res = $this->doApiRequest( [
406 'title' => 'Special:AllPages',
409 $this->assertParsedTo( '', $res,
410 '"title" used without "text", and parsed page properties were requested. ' .
411 'Did you mean to use "page" instead of "title"?' );
414 public function testRevidNoText() {
415 $res = $this->doApiRequest( [
417 'revid' => self
::$revIds['latest'],
420 $this->assertParsedTo( '', $res,
421 '"revid" used without "text", and parsed page properties were requested. ' .
422 'Did you mean to use "oldid" instead of "revid"?' );
425 public function testTextNoContentModel() {
426 $res = $this->doApiRequest( [
428 'text' => "Some ''text''",
431 $this->assertParsedTo( "<p>Some <i>text</i>\n</p>", $res,
432 'No "title" or "contentmodel" was given, assuming wikitext.' );
435 public function testSerializationError() {
436 $this->setExpectedException( APIUsageException
::class,
437 'Content serialization failed: Could not unserialize content' );
439 $this->mergeMwGlobalArrayValue( 'wgContentHandlers',
440 [ 'testing-serialize-error' => 'DummySerializeErrorContentHandler' ] );
442 $this->doApiRequest( [
444 'text' => "Some ''text''",
445 'contentmodel' => 'testing-serialize-error',
449 public function testNewSection() {
450 $res = $this->doApiRequest( [
452 'title' => __CLASS__
,
454 'sectiontitle' => 'Title',
458 $this->assertParsedToRegExp( '!<h2>.*Title.*</h2>\n<p>Content\n</p>!', $res );
461 public function testExistingSection() {
462 $res = $this->doApiRequest( [
464 'title' => __CLASS__
,
466 'text' => "Intro\n\n== Section 1 ==\n\nContent\n\n== Section 2 ==\n\nMore content",
469 $this->assertParsedToRegExp( '!<h2>.*Section 1.*</h2>\n<p>Content\n</p>!', $res );
472 public function testNoPst() {
473 $name = ucfirst( __FUNCTION__
);
475 $this->editPage( "Template:$name", "Template ''text''" );
477 $res = $this->doApiRequest( [
479 'text' => "{{subst:$name}}",
480 'contentmodel' => 'wikitext',
483 $this->assertParsedTo( "<p>{{subst:$name}}\n</p>", $res );
486 public function testPst() {
487 $name = ucfirst( __FUNCTION__
);
489 $this->editPage( "Template:$name", "Template ''text''" );
491 $res = $this->doApiRequest( [
494 'text' => "{{subst:$name}}",
495 'contentmodel' => 'wikitext',
496 'prop' => 'text|wikitext',
499 $this->assertParsedTo( "<p>Template <i>text</i>\n</p>", $res );
500 $this->assertSame( "{{subst:$name}}", $res[0]['parse']['wikitext'] );
503 public function testOnlyPst() {
504 $name = ucfirst( __FUNCTION__
);
506 $this->editPage( "Template:$name", "Template ''text''" );
508 $res = $this->doApiRequest( [
511 'text' => "{{subst:$name}}",
512 'contentmodel' => 'wikitext',
513 'prop' => 'text|wikitext',
514 'summary' => 'Summary',
519 'text' => "Template ''text''",
520 'wikitext' => "{{subst:$name}}",
521 'parsedsummary' => 'Summary',
527 public function testHeadHtml() {
528 $res = $this->doApiRequest( [
531 'prop' => 'headhtml',
534 // Just do a rough sanity check
535 $this->assertRegExp( '#<!DOCTYPE.*<html.*<head.*</head>.*<body#s',
536 $res[0]['parse']['headhtml'] );
537 $this->assertArrayNotHasKey( 'warnings', $res[0] );
540 public function testCategoriesHtml() {
541 $name = ucfirst( __FUNCTION__
);
543 $this->editPage( $name, "[[Category:$name]]" );
545 $res = $this->doApiRequest( [
548 'prop' => 'categorieshtml',
551 $this->assertRegExp( "#Category.*Category:$name.*$name#",
552 $res[0]['parse']['categorieshtml'] );
553 $this->assertArrayNotHasKey( 'warnings', $res[0] );
556 public function testEffectiveLangLinks() {
558 $this->setTemporaryHook( 'LanguageLinks',
559 function () use ( &$hookRan ) {
564 $res = $this->doApiRequest( [
566 'title' => __CLASS__
,
567 'text' => '[[zh:' . __CLASS__
. ']]',
568 'effectivelanglinks' => '',
571 $this->assertTrue( $hookRan );
572 $this->assertSame( 'The parameter "effectivelanglinks" has been deprecated.',
573 $res[0]['warnings']['parse']['warnings'] );
577 * @param array $arr Extra params to add to API request
579 private function doTestLangLinks( array $arr = [] ) {
580 $this->setupInterwiki();
582 $res = $this->doApiRequest( array_merge( [
584 'title' => 'Omelette',
585 'text' => '[[madeuplanguage:Omelette]]',
586 'prop' => 'langlinks',
589 $langLinks = $res[0]['parse']['langlinks'];
591 $this->assertCount( 1, $langLinks );
592 $this->assertSame( 'madeuplanguage', $langLinks[0]['lang'] );
593 $this->assertSame( 'Omelette', $langLinks[0]['title'] );
594 $this->assertSame( 'https://example.com/wiki/Omelette', $langLinks[0]['url'] );
595 $this->assertArrayNotHasKey( 'warnings', $res[0] );
598 public function testLangLinks() {
599 $this->doTestLangLinks();
602 public function testLangLinksWithSkin() {
604 $this->doTestLangLinks( [ 'useskin' => 'testing' ] );
607 public function testHeadItems() {
608 $res = $this->doApiRequest( [
610 'title' => __CLASS__
,
612 'prop' => 'headitems',
615 $this->assertSame( [], $res[0]['parse']['headitems'] );
617 '"prop=headitems" is deprecated since MediaWiki 1.28. ' .
618 'Use "prop=headhtml" when creating new HTML documents, ' .
619 'or "prop=modules|jsconfigvars" when updating a document client-side.',
620 $res[0]['warnings']['parse']['warnings']
624 public function testHeadItemsWithSkin() {
627 $res = $this->doApiRequest( [
629 'title' => __CLASS__
,
631 'prop' => 'headitems',
632 'useskin' => 'testing',
635 $this->assertSame( [], $res[0]['parse']['headitems'] );
637 '"prop=headitems" is deprecated since MediaWiki 1.28. ' .
638 'Use "prop=headhtml" when creating new HTML documents, ' .
639 'or "prop=modules|jsconfigvars" when updating a document client-side.',
640 $res[0]['warnings']['parse']['warnings']
644 public function testModules() {
645 $this->setTemporaryHook( 'ParserAfterParse',
646 function ( $parser ) {
647 $output = $parser->getOutput();
648 $output->addModules( [ 'foo', 'bar' ] );
649 $output->addModuleScripts( [ 'baz', 'quuz' ] );
650 $output->addModuleStyles( [ 'aaa', 'zzz' ] );
651 $output->addJsConfigVars( [ 'x' => 'y', 'z' => -3 ] );
654 $res = $this->doApiRequest( [
656 'title' => __CLASS__
,
658 'prop' => 'modules|jsconfigvars|encodedjsconfigvars',
661 $this->assertSame( [ 'foo', 'bar' ], $res[0]['parse']['modules'] );
662 $this->assertSame( [ 'baz', 'quuz' ], $res[0]['parse']['modulescripts'] );
663 $this->assertSame( [ 'aaa', 'zzz' ], $res[0]['parse']['modulestyles'] );
664 $this->assertSame( [ 'x' => 'y', 'z' => -3 ], $res[0]['parse']['jsconfigvars'] );
665 $this->assertSame( '{"x":"y","z":-3}', $res[0]['parse']['encodedjsconfigvars'] );
666 $this->assertArrayNotHasKey( 'warnings', $res[0] );
669 public function testModulesWithSkin() {
672 $res = $this->doApiRequest( [
674 'pageid' => self
::$pageId,
675 'useskin' => 'testing',
679 [ 'foo', 'bar', 'baz' ],
680 $res[0]['parse']['modules'],
685 $res[0]['parse']['modulescripts'],
686 'resp.parse.modulescripts'
690 $res[0]['parse']['modulestyles'],
691 'resp.parse.modulestyles'
696 'Property "modules" was set but not "jsconfigvars" or ' .
697 '"encodedjsconfigvars". Configuration variables are necessary for ' .
698 'proper module usage.'
705 public function testIndicators() {
706 $res = $this->doApiRequest( [
708 'title' => __CLASS__
,
710 '<indicator name="b">BBB!</indicator>Some text<indicator name="a">aaa</indicator>',
711 'prop' => 'indicators',
715 // It seems we return in markup order and not display order
716 [ 'b' => 'BBB!', 'a' => 'aaa' ],
717 $res[0]['parse']['indicators']
719 $this->assertArrayNotHasKey( 'warnings', $res[0] );
722 public function testIndicatorsWithSkin() {
725 $res = $this->doApiRequest( [
727 'title' => __CLASS__
,
729 '<indicator name="b">BBB!</indicator>Some text<indicator name="a">aaa</indicator>',
730 'prop' => 'indicators',
731 'useskin' => 'testing',
735 // Now we return in display order rather than markup order
736 [ 'a' => 'aaa', 'b' => 'BBB!' ],
737 $res[0]['parse']['indicators']
739 $this->assertArrayNotHasKey( 'warnings', $res[0] );
742 public function testIwlinks() {
743 $this->setupInterwiki();
745 $res = $this->doApiRequest( [
747 'title' => 'Omelette',
748 'text' => '[[:madeuplanguage:Omelette]][[madeuplanguage:Spaghetti]]',
752 $iwlinks = $res[0]['parse']['iwlinks'];
754 $this->assertCount( 1, $iwlinks );
755 $this->assertSame( 'madeuplanguage', $iwlinks[0]['prefix'] );
756 $this->assertSame( 'https://example.com/wiki/Omelette', $iwlinks[0]['url'] );
757 $this->assertSame( 'madeuplanguage:Omelette', $iwlinks[0]['title'] );
758 $this->assertArrayNotHasKey( 'warnings', $res[0] );
761 public function testLimitReports() {
762 $res = $this->doApiRequest( [
764 'pageid' => self
::$pageId,
765 'prop' => 'limitreportdata|limitreporthtml',
768 // We don't bother testing the actual values here
769 $this->assertInternalType( 'array', $res[0]['parse']['limitreportdata'] );
770 $this->assertInternalType( 'string', $res[0]['parse']['limitreporthtml'] );
771 $this->assertArrayNotHasKey( 'warnings', $res[0] );
774 public function testParseTreeNonWikitext() {
775 $this->setExpectedException( ApiUsageException
::class,
776 '"prop=parsetree" is only supported for wikitext content.' );
778 $this->doApiRequest( [
781 'contentmodel' => 'json',
782 'prop' => 'parsetree',
786 public function testParseTree() {
787 $res = $this->doApiRequest( [
789 'text' => "Some ''text'' is {{nice|to have|i=think}}",
790 'contentmodel' => 'wikitext',
791 'prop' => 'parsetree',
794 // Preprocessor_DOM and Preprocessor_Hash give different results here,
795 // so we'll accept either
797 '#^<root>Some \'\'text\'\' is <template><title>nice</title>' .
798 '<part><name index="1"/><value>to have</value></part>' .
799 '<part><name>i</name>(?:<equals>)?=(?:</equals>)?<value>think</value></part>' .
800 '</template></root>$#',
801 $res[0]['parse']['parsetree']
803 $this->assertArrayNotHasKey( 'warnings', $res[0] );
806 public function testDisableTidy() {
807 $this->setMwGlobals( 'wgTidyConfig', [ 'driver' => 'RemexHtml' ] );
809 // Check that disabletidy doesn't have an effect just because tidying
810 // doesn't work for some other reason
811 $res1 = $this->doApiRequest( [
813 'text' => "<b>Mixed <i>up</b></i>",
814 'contentmodel' => 'wikitext',
816 $this->assertParsedTo( "<p><b>Mixed <i>up</i></b>\n</p>", $res1 );
818 $res2 = $this->doApiRequest( [
820 'text' => "<b>Mixed <i>up</b></i>",
821 'contentmodel' => 'wikitext',
825 $this->assertParsedTo( "<p><b>Mixed <i>up</b></i>\n</p>", $res2 );
828 public function testFormatCategories() {
829 $name = ucfirst( __FUNCTION__
);
831 $this->editPage( "Category:$name", 'Content' );
832 $this->editPage( 'Category:Hidden', '__HIDDENCAT__' );
834 $res = $this->doApiRequest( [
836 'title' => __CLASS__
,
837 'text' => "[[Category:$name]][[Category:Foo|Sort me]][[Category:Hidden]]",
838 'prop' => 'categories',
842 [ [ 'sortkey' => '', 'category' => $name ],
843 [ 'sortkey' => 'Sort me', 'category' => 'Foo', 'missing' => true ],
844 [ 'sortkey' => '', 'category' => 'Hidden', 'hidden' => true ] ],
845 $res[0]['parse']['categories']
847 $this->assertArrayNotHasKey( 'warnings', $res[0] );