1 form.test | public FormsFormCacheTestCase::testCacheFormCustomExpiration() |
Tests changing form_cache_expiration.
File
- core/
modules/ simpletest/ tests/ form.test, line 1671 - Unit tests for the Backdrop Form API.
Class
- FormsFormCacheTestCase
- Test cache_form.
Code
public function testCacheFormCustomExpiration() {
config_set('system.core', 'form_cache_expiration', -1 * (24 * 60 * 60));
$form = backdrop_get_form('form_test_cache_form');
$form_state = array('foo' => 'bar', 'build_info' => array('baz'));
form_set_cache($form['#build_id'], $form, $form_state);
// Cleanup expired tempstore entries the same way cron would do, but
// without actually running cron.
db_delete('tempstore')
->condition('expire', REQUEST_TIME, '<')
->execute();
$cached_form_state = array();
$cached_form = form_get_cache($form['#build_id'], $cached_form_state);
$this->assertNull($cached_form, 'Expired form was not returned from cache.');
$this->assertTrue(empty($cached_form_state), 'No data retrieved from cache for expired form.');
}