mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
103 lines
2.6 KiB
PHP
Executable File
103 lines
2.6 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Karaka
|
|
*
|
|
* PHP Version 8.1
|
|
*
|
|
* @package tests
|
|
* @copyright 2013 Dennis Eichhorn
|
|
* @license OMS License 2.0
|
|
* @version 1.0.0
|
|
* @link https://jingga.app
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace phpOMS\tests\phpOMS\Model\Message;
|
|
|
|
use phpOMS\Model\Message\Notify;
|
|
use phpOMS\Model\Message\NotifyType;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
final class NotifyTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
/**
|
|
* @covers phpOMS\Model\Message\Notify
|
|
* @group framework
|
|
*/
|
|
public function testAttributes() : void
|
|
{
|
|
$obj = new Notify();
|
|
self::assertInstanceOf('\phpOMS\Model\Message\Notify', $obj);
|
|
|
|
/* Testing members */
|
|
self::assertObjectHasAttribute('delay', $obj);
|
|
self::assertObjectHasAttribute('title', $obj);
|
|
self::assertObjectHasAttribute('stay', $obj);
|
|
self::assertObjectHasAttribute('message', $obj);
|
|
self::assertObjectHasAttribute('level', $obj);
|
|
}
|
|
|
|
/**
|
|
* @covers phpOMS\Model\Message\Notify
|
|
* @group framework
|
|
*/
|
|
public function testDefault() : void
|
|
{
|
|
$obj = new Notify();
|
|
|
|
/* Testing default values */
|
|
self::assertEquals(0, $obj->toArray()['time']);
|
|
self::assertEquals('', $obj->toArray()['title']);
|
|
self::assertEquals('', $obj->toArray()['msg']);
|
|
self::assertEquals(0, $obj->toArray()['stay']);
|
|
self::assertEquals(NotifyType::INFO, $obj->toArray()['level']);
|
|
}
|
|
|
|
/**
|
|
* @covers phpOMS\Model\Message\Notify
|
|
* @group framework
|
|
*/
|
|
public function testSetGet() : void
|
|
{
|
|
$obj = new Notify('message', NotifyType::WARNING);
|
|
$obj->delay = 3;
|
|
$obj->stay = 5;
|
|
$obj->level = NotifyType::ERROR;
|
|
$obj->message ='msg';
|
|
$obj->title = 'title';
|
|
|
|
self::assertEquals([
|
|
'type' => 'notify',
|
|
'time' => 3,
|
|
'stay' => 5,
|
|
'msg' => 'msg',
|
|
'title' => 'title',
|
|
'level' => NotifyType::ERROR,
|
|
], $obj->toArray());
|
|
|
|
self::assertEquals(\json_encode([
|
|
'type' => 'notify',
|
|
'time' => 3,
|
|
'stay' => 5,
|
|
'msg' => 'msg',
|
|
'title' => 'title',
|
|
'level' => NotifyType::ERROR,
|
|
]), $obj->serialize());
|
|
|
|
self::assertEquals([
|
|
'type' => 'notify',
|
|
'time' => 3,
|
|
'stay' => 5,
|
|
'msg' => 'msg',
|
|
'title' => 'title',
|
|
'level' => NotifyType::ERROR,
|
|
], $obj->jsonSerialize());
|
|
|
|
$obj2 = new Notify();
|
|
$obj2->unserialize($obj->serialize());
|
|
self::assertEquals($obj, $obj2);
|
|
}
|
|
}
|