Commit 59a54c3e authored by webchick's avatar webchick
Browse files

Issue #1962130 by dawehner, YesCT, tim.plunkett, CEikermann: Fixed Fatal...

Issue #1962130 by dawehner, YesCT, tim.plunkett, CEikermann: Fixed Fatal Error: ViewUI::isTranslatable endless loop.
parent 34acf68f
......@@ -67,7 +67,7 @@ public function setOriginalID($id) {
* configuration entities but has no effect after saving, since each
* configuration entity is unique.
*/
final public function isNew() {
public function isNew() {
// Configuration entity IDs are strings, and '0' is a valid ID.
return !empty($this->enforceIsNew) || $this->id() === NULL || $this->id() === '';
}
......
<?php
/**
* @file
* Contains \Drupal\translation_entity\Tests\Views\TranslationEntityViewsUITest.
*/
namespace Drupal\translation_entity\Tests\Views;
use Drupal\views\Tests\UI\UITestBase;
/**
* Tests the views UI when translation_entity is enabled.
*/
class TranslationEntityViewsUITest extends UITestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view');
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('translation_entity');
public static function getInfo() {
return array(
'name' => 'Entity Translation: Views UI',
'description' => 'Tests the views UI when entity translation is enabled.',
'group' => 'Views module integration',
);
}
/**
* Tests the views UI.
*/
public function testViewsUI() {
$this->drupalGet('admin/structure/views/view/test_view/edit');
$this->assertTitle(t('@label (@table) | @site-name', array('@label' => 'Test view', '@table' => 'Views test data', '@site-name' => $this->container->get('config.factory')->get('system.site')->get('name'))));
}
}
......@@ -66,7 +66,7 @@ public function testCacheData() {
$this->clickLink(t('break this lock'));
// Test we can save the view.
$this->drupalPost('admin/structure/views/view/test_view/edit', array(), t('Save'));
$this->assertText(t('The view test_view has been saved.'));
$this->assertRaw(t('The view %view has been saved.', array('%view' => 'Test view')));
}
}
......@@ -52,7 +52,7 @@ public function testDeleteWithNoPath() {
$this->drupalPost(NULL, array(), t('Add Page'));
$this->drupalPost(NULL, array(), t('delete Page'));
$this->drupalPost(NULL, array(), t('Save'));
$this->assertRaw(format_string('The view %view has been saved.', array('%view' => 'test_view')));
$this->assertRaw(t('The view %view has been saved.', array('%view' => 'Test view')));
}
}
<?php
/**
* @file
* Contains \Drupal\views\Tests\ViewsUI\ViewUIObjectTest.
*/
namespace Drupal\views\Tests\ViewsUI;
use Drupal\Tests\UnitTestCase;
use Drupal\views\ViewExecutable;
use Drupal\views_ui\ViewUI;
use Symfony\Component\DependencyInjection\Container;
// Needed because the Entity class uses this constant.
// @todo Remove once http://drupal.org/node/1620010 is in.
if (!defined('LANGUAGE_NOT_SPECIFIED')) {
define('LANGUAGE_NOT_SPECIFIED', 'und');
}
if (!defined('DRUPAL_CORE_COMPATIBILITY')) {
define('DRUPAL_CORE_COMPATIBILITY', '8.x');
}
/**
* Tests the ViewUI class.
*
* @see \Drupal\views_ui\ViewUI
*/
class ViewUIObjectTest extends UnitTestCase {
public static function getInfo() {
return array(
'name' => 'View UI Object',
'description' => 'Test the ViewUI class.',
'group' => 'Views UI'
);
}
/**
* Tests entity method decoration.
*/
public function testEntityDecoration() {
$method_args = array();
$method_args['setOriginalID'] = array(12);
$method_args['setStatus'] = array(TRUE);
$method_args['setNewRevision'] = array(FALSE);
$method_args['enforceIsNew'] = array(FALSE);
$method_args['label'] = array(LANGUAGE_NOT_SPECIFIED);
$method_args['isDefaultRevision'] = array(TRUE);
$reflection = new \ReflectionClass('Drupal\Core\Config\Entity\ConfigEntityInterface');
$interface_methods = array();
foreach ($reflection->getMethods() as $reflection_method) {
$interface_methods[] = $reflection_method->getName();
// EntityInterface::isNew() is missing from the list of methods, because it
// calls id(), which breaks the ->expect($this->once()) call. Call it later.
if ($reflection_method->getName() != 'isNew') {
if (count($reflection_method->getParameters()) == 0) {
$method_args[$reflection_method->getName()] = array();
}
}
}
$storage = $this->getMock('Drupal\views\Plugin\Core\Entity\View', $interface_methods, array(array(), 'view'));
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor()
->setConstructorArgs(array($storage))
->getMock();
$view_ui = new ViewUI($storage, $executable);
foreach ($method_args as $method => $args) {
$method_mock = $storage->expects($this->once())
->method($method);
foreach ($args as $arg) {
$method_mock->with($this->equalTo($arg));
}
call_user_func_array(array($view_ui, $method), $args);
}
$storage->expects($this->once())
->method('isNew');
$view_ui->isNew();
}
}
......@@ -46,6 +46,6 @@ display:
display_title: Master
id: default
position: '0'
label: ''
label: 'Test view'
id: test_view
tag: ''
......@@ -143,10 +143,13 @@ class ViewUI implements ViewStorageInterface {
* @param \Drupal\views\ViewStorageInterface $storage
* The View storage object to wrap.
*/
public function __construct(ViewStorageInterface $storage) {
public function __construct(ViewStorageInterface $storage, ViewExecutable $executable = NULL) {
$this->entityType = 'view';
$this->storage = $storage;
$this->executable = Views::executableFactory()->get($this);
if (!isset($executable)) {
$executable = Views::executableFactory()->get($this);
}
$this->executable = $executable;
}
/**
......@@ -1038,7 +1041,7 @@ public function getNGEntity() {
* Implements \Drupal\Core\Entity\EntityInterface::isTranslatable().
*/
public function isTranslatable() {
return $this->isTranslatable();
return $this->storage->isTranslatable();
}
/**
......
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