Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
testMethod example
/** * Returns the result of an autoloaded class's public method. * * @return array * Renderable array. */
public
function
testClassLoading
(
)
{
$markup
= NULL;
if
(
class_exists
(
'Drupal\module_autoload_test\SomeClass'
)
)
{
$obj
=
new
SomeClass
(
)
;
$markup
=
$obj
->
testMethod
(
)
;
}
return
[
'#markup' =>
$markup
]
;
}
}
$method
=
(
new
\
ReflectionClass
(
$this
)
)
->
getMethod
(
'testMethod'
)
;
$annotations
=
(
new
AnnotationReader
(
)
)
->
getMethodAnnotations
(
$method
)
;
static
::
assertCount
(
3,
$annotations
)
;
static
::
assertInstanceOf
(
Entity::
class
,
$annotations
[
0
]
)
;
static
::
assertInstanceOf
(
NoStore::
class
,
$annotations
[
1
]
)
;
static
::
assertInstanceOf
(
HttpCache::
class
,
$annotations
[
2
]
)
;
// make PHPStan happy that the private method is used
$this
->
testMethod
(
)
;
}
/** * @Entity("product") * * @NoStore() * * @HttpCache(maxAge=360, states={"logged-in", "cart-filled"}) */
private
function
testMethod
(
)
: void
{