-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathContextTest.php
50 lines (42 loc) · 1.37 KB
/
ContextTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Created by PhpStorm.
* User: yf
* Date: 2019-01-06
* Time: 23:27
*/
namespace EasySwoole\Component\Tests;
use EasySwoole\Component\Context\ContextManager;
use EasySwoole\Component\Tests\Lib\ContextContextItemHandler;
use PHPUnit\Framework\TestCase;
class ContextTest extends TestCase
{
function __construct(?string $name = null, array $data = [], string $dataName = '')
{
ContextManager::getInstance()->registerItemHandler('handler',new ContextContextItemHandler());
parent::__construct($name, $data, $dataName);
}
function testHandler()
{
$object = ContextManager::getInstance()->get('handler');
$this->assertEquals('handler',$object->text);
ContextManager::getInstance()->destroy();
$this->assertEquals(true,$object->destroy);
}
function testSet()
{
ContextManager::getInstance()->set('key1','key1');
$this->assertEquals('key1',ContextManager::getInstance()->get('key1'));
}
function testUnset()
{
ContextManager::getInstance()->set('key1','key1');
ContextManager::getInstance()->unset('key1');
$this->assertEquals(null,ContextManager::getInstance()->get('key1'));
}
function testDestroy()
{
ContextManager::getInstance()->destroy();
$this->assertEquals(null,ContextManager::getInstance()->getContextArray());
}
}