當前位置: 首頁>>代碼示例>>PHP>>正文


PHP InputException::getErrors方法代碼示例

本文整理匯總了PHP中Magento\Framework\Exception\InputException::getErrors方法的典型用法代碼示例。如果您正苦於以下問題:PHP InputException::getErrors方法的具體用法?PHP InputException::getErrors怎麽用?PHP InputException::getErrors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Exception\InputException的用法示例。


在下文中一共展示了InputException::getErrors方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testAddErrorWithSameMessage

 /**
  * Verify the message and params are not used to determine the call count
  *
  * @return void
  */
 public function testAddErrorWithSameMessage()
 {
     $rawMessage = 'Foo "%var"';
     $params = ['var' => 'Bar'];
     $expectedProcessedMessage = 'Foo "Bar"';
     $inputException = new InputException(new Phrase($rawMessage, $params));
     $this->assertEquals($rawMessage, $inputException->getRawMessage());
     $this->assertEquals($expectedProcessedMessage, $inputException->getMessage());
     $this->assertEquals($expectedProcessedMessage, $inputException->getLogMessage());
     $this->assertFalse($inputException->wasErrorAdded());
     $this->assertCount(0, $inputException->getErrors());
     $inputException->addError(new Phrase($rawMessage, $params));
     $this->assertEquals($expectedProcessedMessage, $inputException->getMessage());
     $this->assertEquals($expectedProcessedMessage, $inputException->getLogMessage());
     $this->assertTrue($inputException->wasErrorAdded());
     $this->assertCount(0, $inputException->getErrors());
     $inputException->addError(new Phrase($rawMessage, $params));
     $this->assertEquals($expectedProcessedMessage, $inputException->getMessage());
     $this->assertEquals($expectedProcessedMessage, $inputException->getLogMessage());
     $this->assertTrue($inputException->wasErrorAdded());
     $errors = $inputException->getErrors();
     $this->assertCount(2, $errors);
     $this->assertEquals($expectedProcessedMessage, $errors[0]->getMessage());
     $this->assertEquals($expectedProcessedMessage, $errors[0]->getLogMessage());
     $this->assertEquals($expectedProcessedMessage, $errors[1]->getMessage());
     $this->assertEquals($expectedProcessedMessage, $errors[1]->getLogMessage());
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:32,代碼來源:InputExceptionTest.php

示例2: assertInputExceptionMessages

 /**
  * Assert for presence of Input exception messages
  *
  * @param InputException $e
  */
 private function assertInputExceptionMessages($e)
 {
     $this->assertEquals(InputException::DEFAULT_MESSAGE, $e->getMessage());
     $errors = $e->getErrors();
     $this->assertCount(2, $errors);
     $this->assertEquals('username is a required field.', $errors[0]->getLogMessage());
     $this->assertEquals('password is a required field.', $errors[1]->getLogMessage());
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:13,代碼來源:AdminTokenServiceTest.php

示例3: assertInputExceptionMessages

 /**
  * Assert for presence of Input exception messages
  *
  * @param InputException $e
  */
 private function assertInputExceptionMessages($e)
 {
     $this->assertEquals('One or more input exceptions have occurred.', $e->getMessage());
     $errors = $e->getErrors();
     $this->assertCount(2, $errors);
     $this->assertEquals('username is a required field.', $errors[0]->getLogMessage());
     $this->assertEquals('password is a required field.', $errors[1]->getLogMessage());
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:13,代碼來源:CustomerTokenServiceTest.php


注:本文中的Magento\Framework\Exception\InputException::getErrors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。