本文整理汇总了PHP中Magento\Framework\Exception\InputException::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP InputException::getMessage方法的具体用法?PHP InputException::getMessage怎么用?PHP InputException::getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Exception\InputException
的用法示例。
在下文中一共展示了InputException::getMessage方法的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());
}
示例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());
}
示例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());
}