Issue #1880834 by damiankloip, dawehner: Fixed Don't return all data from views_data() service when an invalid table is requested.

8.0.x
catch 2013-01-07 13:40:02 +00:00
parent a3a4347ffe
commit d1613d0116
2 changed files with 16 additions and 2 deletions

View File

@ -14,6 +14,13 @@ namespace Drupal\views\Tests;
*/
class ViewsDataTest extends ViewUnitTestBase {
/**
* Stores the views data cache service used by this test.
*
* @var \Drupal\views\ViewsDataCache
*/
protected $viewsDataCache;
public static function getInfo() {
return array(
'name' => 'Table Data',
@ -31,10 +38,15 @@ class ViewsDataTest extends ViewUnitTestBase {
$table_name = 'views_test_data';
$expected_data = $this->viewsData();
$data = drupal_container()->get('views.views_data')->get($table_name);
$this->viewsDataCache = drupal_container()->get('views.views_data');
$data = $this->viewsDataCache->get($table_name);
$this->assertEqual($data, $expected_data[$table_name], 'Make sure fetching views data by table works as expected.');
$data = drupal_container()->get('views.views_data')->get();
$data = $this->viewsDataCache->get($this->randomName());
$this->assertTrue(empty($data), 'Make sure fetching views data for an invalid table returns empty.');
$data = $this->viewsDataCache->get();
$this->assertTrue(isset($data[$table_name]), 'Make sure the views_test_data info appears in the total views data.');
$this->assertEqual($data[$table_name], $expected_data[$table_name], 'Make sure the views_test_data has the expected values.');
}

View File

@ -105,6 +105,8 @@ class ViewsDataCache {
if (isset($this->storage[$key])) {
return $this->storage[$key];
}
// If the key is invalid, return an empty array.
return array();
}
else {
if (!$this->fullyLoaded) {