Commit eeb7c103 authored by catch's avatar catch

Issue #2189453 by damiankloip, sun: Fatal error: Call to a member function...

Issue #2189453 by damiankloip, sun: Fatal error: Call to a member function hasPath() on a non-object in ViewListController::getDisplayPaths().
parent 1b584005
......@@ -161,7 +161,13 @@ public function key() {
*/
public function valid() {
$key = key($this->instanceIDs);
return $key !== NULL && $key !== FALSE;
// Check the key is valid but also that this key yields a plugin from get().
// There can be situations where configuration contains data for a plugin
// that cannot be instantiated. In this case, this enables us to skip that
// plugin during iteration.
// @todo Look at removing when https://drupal.org/node/2080823 has been
// solved.
return $key !== NULL && $key !== FALSE && $this->get($key);
}
/**
......
......@@ -50,6 +50,10 @@ protected function setUp() {
*/
public function testFeedUI() {
$this->drupalGet('admin/structure/views');
// Verify that the page lists the test_display_feed view.
// Regression test: ViewsListController::getDisplayPaths() did not properly
// check whether a DisplayBag was returned in iterating over all displays.
$this->assertText('test_display_feed');
// Check the attach TO interface.
$this->drupalGet('admin/structure/views/nojs/display/test_display_feed/feed_1/displays');
......
......@@ -145,7 +145,7 @@ public function testRemoveInstanceId() {
* @see \Drupal\Component\Plugin\DefaultPluginBag::setConfiguration()
*/
public function testSetConfiguration() {
$this->setupPluginBag($this->exactly(4));
$this->setupPluginBag($this->exactly(3));
$expected = array(
'id' => 'cherry',
'key' => 'value',
......
......@@ -75,11 +75,26 @@ protected function setupPluginBag(\PHPUnit_Framework_MockObject_Matcher_InvokedR
$create_count = $create_count ?: $this->never();
$this->pluginManager->expects($create_count)
->method('createInstance')
->will($this->returnValueMap($map));
->will($this->returnCallback(array($this, 'returnPluginMap')));
$this->defaultPluginBag = new DefaultPluginBag($this->pluginManager, $this->config);
}
/**
* Return callback for createInstance.
*
* @param string $plugin_id
* The plugin ID to return the mock plugin for.
*
* @return \Drupal\Component\Plugin\PluginInspectionInterface|\PHPUnit_Framework_MockObject_MockObject
* The mock plugin object.
*/
public function returnPluginMap($plugin_id) {
if (isset($this->pluginInstances[$plugin_id])) {
return $this->pluginInstances[$plugin_id];
}
}
/**
* Returns a mocked plugin object.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment