Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
addNodeList example
public
function
add
(
\DOMNodeList|\DOMNode|array|string|null
$node
)
{
if
(
$node
instanceof \DOMNodeList
)
{
$this
->
addNodeList
(
$node
)
;
}
elseif
(
$node
instanceof \DOMNode
)
{
$this
->
addNode
(
$node
)
;
}
elseif
(
\
is_array
(
$node
)
)
{
$this
->
addNodes
(
$node
)
;
}
elseif
(
\
is_string
(
$node
)
)
{
$this
->
addContent
(
$node
)
;
}
elseif
(
null !==
$node
)
{
throw
new
\
InvalidArgumentException
(
sprintf
(
'Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".',
get_debug_type
(
$node
)
)
)
;
}
}
public
function
testAddDocument
(
)
{
$crawler
=
$this
->
createCrawler
(
)
;
$crawler
->
addDocument
(
$this
->
createDomDocument
(
)
)
;
$this
->
assertEquals
(
'foo',
$crawler
->
filterXPath
(
'//div'
)
->
attr
(
'class'
)
, '->addDocument() adds nodes from a \DOMDocument'
)
;
}
public
function
testAddNodeList
(
)
{
$crawler
=
$this
->
createCrawler
(
)
;
$crawler
->
addNodeList
(
$this
->
createNodeList
(
)
)
;
$this
->
assertEquals
(
'foo',
$crawler
->
filterXPath
(
'//div'
)
->
attr
(
'class'
)
, '->addNodeList() adds nodes from a \DOMNodeList'
)
;
}
public
function
testAddNodes
(
)
{
$list
=
[
]
;
foreach
(
$this
->
createNodeList
(
)
as
$node
)
{
$list
[
]
=
$node
;
}