## Main test
# Confirm, that Memcached service is installed and started in the test system
# Re-install In-Portal, confirm that on "Step 9 - System Configuration" these options are available choice for "Output Caching Engine" setting:
* on PHP7.*: Memcached
* on PHP5.*: Memcache
# Login to Administrative Console
# Go to {nav Tools > System Tools} section
# Confirm, that "Memory Cache" subsection is visible
## Testing auto-usage of Memcached on PHP 7+, when Memcache is configured to be used
# Configure Memcache to be used (ensure `$_CONFIG['Misc']['CacheHandler'] = 'Memcache';` in the `/system/config.php`)
# Stop Memcached service (e.g. use `service memcached stop` or other related command on server)
# Login to Administrative Console
# Go to {nav Tools > System Tools} section
# Confirm, that "Memory Cache" subsection is visible
## Code for kApplication fscade testing
```
$application->addCache('key', '1');
if ( $application->getCache('key') === '1' ) {
echo 'addCache is working<br>';
echo 'getCache is working<br>';
}
$application->setCache('key', '2');
if ( $application->getCache('key') === '2' ) {
echo 'setCache is working<br>';
}
$application->deleteCache('key');
if ( $application->getCache('key') === false ) {
echo 'deleteCache is working<br>';
}
exit;
```
# Place test code in the index.php, after `$application->Init();`
# Open home page.
# Confirm that output is:
* addCache is working
* getCache is working
* setCache is working
* deleteCache is workingNOTE: Perform each test on PHP 5 and on PHP 7 AND restart Memcached service when switching PHP version AND results must match, unless otherwise noted.
# Part 1 (general test)
# confirm, that Memcached service is installed and started on the server
# re-install In-Portal and on "Step 9 - System Configuration" confirm, that these option is available choice for "Output Caching Engine" dropdown:
* on PHP 5: Memcache
* on PHP 7: Memcached
# login to Administrative Console
# go to {nav Tools > System Tools} section
# confirm, that "Memory Cache" sub-section is visible
# Part 2 (fallback for PHP 5 configuration on PHP 7)
# configure Memcache using PHP 5-style setting (ensure `$_CONFIG['Misc']['CacheHandler'] = 'Memcache';` is present in the `/system/config.php`)
# login to Administrative Console
# go to {nav Tools > System Tools} section
# confirm, that "Memory Cache" sub-section is visible
# Preparation for following tests
1. create `/memcache_test.php` file with following content:
```
lang=php
<?php
<?php
$start = microtime(true);
define('FULL_PATH', realpath(dirname(__FILE__)));
include_once(FULL_PATH.'/core/kernel/startup.php');
$application =& kApplication::Instance();
$application->Init();
echo 'PHP ' . PHP_VERSION . '<br/><br/>';
switch ( $application->GetVar('step') ) {
case 'delete':
echo 'Deleting Infinite Key<br/>' . PHP_EOL;
$application->deleteCache('infinite_key');
echo 'Deleting Expiring Key<br/>' . PHP_EOL;
$application->deleteCache('expiring_key');
echo 'Deleting Infinite Added Key<br/>' . PHP_EOL;
$application->deleteCache('infinite_added_key');
echo 'Deleting Expiring Added Key<br/>' . PHP_EOL;
$application->deleteCache('expiring_added_key');
break;
case 'set':
$result = $application->setCache('infinite_key', 'infinite value');
echo 'Setting Infinite Key: ';
var_dump($result);
$result = $application->setCache('expiring_key', 'expiring value', 30);
echo 'Setting Expiring Key: ';
var_dump($result);
$result = $application->addCache('infinite_added_key', 'infinite added value');
echo 'Adding Infinite Adding Key: ';
var_dump($result);
$result = $application->addCache('expiring_added_key', 'expiring added value', 30);
echo 'Adding Expiring Adding Key: ';
var_dump($result);
break;
default:
echo 'Getting Infinite Key:' . PHP_EOL;
var_dump($application->getCache('infinite_key'));
echo 'Getting Expiring Key:' . PHP_EOL;
var_dump($application->getCache('expiring_key'));
echo 'Getting Infinite Added Key:' . PHP_EOL;
var_dump($application->getCache('infinite_added_key'));
echo 'Getting Expiring Added Key:' . PHP_EOL;
var_dump($application->getCache('expiring_added_key'));
break;
}
$end = microtime(true);
```
2. this is URL for showing: `.../memcache_test.php?step=show`
3. this is URL for setting: `.../memcache_test.php?step=set`
4. this is URL for deleting: `.../memcache_test.php?step=delete`
## Part 3 (no cached value by default)
1. open showing URL couple of times
2. confirm, that output is similar to this:
```
PHP ...
Getting Infinite Key:
boolean false
Getting Expiring Key:
boolean false
Getting Infinite Added Key:
boolean false
Getting Expiring Added Key:
boolean false
```
## Part 4 (value is persistent upon setting/adding)
1. open setting URL
2. confirm, that output is similar to this:
```
PHP ...
Setting Infinite Key:
boolean true
Setting Expiring Key:
boolean true
Adding Infinite Adding Key:
boolean true
Adding Expiring Adding Key:
boolean true
```
3. open setting URL
4. confirm, that output is similar to this:
```
PHP ...
Setting Infinite Key:
boolean true
Setting Expiring Key:
boolean true
Adding Infinite Adding Key:
boolean false
Adding Expiring Adding Key:
boolean false
```
5. open getting URL couple of times
6. confirm, that output is similar to this:
```
PHP ...
Getting Infinite Key:
string 'infinite value' (length=14)
Getting Expiring Key:
string 'expiring value' (length=14)
Getting Infinite Added Key:
string 'infinite added value' (length=20)
Getting Expiring Added Key:
string 'expiring added value' (length=20)
```
7. wait 35 seconds (because auto-expiration is set to 30 seconds)
8. open getting URL couple of times
9. confirm, that output is similar to this:
```
PHP ...
Getting Infinite Key:
string 'infinite value' (length=14)
Getting Expiring Key:
boolean false
Getting Infinite Added Key:
string 'infinite added value' (length=20)
Getting Expiring Added Key:
boolean false
```
10. open deleting URL
11. open showing URL couple of times
12. confirm, that output is similar to this:
```
PHP ...
Getting Infinite Key:
boolean false
Getting Expiring Key:
boolean false
Getting Infinite Added Key:
boolean false
Getting Expiring Added Key:
boolean false
```