colly_wyx
2018-04-27 74adf3a72663f151dc2c1b87ecb4ea4b0e080a50
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env php
<?php
/**
 * PhpUnderControl_PhalApiCookie_Test
 *
 * 针对 ../../../PhalApi/PhalApi/Cookie.php PhalApi_Cookie 类的PHPUnit单元测试
 *
 * @author: dogstar 20150411
 */
 
require_once dirname(__FILE__) . '/test_env.php';
 
if (!class_exists('PhalApi_Cookie')) {
    require dirname(__FILE__) . '/../../../PhalApi/PhalApi/Cookie.php';
}
 
class PhpUnderControl_PhalApiCookie_Test extends PHPUnit_Framework_TestCase
{
    public $phalApiCookie;
 
    protected function setUp()
    {
        parent::setUp();
 
        $this->phalApiCookie = new PhalApi_Cookie();
    }
 
    protected function tearDown()
    {
    }
 
 
    /**
     * @group testGet
     */ 
    public function testGet()
    {
        $key = NULL;
 
        $rs = $this->phalApiCookie->get($key);
 
        $this->assertTrue(is_array($rs));
 
        $this->assertNull($this->phalApiCookie->get('noThisKey'));
 
        $_COOKIE['aKey'] = 'phalapi';
        $key = 'aKey';
        $this->assertEquals('phalapi', $this->phalApiCookie->get($key));
    }
 
    /**
     * @group testSet
     */ 
    public function testSet()
    {
        $key = 'bKey';
        $value = '2015';
 
        $rs = @$this->phalApiCookie->set($key, $value);
 
        //should not get in this time, but next time
        $this->assertNull($this->phalApiCookie->get($key));
    }
 
}