Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ViewExecutable example
$this
->viewsData =
$this
->
getMockBuilder
(
'Drupal\views\ViewsData'
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$this
->displayHandler =
$this
->
getMockBuilder
(
'Drupal\views\Plugin\views\display\DisplayRouterInterface'
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$this
->routeProvider =
$this
->
createMock
(
'Drupal\Core\Routing\RouteProviderInterface'
)
;
$this
->displayHandlers =
$this
->
getMockBuilder
(
'Drupal\views\DisplayPluginCollection'
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$this
->executable =
new
ViewExecutable
(
$this
->view,
$this
->user,
$this
->viewsData,
$this
->routeProvider
)
;
$this
->executable->display_handler =
$this
->displayHandler;
$this
->executable->displayHandlers =
$this
->displayHandlers;
$this
->viewExecutableFactory =
$this
->
getMockBuilder
(
'Drupal\views\ViewExecutableFactory'
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$module_handler
=
$this
->
getMockBuilder
(
ModuleHandlerInterface::
class
)
->
getMock
(
)
;
$this
->noneCache =
$this
->
getMockBuilder
(
NoneCache::
class
)
'id' => 'default',
'display_plugin' => 'default',
'display_title' => 'Default',
]
;
$storage
=
new
View
(
$config
, 'view'
)
;
$user
=
$this
->
createMock
(
'Drupal\Core\Session\AccountInterface'
)
;
$views_data
=
$this
->
getMockBuilder
(
'Drupal\views\ViewsData'
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$route_provider
=
$this
->
createMock
(
'Drupal\Core\Routing\RouteProviderInterface'
)
;
$this
->view =
new
ViewExecutable
(
$storage
,
$user
,
$views_data
,
$route_provider
)
;
$this
->display =
$this
->
getMockBuilder
(
'Drupal\views\Plugin\views\display\DisplayPluginBase'
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$this
->pager =
$this
->
getMockBuilder
(
'Drupal\views\Plugin\views\pager\Full'
)
->
disableOriginalConstructor
(
)
->
onlyMethods
(
[
]
)
->
getMock
(
)
;
$this
->view->display_handler =
$this
->display;
protected
function
setUp
(
)
: void
{
parent::
setUp
(
)
;
$storage
=
$this
->
prophesize
(
View::
class
)
;
$storage
->
label
(
)
->
willReturn
(
'ResultTest'
)
;
$storage
->
set
(
Argument::
cetera
(
)
)
->
willReturn
(
NULL
)
;
$user
=
$this
->
prophesize
(
AccountInterface::
class
)
->
reveal
(
)
;
$views_data
=
$this
->
prophesize
(
ViewsData::
class
)
->
reveal
(
)
;
$route_provider
=
$this
->
prophesize
(
RouteProviderInterface::
class
)
->
reveal
(
)
;
$this
->view =
new
ViewExecutable
(
$storage
->
reveal
(
)
,
$user
,
$views_data
,
$route_provider
)
;
$this
->resultHandler =
new
Result
(
[
]
, 'result',
[
]
)
;
$this
->resultHandler->view =
$this
->view;
}
/** * Tests the query method. */
public
function
testQuery
(
)
{
$this
->
assertNull
(
$this
->view->get_total_rows
)
;
// @total should set get_total_rows.
/** * Instantiates a ViewExecutable class. * * @param \Drupal\views\ViewEntityInterface $view * A view entity instance. * * @return \Drupal\views\ViewExecutable * A ViewExecutable instance. */
public
function
get
(
ViewEntityInterface
$view
)
{
$view_executable
=
new
ViewExecutable
(
$view
,
$this
->user,
$this
->viewsData,
$this
->routeProvider
)
;
$view_executable
->
setRequest
(
$this
->requestStack->
getCurrentRequest
(
)
)
;
return
$view_executable
;
}
}