Projet

Général

Profil

Révision 6eb8d15f

Ajouté par Assos Assos il y a presque 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/tests/views_cache.test
241 241
    $this->assertEqual($first_content_type, $second_content_type, t('Content types of responses are equal.'));
242 242
  }
243 243

  
244
  /**
245
   * Test caching of different exposed filter values with the same view result.
246
   *
247
   * Make sure the output is different.
248
   */
249
  function testExposedFilterSameResultsCaching() {
250
    // Create the view with time-based cache with hour lifetimes and add exposed
251
    // filter to it with "Starts with" operator.
252
    $view = $this->getBasicView();
253
    $view->set_display();
254
    $view->display_handler->override_option('cache', array(
255
      'type' => 'time',
256
      'results_lifespan' => '3600',
257
      'output_lifespan' => '3600',
258
    ));
259
    $view->display_handler->override_option('filters', array(
260
      'name' => array(
261
        'id' => 'name',
262
        'table' => 'views_test',
263
        'field' => 'name',
264
        'relationship' => 'none',
265
        'operator' => 'starts',
266
        'exposed' => TRUE,
267
        'expose' => array(
268
          'operator_id' => 'name_op',
269
          'operator' => 'name_op',
270
          'identifier' => 'name',
271
        ),
272
      ),
273
    ));
274

  
275
    // Clone the view before setting exposed input.
276
    $clone = $view->copy();
277

  
278
    // Pass "Rin" to the exposed filter and check that only one row returned.
279
    $view->set_exposed_input(array(
280
      'name' => 'Rin',
281
    ));
282
    $this->executeView($view);
283
    $first_result = $view->result;
284
    $first_output = $view->render();
285
    $this->assertEqual(1, count($first_result), t('The number of rows returned by the first view match.'));
286

  
287
    // Pass full "Ringo" to the exposed filter at the second time and make sure
288
    // results are the same.
289
    $clone->set_exposed_input(array(
290
      'name' => 'Ringo',
291
    ));
292
    $this->executeView($clone);
293
    $second_result = $clone->result;
294
    $second_output = $clone->render();
295
    $this->assertEqual($first_result, $second_result, t('Results of both views are the same.'));
296

  
297
    // Check that output is not the same and it contains full "Ringo" word in
298
    // default value of exposed input.
299
    $this->assertNotEqual($first_output, $second_output, t('Output of the second view is different.'));
300
    $this->drupalSetContent($second_output);
301
    $element = $this->xpath('//input[@name="name" and @value="Ringo"]');
302
    $this->assertTrue(!empty($element), t('Input field of exposed filter has the second value.'));
303

  
304
    $view->destroy();
305
    $clone->destroy();
306
  }
307

  
244 308
}

Formats disponibles : Unified diff