Tests the ViewUI class.
Expanded class hierarchy of ViewUIObjectTest
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::LANGCODE_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();
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
public static | function | Generates a random string containing letters and numbers. | |
ViewUIObjectTest:: |
public static | function |
This method exists to support the simpletest UI runner. Overrides UnitTestCase:: |
|
ViewUIObjectTest:: |
public | function | Tests entity method decoration. |