Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setupViewsData example
$this
->fieldTypePluginManager->
expects
(
$this
->
any
(
)
)
->
method
(
'getDefaultStorageSettings'
)
->
willReturn
(
[
]
)
;
$this
->fieldTypePluginManager->
expects
(
$this
->
any
(
)
)
->
method
(
'getDefaultFieldSettings'
)
->
willReturn
(
[
]
)
;
$this
->languageManager =
$this
->
createMock
(
'Drupal\Core\Language\LanguageManagerInterface'
)
;
$this
->renderer =
$this
->
createMock
(
'Drupal\Core\Render\RendererInterface'
)
;
$this
->
setupExecutableAndView
(
)
;
$this
->
setupViewsData
(
)
;
$this
->display =
$this
->
getMockBuilder
(
'Drupal\views\Plugin\views\display\DisplayPluginBase'
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$this
->container =
new
ContainerBuilder
(
)
;
$this
->container->
set
(
'plugin.manager.field.field_type',
$this
->fieldTypePluginManager
)
;
\Drupal::
setContainer
(
$this
->container
)
;
}
/** * @covers ::__construct */
class
HandlerBaseTest
extends
UnitTestCase
{
use
HandlerTestTrait;
/** * {@inheritdoc} */
protected
function
setUp
(
)
: void
{
parent::
setUp
(
)
;
$this
->
setupViewsData
(
)
;
$this
->
setupExecutableAndView
(
)
;
$this
->
setupDisplay
(
)
;
}
/** * @covers ::getEntityType */
public
function
testGetEntityTypeForFieldOnBaseTable
(
)
{
$handler
=
new
TestHandler
(
[
]
, 'test_handler',
[
]
)
;
$handler
->
init
(
$this
->executable,
$this
->display
)
;
'table' =>
[
'entity type' => 'second',
'entity revision' => TRUE,
]
,
]
)
;
$views_data
->
get
(
'entity_first_field_data'
)
->
willReturn
(
[
'table' =>
[
'entity type' => 'first',
'entity revision' => FALSE,
]
,
]
)
;
$this
->
setupViewsData
(
$views_data
->
reveal
(
)
)
;
// Setup the loading of entities and entity revisions.
$entity_storages
=
[
'first' =>
$this
->
prophesize
(
EntityStorageInterface::
class
)
,
'second' =>
$this
->
prophesize
(
EntityStorageInterface::
class
)
,
]
;
foreach
(
$entities_by_type
as
$entity_type_id
=>
$entities
)
{
foreach
(
$entities
as
$entity_id
=>
$entity
)
{
$entity_storages
[
$entity_type_id
]
->
load
(
$entity_id
)
->
willReturn
(
$entity
)
;
}