mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
|
|
namespace SilverStripe\ORM\Tests;
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
use SilverStripe\ORM\ValidationResult;
|
|
|
|
class ValidationResultTest extends SapphireTest
|
|
{
|
|
public function testSerialise()
|
|
{
|
|
$result = new ValidationResult();
|
|
$result->addError("Error", ValidationResult::TYPE_ERROR, null, ValidationResult::CAST_HTML);
|
|
$result->addMessage("Message", ValidationResult::TYPE_GOOD);
|
|
$serialised = serialize($result);
|
|
|
|
/**
|
|
* @var ValidationResult $result2
|
|
*/
|
|
$result2 = unserialize($serialised ?? '');
|
|
$this->assertEquals(
|
|
[
|
|
[
|
|
'message' => 'Error',
|
|
'fieldName' => null,
|
|
'messageCast' => ValidationResult::CAST_HTML,
|
|
'messageType' => ValidationResult::TYPE_ERROR,
|
|
],
|
|
[
|
|
'message' => 'Message',
|
|
'fieldName' => null,
|
|
'messageCast' => ValidationResult::CAST_TEXT,
|
|
'messageType' => ValidationResult::TYPE_GOOD,
|
|
]
|
|
],
|
|
$result2->getMessages()
|
|
);
|
|
$this->assertFalse($result2->isValid());
|
|
}
|
|
}
|