From 65b1a47c3aed5256cba9aad4430f55eb2e021eb0 Mon Sep 17 00:00:00 2001 From: damiankloip <damian@damoweb.co.uk> Date: Sun, 26 Aug 2012 16:01:39 +0200 Subject: [PATCH] use format_patch instead of t, Added create tests --- lib/Drupal/views/Tests/ViewsStorageTest.php | 26 ++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/Drupal/views/Tests/ViewsStorageTest.php b/lib/Drupal/views/Tests/ViewsStorageTest.php index 1c91afc0d693..60f2d0f663a1 100644 --- a/lib/Drupal/views/Tests/ViewsStorageTest.php +++ b/lib/Drupal/views/Tests/ViewsStorageTest.php @@ -71,7 +71,7 @@ function testConfigurableCRUD() { // expected properties. $this->assertTrue($view instanceof View, 'Single View instance loaded.'); foreach ($this->config_properties as $property) { - $this->assertTrue(isset($view->{$property}), t('Property: @property loaded onto View.', array('@property' => $property))); + $this->assertTrue(isset($view->{$property}), format_string('Property: @property loaded onto View.', array('@property' => $property))); } // Check the displays have been loaded correctly from config display data. @@ -80,7 +80,7 @@ function testConfigurableCRUD() { // Check each ViewDisplay object and confirm that it has the correct key. foreach ($view->display as $key => $display) { - $this->assertTrue($display instanceof ViewsDisplay, t('Display: @display is instance of ViewsDisplay.', array('@display' => $key))); + $this->assertTrue($display instanceof ViewsDisplay, format_string('Display: @display is instance of ViewsDisplay.', array('@display' => $key))); $this->assertEqual($key, $display->id, 'The display has the correct ID.'); // Confirm that the display options array exists. $display_options = $display->display_options; @@ -100,10 +100,30 @@ function testConfigurableCRUD() { // Check that the correct number of Configurable objects have been loaded. $count = count($all_configurables); - $this->assertEqual($count, count($all_config), t('The array of all @count Configurable objects is loaded.', array('@count' => $count))); + $this->assertEqual($count, count($all_config), format_string('The array of all @count Configurable objects is loaded.', array('@count' => $count))); // Check that all of these machine names match. $this->assertIdentical(array_keys($all_configurables), array_map($prefix_map, $all_config), 'All loaded elements match.'); + + // Create a new View instance with empty values. + $created = $controller->create(array()); + + $this->assertTrue($created instanceof View, 'Created object is a View.'); + // Check that the View contains all of the properties. + foreach ($this->config_properties as $property) { + $this->assertTrue(isset($view->{$property}), format_string('Property: @property created on View.', array('@property' => $property))); + } + + // Create a new View instance with config values. + $values = config('views.view.archive')->get(); + $created = $controller->create($values); + + $this->assertTrue($created instanceof View, 'Created object is a View.'); + // Check that the View contains all of the properties. + foreach ($this->config_properties as $property) { + $this->assertTrue(isset($view->{$property}), format_string('Property: @property created on View.', array('@property' => $property))); + $this->assertIdentical($values[$property], $created->{$property}, format_string('Property value: @property matches configuration value.', array('@property' => $property))); + } } } -- GitLab