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_module.test
151 151
    $this->assertEqual('views_handler_filter', get_class($handler));
152 152
  }
153 153

  
154
  /**
155
   * Tests views_fetch_data().
156
   */
157
  function testFetchData() {
158

  
159
    // Make sure we start with a empty cache.
160
    $this->resetStaticViewsDataCache();
161
    cache_clear_all('*', 'cache_views', TRUE);
162
    variable_set('views_test_views_data_count', 0);
163

  
164
    // Request info about an existing table.
165
    $this->assertTrue(views_fetch_data('views_test'), 'Data about existing table returned');
166
    // This should have triggered a views data rebuild, and written a cache
167
    // entry for all tables and the requested table but no other tables.
168
    $this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once');
169
    $this->assertTrue(cache_get('views_data:en', 'cache_views'), 'Cache for all tables written.');
170
    $this->assertTrue(cache_get('views_data:views_test:en', 'cache_views'), 'Cache for requested table written.');
171
    $this->assertFalse(cache_get('views_data:views_test_previous:en', 'cache_views'), 'No Cache written for not requested table.');
172
    $this->assertTrue(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is fully loaded');
173

  
174
    $this->resetStaticViewsDataCache();
175

  
176
    // Request the same table again.
177
    $this->assertTrue(views_fetch_data('views_test'), 'Data about existing table returned');
178
    $this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once');
179
    $this->assertFalse(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is not fully loaded');
180

  
181
    $this->resetStaticViewsDataCache();
182

  
183
    // Request a missing table, this should load the full cache from cache but
184
    // not rebuilt.
185
    $this->assertFalse(views_fetch_data('views_test_missing'), 'No data about missing table returned');
186
    $this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once');
187
    $this->assertTrue(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is fully loaded');
188

  
189
    $this->resetStaticViewsDataCache();
190

  
191
    // Request the same empty table again, this should load only that (empty)
192
    // cache for that table.
193
    $this->assertFalse(views_fetch_data('views_test_missing'), 'No data about missing table returned');
194
    $this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once');
195
    $this->assertFalse(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is not fully loaded');
196

  
197
  }
198

  
154 199
  /**
155 200
   * Ensure that a certain handler is a instance of a certain table/field.
156 201
   */
......
160 205

  
161 206
    $this->assertEqual($field_data['handler'], get_class($handler));
162 207
  }
208

  
209
  /**
210
   * Resets the views data cache.
211
   */
212
  protected function resetStaticViewsDataCache() {
213
    drupal_static_reset('_views_fetch_data_cache');
214
    drupal_static_reset('_views_fetch_data_recursion_protected');
215
    drupal_static_reset('_views_fetch_data_fully_loaded');
216
  }
163 217
}

Formats disponibles : Unified diff