Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3485117
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3485117
Commits
34b980b3
Commit
34b980b3
authored
12 years ago
by
Jess
Committed by
Tim Plunkett
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Improved documentation in the ViewsStorageTest.
parent
701b0d80
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Drupal/views/Tests/ViewsStorageTest.php
+32
-29
32 additions, 29 deletions
lib/Drupal/views/Tests/ViewsStorageTest.php
with
32 additions
and
29 deletions
lib/Drupal/views/Tests/ViewsStorageTest.php
+
32
−
29
View file @
34b980b3
...
...
@@ -11,9 +11,17 @@
use
Drupal\views\View
;
use
Drupal\views\ViewsDisplay
;
/**
* Tests that functionality of the the ViewsStorageController.
*/
class
ViewsStorageTest
extends
WebTestBase
{
protected
$config_properties
=
array
(
/**
* Properties that should be stored in the configuration.
*
* @var array
*/
protected
$config_properties
=
array
(
'disabled'
,
'api_version'
,
'name'
,
...
...
@@ -34,7 +42,7 @@ class ViewsStorageTest extends WebTestBase {
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Views configura
tion entity
CRUD tests'
,
'name'
=>
'Views configura
ble
CRUD tests'
,
'description'
=>
'Test the CRUD functionality for ViewStorage.'
,
'group'
=>
'Views'
,
);
...
...
@@ -43,64 +51,59 @@ public static function getInfo() {
/**
* Tests CRUD operations.
*/
function
testConfigEntityCRUD
()
{
// Get the entity info.
function
testConfigurableCRUD
()
{
// Get the Configurable information and controller.
$info
=
entity_get_info
(
'view'
);
// Get the entity controller.
$controller
=
entity_get_controller
(
'view'
);
//
Tes
t an info array has been returned.
$this
->
assertTrue
(
!
empty
(
$info
)
&&
is_array
(
$info
),
'View
entity
info array loaded.'
);
//
Confirm tha
t an info array has been returned.
$this
->
assertTrue
(
!
empty
(
$info
)
&&
is_array
(
$info
),
'
The
View info array
is
loaded.'
);
// Confirm we have the correct controller class.
$this
->
assertTrue
(
$controller
instanceof
ViewStorageController
,
'Correct entity controller loaded.'
);
// Loading.
$this
->
assertTrue
(
$controller
instanceof
ViewStorageController
,
'The correct controller is loaded.'
);
//Load a single
c
onfig
entity
.
//
Load a single
C
onfig
urable object from the controller
.
$load
=
$controller
->
load
(
array
(
'archive'
));
$view
=
reset
(
$load
);
// Confirm it's a view.
// Confirm that an actual view object is loaded and that it returns all of
// expected properties.
$this
->
assertTrue
(
$view
instanceof
View
,
'Single View instance loaded.'
);
// Check that the View contains all of the properties.
foreach
(
$this
->
config_properties
as
$property
)
{
$this
->
assertTrue
(
isset
(
$view
->
{
$property
}),
t
(
'Property: @property loaded onto View.'
,
array
(
'@property'
=>
$property
)));
}
// Check the displays have been loaded correctly from config display data.
$expected_displays
=
array
(
'default'
,
'page'
,
'block'
);
// Check display keys.
$this
->
assertEqual
(
array_keys
(
$view
->
display
),
$expected_displays
,
'Correct display names present.'
);
$this
->
assertEqual
(
array_keys
(
$view
->
display
),
$expected_displays
,
'The correct display names are present.'
);
// Check each ViewDisplay object and confirm that it has the correct key.
foreach
(
$view
->
display
as
$key
=>
$display
)
{
// Confirm it's a ViewDisplay object.
$this
->
assertTrue
(
$display
instanceof
ViewsDisplay
,
t
(
'Display: @display is instance of ViewsDisplay.'
,
array
(
'@display'
=>
$key
)));
// Check the display ID array key and object property match.
$this
->
assertEqual
(
$key
,
$display
->
id
,
'The display has the correct ID.'
);
// Che
ck
display options array exists
on the ViewsDisplay
.
// C
onfirm that t
he display options array exists.
$display_options
=
$display
->
display_options
;
$this
->
assertTrue
(
!
empty
(
$display_options
)
&&
is_array
(
$display_options
),
'Display options exist.'
);
}
// Load all config entities.
$all_entities
=
$controller
->
load
();
// Get a list of all existing default view config.
// Fetch data for all Configurable objects and default view configurations.
$all_configurables
=
$controller
->
load
();
$all_config
=
config_get_storage_names_with_prefix
(
'views.view'
);
// Remove 'views.view.' prefix from config names for comparision with
// loaded
c
onfig
entitie
s.
// Remove
the
'views.view.' prefix from config names for comparision with
// loaded
C
onfig
urable object
s.
$prefix_map
=
function
(
$value
)
{
$parts
=
explode
(
'.'
,
$value
);
return
end
(
$parts
);
};
// Check correct number of entities have been loaded.
$count
=
count
(
$all_entities
);
$this
->
assertEqual
(
$count
,
count
(
$all_config
),
t
(
'Array of all @count entities loaded.'
,
array
(
'@count'
=>
$count
)));
// Check all of these machine names match.
$this
->
assertIdentical
(
array_keys
(
$all_entities
),
array_map
(
$prefix_map
,
$all_config
),
'All loaded elements match.'
);
// 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
)));
// Check that all of these machine names match.
$this
->
assertIdentical
(
array_keys
(
$all_configurables
),
array_map
(
$prefix_map
,
$all_config
),
'All loaded elements match.'
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment