Issue #2061925 by alweb, Albert Volkman, dawehner: Remove calls to deprecated global in views_ui module.
parent
384aae19c0
commit
ed06280e8b
|
@ -807,7 +807,7 @@ class ViewUI implements ViewStorageInterface {
|
||||||
* TRUE if the view is locked, FALSE otherwise.
|
* TRUE if the view is locked, FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
public function isLocked() {
|
public function isLocked() {
|
||||||
return is_object($this->lock) && ($this->lock->owner != $GLOBALS['user']->id());
|
return is_object($this->lock) && ($this->lock->owner != \Drupal::currentUser()->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,7 @@ use Drupal\Tests\UnitTestCase;
|
||||||
use Drupal\views\ViewExecutable;
|
use Drupal\views\ViewExecutable;
|
||||||
use Drupal\views_ui\ViewUI;
|
use Drupal\views_ui\ViewUI;
|
||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the ViewUI class.
|
* Tests the ViewUI class.
|
||||||
|
@ -75,4 +76,46 @@ class ViewUIObjectTest extends UnitTestCase {
|
||||||
$view_ui->isNew();
|
$view_ui->isNew();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the isLocked method.
|
||||||
|
*/
|
||||||
|
public function testIsLocked() {
|
||||||
|
$storage = $this->getMock('Drupal\views\Entity\View', array(), array(array(), 'view'));
|
||||||
|
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->setConstructorArgs(array($storage))
|
||||||
|
->getMock();
|
||||||
|
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
|
||||||
|
$account->expects($this->exactly(2))
|
||||||
|
->method('id')
|
||||||
|
->will($this->returnValue(1));
|
||||||
|
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->set('current_user', $account);
|
||||||
|
\Drupal::setContainer($container);
|
||||||
|
|
||||||
|
$view_ui = new ViewUI($storage, $executable);
|
||||||
|
|
||||||
|
// A view_ui without a lock object is not locked.
|
||||||
|
$this->assertFalse($view_ui->isLocked());
|
||||||
|
|
||||||
|
// Set the lock object with a different owner than the mocked account above.
|
||||||
|
$lock = (object) array(
|
||||||
|
'owner' => 2,
|
||||||
|
'data' => array(),
|
||||||
|
'updated' => REQUEST_TIME,
|
||||||
|
);
|
||||||
|
$view_ui->lock = $lock;
|
||||||
|
$this->assertTrue($view_ui->isLocked());
|
||||||
|
|
||||||
|
// Set a different lock object with the same object as the mocked account.
|
||||||
|
$lock = (object) array(
|
||||||
|
'owner' => 1,
|
||||||
|
'data' => array(),
|
||||||
|
'updated' => REQUEST_TIME,
|
||||||
|
);
|
||||||
|
$view_ui->lock = $lock;
|
||||||
|
$this->assertFalse($view_ui->isLocked());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue