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


PHP Status::newGood方法代码示例

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


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

示例1: handleFormSubmit

 public function handleFormSubmit($data)
 {
     // unlink requests do not accept user input so repeat parent code but skip call to
     // AuthenticationRequest::loadRequestsFromSubmission
     $response = $this->performAuthenticationStep($this->authAction, $this->authRequests);
     return Status::newGood($response);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:7,代码来源:SpecialUnlinkAccounts.php

示例2: testBeginSecondaryAccountCreation

 public function testBeginSecondaryAccountCreation()
 {
     $authManager = new AuthManager(new \FauxRequest(), new \HashConfig());
     $creator = $this->getMock('User');
     $userWithoutEmail = $this->getMock('User');
     $userWithoutEmail->expects($this->any())->method('getEmail')->willReturn('');
     $userWithoutEmail->expects($this->never())->method('sendConfirmationMail');
     $userWithEmailError = $this->getMock('User');
     $userWithEmailError->expects($this->any())->method('getEmail')->willReturn('foo@bar.baz');
     $userWithEmailError->expects($this->any())->method('sendConfirmationMail')->willReturn(\Status::newFatal('fail'));
     $userExpectsConfirmation = $this->getMock('User');
     $userExpectsConfirmation->expects($this->any())->method('getEmail')->willReturn('foo@bar.baz');
     $userExpectsConfirmation->expects($this->once())->method('sendConfirmationMail')->willReturn(\Status::newGood());
     $userNotExpectsConfirmation = $this->getMock('User');
     $userNotExpectsConfirmation->expects($this->any())->method('getEmail')->willReturn('foo@bar.baz');
     $userNotExpectsConfirmation->expects($this->never())->method('sendConfirmationMail');
     $provider = new EmailNotificationSecondaryAuthenticationProvider(['sendConfirmationEmail' => false]);
     $provider->setManager($authManager);
     $provider->beginSecondaryAccountCreation($userNotExpectsConfirmation, $creator, []);
     $provider = new EmailNotificationSecondaryAuthenticationProvider(['sendConfirmationEmail' => true]);
     $provider->setManager($authManager);
     $provider->beginSecondaryAccountCreation($userWithoutEmail, $creator, []);
     $provider->beginSecondaryAccountCreation($userExpectsConfirmation, $creator, []);
     // test logging of email errors
     $logger = $this->getMockForAbstractClass(LoggerInterface::class);
     $logger->expects($this->once())->method('warning');
     $provider->setLogger($logger);
     $provider->beginSecondaryAccountCreation($userWithEmailError, $creator, []);
     // test disable flag used by other providers
     $authManager->setAuthenticationSessionData('no-email', true);
     $provider->setManager($authManager);
     $provider->beginSecondaryAccountCreation($userNotExpectsConfirmation, $creator, []);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:33,代码来源:EmailNotificationSecondaryAuthenticationProviderTest.php

示例3: verifyUpload

 /**
  * Various checks against the uploaded file
  * - maximum upload size
  * - maximum number of embedded files
  * - maximum size of metadata
  * - identify-errors
  * - identify-warnings
  * - check for running-identify-service
  */
 function verifyUpload($fileName)
 {
     global $wgTiffUseTiffReader, $wgTiffReaderCheckEofForJS;
     $status = Status::newGood();
     if ($wgTiffUseTiffReader) {
         $tr = new TiffReader($fileName);
         $tr->check();
         if (!$tr->isValidTiff()) {
             wfDebug(__METHOD__ . ": bad file\n");
             $status->fatal('tiff_bad_file');
         } else {
             if ($tr->checkScriptAtEnd($wgTiffReaderCheckEofForJS)) {
                 wfDebug(__METHOD__ . ": script detected\n");
                 $status->fatal('tiff_script_detected');
             }
             if (!$tr->checkSize()) {
                 wfDebug(__METHOD__ . ": size error\n");
                 $status->fatal('tiff_size_error');
             }
         }
     }
     $meta = self::getTiffImage(false, $fileName)->retrieveMetaData();
     if (!$meta) {
         wfDebug(__METHOD__ . ": unable to retreive metadata\n");
         $status->fatal('tiff_out_of_service');
     } else {
         $error = false;
         $ok = self::verifyMetaData($meta, $error);
         if (!$ok) {
             call_user_func_array(array($status, 'fatal'), $error);
         }
     }
     return $status;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:43,代码来源:PagedTiffHandler_body.php

示例4: testNewGood

 /**
  * @dataProvider provideValues
  * @covers Status::newGood
  */
 public function testNewGood($value = null)
 {
     $status = Status::newGood($value);
     $this->assertTrue($status->isGood());
     $this->assertTrue($status->isOK());
     $this->assertEquals($value, $status->getValue());
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:11,代码来源:StatusTest.php

示例5: testExecute_email

 public function testExecute_email()
 {
     $config = new HashConfig(['PasswordResetRoutes' => ['username' => true, 'email' => true], 'EnableEmail' => true]);
     $authManager = $this->getMockBuilder(AuthManager::class)->disableOriginalConstructor()->getMock();
     $authManager->expects($this->any())->method('allowsAuthenticationDataChange')->willReturn(Status::newGood());
     $authManager->expects($this->exactly(2))->method('changeAuthenticationData');
     $request = new FauxRequest();
     $request->setIP('1.2.3.4');
     $performingUser = $this->getMock(User::class);
     $performingUser->expects($this->any())->method('getRequest')->willReturn($request);
     $performingUser->expects($this->any())->method('isAllowed')->willReturn(true);
     $targetUser1 = $this->getMock(User::class);
     $targetUser2 = $this->getMock(User::class);
     $targetUser1->expects($this->any())->method('getName')->willReturn('User1');
     $targetUser2->expects($this->any())->method('getName')->willReturn('User2');
     $targetUser1->expects($this->any())->method('getId')->willReturn(1);
     $targetUser2->expects($this->any())->method('getId')->willReturn(2);
     $targetUser1->expects($this->any())->method('getEmail')->willReturn('foo@bar.baz');
     $targetUser2->expects($this->any())->method('getEmail')->willReturn('foo@bar.baz');
     $passwordReset = $this->getMockBuilder(PasswordReset::class)->setMethods(['getUsersByEmail'])->setConstructorArgs([$config, $authManager])->getMock();
     $passwordReset->expects($this->any())->method('getUsersByEmail')->with('foo@bar.baz')->willReturn([$targetUser1, $targetUser2]);
     $status = $passwordReset->isAllowed($performingUser);
     $this->assertTrue($status->isGood());
     $status = $passwordReset->execute($performingUser, null, 'foo@bar.baz');
     $this->assertTrue($status->isGood());
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:26,代码来源:PasswordResetTest.php

示例6: testErrorFormatterBC

 /**
  * @covers ApiErrorFormatter_BackCompat
  */
 public function testErrorFormatterBC()
 {
     $mainpagePlain = wfMessage('mainpage')->useDatabase(false)->plain();
     $parensPlain = wfMessage('parentheses', 'foobar')->useDatabase(false)->plain();
     $result = new ApiResult(8388608);
     $formatter = new ApiErrorFormatter_BackCompat($result);
     $formatter->addWarning('string', 'mainpage');
     $formatter->addError('err', 'mainpage');
     $this->assertSame(array('error' => array('code' => 'mainpage', 'info' => $mainpagePlain), 'warnings' => array('string' => array('warnings' => $mainpagePlain, ApiResult::META_CONTENT => 'warnings')), ApiResult::META_TYPE => 'assoc'), $result->getResultData(), 'Simple test');
     $result->reset();
     $formatter->addWarning('foo', 'mainpage');
     $formatter->addWarning('foo', 'mainpage');
     $formatter->addWarning('foo', array('parentheses', 'foobar'));
     $msg1 = wfMessage('mainpage');
     $formatter->addWarning('message', $msg1);
     $msg2 = new ApiMessage('mainpage', 'overriddenCode', array('overriddenData' => true));
     $formatter->addWarning('messageWithData', $msg2);
     $formatter->addError('errWithData', $msg2);
     $this->assertSame(array('error' => array('code' => 'overriddenCode', 'info' => $mainpagePlain, 'overriddenData' => true), 'warnings' => array('messageWithData' => array('warnings' => $mainpagePlain, ApiResult::META_CONTENT => 'warnings'), 'message' => array('warnings' => $mainpagePlain, ApiResult::META_CONTENT => 'warnings'), 'foo' => array('warnings' => "{$mainpagePlain}\n{$parensPlain}", ApiResult::META_CONTENT => 'warnings')), ApiResult::META_TYPE => 'assoc'), $result->getResultData(), 'Complex test');
     $result->reset();
     $status = Status::newGood();
     $status->warning('mainpage');
     $status->warning('parentheses', 'foobar');
     $status->warning($msg1);
     $status->warning($msg2);
     $status->error('mainpage');
     $status->error('parentheses', 'foobar');
     $formatter->addMessagesFromStatus('status', $status);
     $this->assertSame(array('error' => array('code' => 'parentheses', 'info' => $parensPlain), 'warnings' => array('status' => array('warnings' => "{$mainpagePlain}\n{$parensPlain}", ApiResult::META_CONTENT => 'warnings')), ApiResult::META_TYPE => 'assoc'), $result->getResultData(), 'Status test');
     $I = ApiResult::META_INDEXED_TAG_NAME;
     $this->assertSame(array(array('type' => 'error', 'message' => 'mainpage', 'params' => array($I => 'param')), array('type' => 'error', 'message' => 'parentheses', 'params' => array('foobar', $I => 'param')), $I => 'error'), $formatter->arrayFromStatus($status, 'error'), 'arrayFromStatus test for error');
     $this->assertSame(array(array('type' => 'warning', 'message' => 'mainpage', 'params' => array($I => 'param')), array('type' => 'warning', 'message' => 'parentheses', 'params' => array('foobar', $I => 'param')), array('message' => 'mainpage', 'params' => array($I => 'param'), 'type' => 'warning'), array('message' => 'mainpage', 'params' => array($I => 'param'), 'type' => 'warning'), $I => 'warning'), $formatter->arrayFromStatus($status, 'warning'), 'arrayFromStatus test for warning');
 }
开发者ID:foxlog,项目名称:wiki,代码行数:36,代码来源:ApiErrorFormatterTest.php

示例7: validate

 /**
  * @param string|MWRestrictions $value The value the field was submitted with
  * @param array $alldata The data collected from the form
  *
  * @return bool|string True on success, or String error to display, or
  *   false to fail validation without displaying an error.
  */
 public function validate($value, $alldata)
 {
     if ($this->isHidden($alldata)) {
         return true;
     }
     if (isset($this->mParams['required']) && $this->mParams['required'] !== false && $value instanceof MWRestrictions && !$value->toArray()['IPAddresses']) {
         return $this->msg('htmlform-required')->parse();
     }
     if (is_string($value)) {
         // MWRestrictions::newFromArray failed; one of the IP ranges must be invalid
         $status = Status::newGood();
         foreach (explode(PHP_EOL, $value) as $range) {
             if (!\IP::isIPAddress($range)) {
                 $status->fatal('restrictionsfield-badip', $range);
             }
         }
         if ($status->isOK()) {
             $status->fatal('unknown-error');
         }
         return $status->getMessage()->parse();
     }
     if (isset($this->mValidationCallback)) {
         return call_user_func($this->mValidationCallback, $value, $alldata, $this->mParent);
     }
     return true;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:33,代码来源:HTMLRestrictionsField.php

示例8: doDeleteInternal

 protected function doDeleteInternal(array $params)
 {
     $this->debug(serialize($params));
     $src = $params['src'];
     unset($this->mocked[$src]);
     return Status::newGood();
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:7,代码来源:MockFileBackend.php

示例9: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $context = RequestContext::getMain();
     try {
         $user = $context->getUser();
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         if (count($_SESSION) === 0) {
             // Empty session probably indicates that we didn't associate
             // with the session correctly. Note that being able to load
             // the user does not necessarily mean the session was loaded.
             // Most likely cause by suhosin.session.encrypt = On.
             $this->setLastError("Error associating with user session. " . "Try setting suhosin.session.encrypt = Off");
             return false;
         }
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood()));
         $upload = new UploadFromStash($user);
         // @todo initialize() causes a GET, ideally we could frontload the antivirus
         // checks and anything else to the stash stage (which includes concatenation and
         // the local file is thus already there). That way, instead of GET+PUT, there could
         // just be a COPY operation from the stash to the public zone.
         $upload->initialize($this->params['filekey'], $this->params['filename']);
         // Check if the local file checks out (this is generally a no-op)
         $verification = $upload->verifyUpload();
         if ($verification['status'] !== UploadBase::OK) {
             $status = Status::newFatal('verification-error');
             $status->value = array('verification' => $verification);
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => $status));
             $this->setLastError("Could not verify upload.");
             return false;
         }
         // Upload the stashed file to a permanent location
         $status = $upload->performUpload($this->params['comment'], $this->params['text'], $this->params['watch'], $user);
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => $status));
             $this->setLastError($status->getWikiText());
             return false;
         }
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Success', 'stage' => 'publish', 'filename' => $upload->getLocalFile()->getName(), 'imageinfo' => $imageInfo, 'status' => Status::newGood()));
     } catch (MWException $e) {
         UploadBase::setSessionStatus($this->params['filekey'], array('result' => 'Failure', 'stage' => 'publish', 'status' => Status::newFatal('api-error-publishfailed')));
         $this->setLastError(get_class($e) . ": " . $e->getText());
         // To prevent potential database referential integrity issues.
         // See bug 32551.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:59,代码来源:PublishStashedFileJob.php

示例10: testOkAndErrors

 /**
  *
  */
 public function testOkAndErrors()
 {
     $status = Status::newGood('foo');
     $this->assertTrue($status->ok);
     $status = Status::newFatal('foo', 1, 2);
     $this->assertFalse($status->ok);
     $this->assertArrayEquals(array(array('type' => 'error', 'message' => 'foo', 'params' => array(1, 2))), $status->errors);
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:11,代码来源:StatusTest.php

示例11: testTrack

 /**
  * @dataProvider trackDataProvider
  * @param $amgId
  * @param $trackResult
  * @param $responseCode
  */
 public function testTrack($amgId, $trackResult, $responseCode)
 {
     $controller = new LyricFindController();
     $controller->setRequest(new WikiaRequest(['amgid' => $amgId]));
     $controller->setResponse(new WikiaResponse('json'));
     $this->mockClassWithMethods('LyricFindTrackingService', ['track' => $trackResult ? Status::newGood() : Status::newFatal('foo')]);
     $controller->track();
     $this->assertEquals($responseCode, $controller->getResponse()->getCode(), 'HTTP response code should match the expected value');
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:15,代码来源:LyricFindControllerTest.php

示例12: fetchFile

 public function fetchFile()
 {
     if (!Http::isValidURI($this->mUrl)) {
         return Status::newFatal('http-invalid-url');
     }
     if (!$this->mAsync) {
         return $this->reallyFetchFile();
     }
     return Status::newGood();
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:10,代码来源:UploadFromUrl.php

示例13: run

 public function run()
 {
     $scope = RequestContext::importScopedSession($this->params['session']);
     $this->addTeardownCallback(function () use(&$scope) {
         ScopedCallback::consume($scope);
         // T126450
     });
     $context = RequestContext::getMain();
     $user = $context->getUser();
     try {
         if (!$user->isLoggedIn()) {
             $this->setLastError("Could not load the author user from session.");
             return false;
         }
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood()]);
         $upload = new UploadFromStash($user);
         // @todo initialize() causes a GET, ideally we could frontload the antivirus
         // checks and anything else to the stash stage (which includes concatenation and
         // the local file is thus already there). That way, instead of GET+PUT, there could
         // just be a COPY operation from the stash to the public zone.
         $upload->initialize($this->params['filekey'], $this->params['filename']);
         // Check if the local file checks out (this is generally a no-op)
         $verification = $upload->verifyUpload();
         if ($verification['status'] !== UploadBase::OK) {
             $status = Status::newFatal('verification-error');
             $status->value = ['verification' => $verification];
             UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => $status]);
             $this->setLastError("Could not verify upload.");
             return false;
         }
         // Upload the stashed file to a permanent location
         $status = $upload->performUpload($this->params['comment'], $this->params['text'], $this->params['watch'], $user, isset($this->params['tags']) ? $this->params['tags'] : []);
         if (!$status->isGood()) {
             UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => $status]);
             $this->setLastError($status->getWikiText(false, false, 'en'));
             return false;
         }
         // Build the image info array while we have the local reference handy
         $apiMain = new ApiMain();
         // dummy object (XXX)
         $imageInfo = $upload->getImageInfo($apiMain->getResult());
         // Cleanup any temporary local file
         $upload->cleanupTempFile();
         // Cache the info so the user doesn't have to wait forever to get the final info
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Success', 'stage' => 'publish', 'filename' => $upload->getLocalFile()->getName(), 'imageinfo' => $imageInfo, 'status' => Status::newGood()]);
     } catch (Exception $e) {
         UploadBase::setSessionStatus($user, $this->params['filekey'], ['result' => 'Failure', 'stage' => 'publish', 'status' => Status::newFatal('api-error-publishfailed')]);
         $this->setLastError(get_class($e) . ": " . $e->getMessage());
         // To prevent potential database referential integrity issues.
         // See bug 32551.
         MWExceptionHandler::rollbackMasterChangesAndLog($e);
         return false;
     }
     return true;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:55,代码来源:PublishStashedFileJob.php

示例14: fetchUser

 /**
  * @param $username
  * @return Status
  */
 function fetchUser($username)
 {
     $knownwiki = $this->getRequest()->getVal('wpKnownWiki');
     $user = CentralAuthGroupMembershipProxy::newFromName($username);
     if (!$user) {
         return Status::newFatal('nosuchusershort', $username);
     } elseif (!$this->getRequest()->getCheck('saveusergroups') && !$user->attachedOn($knownwiki)) {
         return Status::newFatal('centralauth-globalgroupmembership-badknownwiki', $username, $knownwiki);
     }
     return Status::newGood($user);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:15,代码来源:SpecialGlobalGroupMembership.php

示例15: fetchFile

 /**
  * Do the real fetching stuff
  */
 function fetchFile()
 {
     if (!self::isValidUrl($this->mUrl)) {
         return Status::newFatal('upload-proto-error');
     }
     $res = $this->curlCopy();
     if ($res !== true) {
         return Status::newFatal($res);
     }
     return Status::newGood();
 }
开发者ID:hala54,项目名称:DSMW,代码行数:14,代码来源:UploadFromUrl.php


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