forked from BeSimple/BeSimpleSoap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCacheTest.php
More file actions
94 lines (77 loc) · 2.62 KB
/
CacheTest.php
File metadata and controls
94 lines (77 loc) · 2.62 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
* (c) Francis Besset <francis.besset@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapCommon\Tests;
use BeSimple\SoapCommon\Cache;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamWrapper;
class CacheTest extends \PHPUnit_Framework_TestCase
{
public function testSetEnabled()
{
Cache::setEnabled(Cache::ENABLED);
$this->assertEquals(Cache::ENABLED, Cache::isEnabled());
Cache::setEnabled(Cache::DISABLED);
$this->assertEquals(Cache::DISABLED, Cache::isEnabled());
}
public function testSetEnabledBadValue()
{
$this->setExpectedException('InvalidArgumentException');
Cache::setEnabled('foo');
}
public function testSetType()
{
Cache::setType(Cache::TYPE_DISK);
$this->assertEquals(Cache::TYPE_DISK, Cache::getType());
Cache::setType(Cache::TYPE_NONE);
$this->assertEquals(Cache::TYPE_NONE, Cache::getType());
}
public function testSetTypeBadValue()
{
$this->setExpectedException('InvalidArgumentException');
Cache::setType('foo');
}
public function testSetDirectory()
{
vfsStream::setup('Fixtures');
$this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('foo'));
$dir = vfsStream::url('Fixtures/foo');
Cache::setDirectory($dir);
$this->assertEquals($dir, Cache::getDirectory());
$this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('foo'));
$this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('bar'));
$dir = vfsStream::url('Fixtures/bar');
Cache::setDirectory($dir);
$this->assertEquals($dir, Cache::getDirectory());
$this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('bar'));
}
public function testSetLifetime()
{
Cache::setLifetime(1234);
$this->assertEquals(1234, Cache::getLifetime());
Cache::setLifetime(4321);
$this->assertEquals(4321, Cache::getLifetime());
}
public function testSetLimit()
{
Cache::setLimit(10);
$this->assertEquals(10, Cache::getLimit());
Cache::setLimit(1);
$this->assertEquals(1, Cache::getLimit());
}
public function setUp()
{
ini_restore('soap.wsdl_cache_enabled');
ini_restore('soap.wsdl_cache');
ini_restore('soap.wsdl_cache_dir');
ini_restore('soap.wsdl_cache_ttl');
ini_restore('soap.wsdl_cache_limit');
}
}