当前位置: 首页>>代码示例>>PHP>>正文


PHP DeferredUpdates::pendingUpdatesCount方法代码示例

本文整理汇总了PHP中DeferredUpdates::pendingUpdatesCount方法的典型用法代码示例。如果您正苦于以下问题:PHP DeferredUpdates::pendingUpdatesCount方法的具体用法?PHP DeferredUpdates::pendingUpdatesCount怎么用?PHP DeferredUpdates::pendingUpdatesCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DeferredUpdates的用法示例。


在下文中一共展示了DeferredUpdates::pendingUpdatesCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDoUpdatesWeb

 public function testDoUpdatesWeb()
 {
     $this->setMwGlobals('wgCommandLineMode', false);
     $updates = ['1' => "deferred update 1;\n", '2' => "deferred update 2;\n", '2-1' => "deferred update 1 within deferred update 2;\n", '2-2' => "deferred update 2 within deferred update 2;\n", '3' => "deferred update 3;\n", '3-1' => "deferred update 1 within deferred update 3;\n", '3-2' => "deferred update 2 within deferred update 3;\n", '3-1-1' => "deferred update 1 within deferred update 1 within deferred update 3;\n", '3-2-1' => "deferred update 1 within deferred update 2 with deferred update 3;\n"];
     DeferredUpdates::addCallableUpdate(function () use($updates) {
         echo $updates['1'];
     });
     DeferredUpdates::addCallableUpdate(function () use($updates) {
         echo $updates['2'];
         DeferredUpdates::addCallableUpdate(function () use($updates) {
             echo $updates['2-1'];
         });
         DeferredUpdates::addCallableUpdate(function () use($updates) {
             echo $updates['2-2'];
         });
     });
     DeferredUpdates::addCallableUpdate(function () use($updates) {
         echo $updates['3'];
         DeferredUpdates::addCallableUpdate(function () use($updates) {
             echo $updates['3-1'];
             DeferredUpdates::addCallableUpdate(function () use($updates) {
                 echo $updates['3-1-1'];
             });
         });
         DeferredUpdates::addCallableUpdate(function () use($updates) {
             echo $updates['3-2'];
             DeferredUpdates::addCallableUpdate(function () use($updates) {
                 echo $updates['3-2-1'];
             });
         });
     });
     $this->assertEquals(3, DeferredUpdates::pendingUpdatesCount());
     $this->expectOutputString(implode('', $updates));
     DeferredUpdates::doUpdates();
     $x = null;
     $y = null;
     DeferredUpdates::addCallableUpdate(function () use(&$x) {
         $x = 'Sherity';
     }, DeferredUpdates::PRESEND);
     DeferredUpdates::addCallableUpdate(function () use(&$y) {
         $y = 'Marychu';
     }, DeferredUpdates::POSTSEND);
     $this->assertNull($x, "Update not run yet");
     $this->assertNull($y, "Update not run yet");
     DeferredUpdates::doUpdates('run', DeferredUpdates::PRESEND);
     $this->assertEquals("Sherity", $x, "PRESEND update ran");
     $this->assertNull($y, "POSTSEND update not run yet");
     DeferredUpdates::doUpdates('run', DeferredUpdates::POSTSEND);
     $this->assertEquals("Marychu", $y, "POSTSEND update ran");
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:50,代码来源:DeferredUpdatesTest.php

示例2: testCreatePageTrx

 /**
  * @dataProvider provideCreatePages
  * @covers EditPage
  */
 public function testCreatePageTrx($desc, $pageTitle, $user, $editText, $expectedCode, $expectedText, $ignoreBlank = false)
 {
     $checkIds = [];
     $this->setMwGlobals('wgHooks', ['PageContentInsertComplete' => [function (WikiPage &$page, User &$user, Content $content, $summary, $minor, $u1, $u2, &$flags, Revision $revision) {
         // types/refs checked
     }], 'PageContentSaveComplete' => [function (WikiPage &$page, User &$user, Content $content, $summary, $minor, $u1, $u2, &$flags, Revision $revision, Status &$status, $baseRevId) use(&$checkIds) {
         $checkIds[] = $status->value['revision']->getId();
         // types/refs checked
     }]]);
     wfGetDB(DB_MASTER)->begin(__METHOD__);
     $edit = ['wpTextbox1' => $editText];
     if ($ignoreBlank) {
         $edit['wpIgnoreBlankArticle'] = 1;
     }
     $page = $this->assertEdit($pageTitle, null, $user, $edit, $expectedCode, $expectedText, $desc);
     $pageTitle2 = (string) $pageTitle . '/x';
     $page2 = $this->assertEdit($pageTitle2, null, $user, $edit, $expectedCode, $expectedText, $desc);
     wfGetDB(DB_MASTER)->commit(__METHOD__);
     $this->assertEquals(0, DeferredUpdates::pendingUpdatesCount(), 'No deferred updates');
     if ($expectedCode != EditPage::AS_BLANK_ARTICLE) {
         $latest = $page->getLatest();
         $page->doDeleteArticleReal($pageTitle);
         $this->assertGreaterThan(0, $latest, "Page #1 revision ID updated in object");
         $this->assertEquals($latest, $checkIds[0], "Revision #1 in Status for hook");
         $latest2 = $page2->getLatest();
         $page2->doDeleteArticleReal($pageTitle2);
         $this->assertGreaterThan(0, $latest2, "Page #2 revision ID updated in object");
         $this->assertEquals($latest2, $checkIds[1], "Revision #2 in Status for hook");
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:34,代码来源:EditPageTest.php


注:本文中的DeferredUpdates::pendingUpdatesCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。