Bug #3188108 Inline edit break the hyperlink of foreign keyed value
[phpmyadmin/crack.git] / test / PMA_cache_test.php
blob34aa5f98d415ff2105141aae40b616f51ca708c8
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for caching data in session
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_cache_test.php
8 */
10 /**
11 * Tests core.
13 require_once 'PHPUnit/Framework.php';
15 /**
16 * Include to test.
18 require_once './libraries/common.lib.php';
20 /**
21 * Test cache.
24 class PMA_cache_test extends PHPUnit_Framework_TestCase
27 /**
28 * @var array temporary variable for globals array
30 protected $tmpGlobals;
32 /**
33 * @var array temporary variable for session array
35 protected $tmpSession;
37 /**
38 * storing globals and session
40 public function setUp()
42 $this->tmpGlobals = $GLOBALS;
43 $this->tmpSession = $_SESSION;
46 /**
47 * Test if cached data is available after set
49 public function testCacheExists()
51 $GLOBALS['server'] = 'server';
52 PMA_cacheSet('test_data', 5, true);
53 PMA_cacheSet('test_data_2', 5, true);
55 $this->assertTrue(PMA_cacheExists('test_data', true));
56 $this->assertTrue(PMA_cacheExists('test_data_2', 'server'));
57 $this->assertFalse(PMA_cacheExists('fake_data_2', true));
60 /**
61 * Test if cacheGet does not return data for non existing caache entries
63 public function testCacheGet()
65 $GLOBALS['server'] = 'server';
66 PMA_cacheSet('test_data', 5, true);
67 PMA_cacheSet('test_data_2', 5, true);
69 $this->assertNotNull(PMA_cacheGet('test_data', true));
70 $this->assertNotNull(PMA_cacheGet('test_data_2', 'server'));
71 $this->assertNull(PMA_cacheGet('fake_data_2', true));
74 /**
75 * Test retrieval of cached data
77 public function testCacheSetGet()
79 $GLOBALS['server'] = 'server';
80 PMA_cacheSet('test_data', 25, true);
82 PMA_cacheSet('test_data', 5, true);
83 $this->assertEquals(5, $_SESSION['cache']['server_server']['test_data']);
84 PMA_cacheSet('test_data_3', 3, true);
85 $this->assertEquals(3, $_SESSION['cache']['server_server']['test_data_3']);
88 /**
89 * Test clearing cached values
91 public function testCacheUnSet()
93 $GLOBALS['server'] = 'server';
94 PMA_cacheSet('test_data', 25, true);
95 PMA_cacheSet('test_data_2', 25, true);
97 PMA_cacheUnset('test_data', true);
98 $this->assertArrayNotHasKey('test_data', $_SESSION['cache']['server_server']);
99 PMA_cacheUnset('test_data_2', true);
100 $this->assertArrayNotHasKey('test_data_2', $_SESSION['cache']['server_server']);