PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 2.7.2
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v2.7.2
4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / vendor / wpdevelopers / embera / tests / Embera / Cache / FilesystemTest.php
embedpress / vendor / wpdevelopers / embera / tests / Embera / Cache Last commit date
CacheAdapterTest.php 5 years ago FilesystemTest.php 5 years ago
FilesystemTest.php
121 lines
1 <?php
2 /**
3 * FilesystemTest.php
4 *
5 * @package Tests
6 * @author Michael Pratt <yo@michael-pratt.com>
7 * @link http://www.michael-pratt.com/
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12 namespace Embera\Cache;
13
14 use PHPUnit\Framework\TestCase;
15
16 use DateTime;
17 use DateInterval;
18
19 class FilesystemTest extends TestCase
20 {
21 public function testCanStoreStringsArraysAndObjects()
22 {
23 $cache = new Filesystem(sys_get_temp_dir(), mt_rand(1, 5));
24 $cache->clear();
25
26 $data = [ md5(mt_rand(1000, 9000)), sha1(mt_rand(1000, 9000)), mt_rand(1000, 9000), 'This is a string! ? \' 345 345 sdf # @ $ % & *'];
27
28 $this->assertTrue($cache->set('array', $data));
29 $this->assertEquals($cache->get('array'), $data);
30
31 $this->assertTrue($cache->set('object', (object) $data));
32 $this->assertEquals($cache->get('object'), (object) $data);
33
34 $this->assertTrue($cache->set('string', end($data)));
35 $this->assertEquals($cache->get('string'), end($data));
36 }
37
38 public function testBehaviourOnOverwrite()
39 {
40 $cache = new Filesystem(sys_get_temp_dir(), mt_rand(1, 5));
41 $this->assertTrue($cache->set('twice', 'this is the first string', 5));
42 $this->assertTrue($cache->set('twice', 'This is the second string', 2));
43 $this->assertEquals($cache->get('twice'), 'This is the second string');
44 }
45
46 public function testNonExistantKeys()
47 {
48 $cache = new Filesystem(sys_get_temp_dir(), mt_rand(1, 5));
49 $this->assertNull($cache->get('unknown_key'));
50 }
51
52 public function testCacheDuration()
53 {
54 $expirationDate = new DateTime('Now');
55 $expirationDate->add(new DateInterval('PT2S'));
56
57 $cache = new Filesystem(sys_get_temp_dir(), mt_rand(1, 5));
58 $this->assertTrue($cache->set('test_duration', 'dummy data', $expirationDate));
59 sleep(4);
60
61 $this->assertNull($cache->get('test_duration'));
62 }
63
64 public function testDeleteCache()
65 {
66 $cache = new Filesystem(sys_get_temp_dir(), mt_rand(1, 5));
67
68 $this->assertTrue($cache->set('deleted_key', 'dummy data'));
69 $this->assertTrue($cache->has('deleted_key'));
70 $this->assertTrue($cache->delete('deleted_key'));
71 $this->assertNull($cache->get('deleted_key'));
72 $this->assertFalse($cache->has('deleted_key'));
73 $this->assertFalse($cache->delete('deleted_key'));
74 }
75
76 public function testEnabledConditions()
77 {
78 $cache = new Filesystem('/path/unknown/' . mt_rand(0,5000), 1);
79 $this->assertFalse($cache->isEnabled());
80
81 $cache = new Filesystem(sys_get_temp_dir(), 1);
82 $cache->set('enable_test', 'dummy_data_1');
83 $this->assertTrue($cache->has('enable_test'));
84 $this->assertEquals($cache->get('enable_test'), 'dummy_data_1');
85 $this->assertTrue($cache->delete('enable_test'));
86
87 $cache->disable();
88 $this->assertFalse($cache->isEnabled());
89 $cache->set('enable_test', 'dummy_data_1');
90 $this->assertFalse($cache->has('enable_test'));
91 $this->assertNull($cache->get('enable_test'));
92 $this->assertFalse($cache->delete('enable_test'));
93 $this->assertFalse($cache->clear());
94
95 $cache->enable();
96 $cache->set('enable_test', 'dummy_data_1');
97 $this->assertTrue($cache->has('enable_test'));
98 $this->assertEquals($cache->get('enable_test'), 'dummy_data_1');
99 $this->assertTrue($cache->delete('enable_test'));
100 }
101
102 public function testClearCache()
103 {
104 $cache = new Filesystem(sys_get_temp_dir(), 1);
105 $cache->set('clear_1', 'dummy_data_1');
106 $cache->set('clear_2', 'dummy_data_2');
107 $cache->set('clear_3', 'dummy_data_3');
108
109 $this->assertEquals($cache->get('clear_1'), 'dummy_data_1');
110 $this->assertEquals($cache->get('clear_2'), 'dummy_data_2');
111 $this->assertEquals($cache->get('clear_3'), 'dummy_data_3');
112
113 $this->assertTrue($cache->clear());
114
115 $this->assertEquals($cache->get('clear_1'), null);
116 $this->assertEquals($cache->get('clear_2'), null);
117 $this->assertEquals($cache->get('clear_3'), null);
118 }
119
120 }
121