Projet

Général

Profil

Révision cd5c298a

Ajouté par Geoffroy Desvernay il y a plus de 5 ans

MAJ 7.60 -> 7.62

Voir les différences:

drupal7/modules/simpletest/tests/form.test
1420 1420
  }
1421 1421
}
1422 1422

  
1423
/**
1424
 * Test cache_form.
1425
 */
1426
class FormsFormCacheTestCase extends DrupalWebTestCase {
1427
  public static function getInfo() {
1428
    return array(
1429
      'name' => 'Form caching',
1430
      'description' => 'Tests storage and retrieval of forms from cache.',
1431
      'group' => 'Form API',
1432
    );
1433
  }
1434

  
1435
  function setUp() {
1436
    parent::setUp('form_test');
1437
  }
1438

  
1439
  /**
1440
   * Tests storing and retrieving the form from cache.
1441
   */
1442
  function testCacheForm() {
1443
    $form = drupal_get_form('form_test_cache_form');
1444
    $form_state = array('foo' => 'bar', 'build_info' => array('baz'));
1445
    form_set_cache($form['#build_id'], $form, $form_state);
1446

  
1447
    $cached_form_state = array();
1448
    $cached_form = form_get_cache($form['#build_id'], $cached_form_state);
1449

  
1450
    $this->assertEqual($cached_form['#build_id'], $form['#build_id'], 'Form retrieved from cache_form successfully.');
1451
    $this->assertEqual($cached_form_state['foo'], 'bar', 'Data retrieved from cache_form successfully.');
1452
  }
1453

  
1454
  /**
1455
   * Tests changing form_cache_expiration.
1456
   */
1457
  function testCacheFormCustomExpiration() {
1458
    variable_set('form_cache_expiration', -1 * (24 * 60 * 60));
1459

  
1460
    $form = drupal_get_form('form_test_cache_form');
1461
    $form_state = array('foo' => 'bar', 'build_info' => array('baz'));
1462
    form_set_cache($form['#build_id'], $form, $form_state);
1463

  
1464
    // Clear expired entries from cache_form, which should include the entry we
1465
    // just stored. Without this, the form will still be retrieved from cache.
1466
    cache_clear_all(NULL, 'cache_form');
1467

  
1468
    $cached_form_state = array();
1469
    $cached_form = form_get_cache($form['#build_id'], $cached_form_state);
1470

  
1471
    $this->assertNull($cached_form, 'Expired form was not returned from cache.');
1472
    $this->assertTrue(empty($cached_form_state), 'No data retrieved from cache for expired form.');
1473
  }
1474
}
1475

  
1423 1476
/**
1424 1477
 * Test wrapper form callbacks.
1425 1478
 */

Formats disponibles : Unified diff