本文整理汇总了PHP中Behat\Mink\Element\NodeElement::getParent方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeElement::getParent方法的具体用法?PHP NodeElement::getParent怎么用?PHP NodeElement::getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Behat\Mink\Element\NodeElement
的用法示例。
在下文中一共展示了NodeElement::getParent方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reverseControls
private static function reverseControls(NodeElement $content, dTable $dt)
{
$wrap = $content->getParent();
self::reverseHeader($wrap, $dt);
self::reverseFooter($wrap, $dt);
}
示例2: findParentByClass
/**
* Returns the closest parent element having a specific class attribute.
*
* @param NodeElement $el
* @param String $class
* @return Element|null
*/
protected function findParentByClass(NodeElement $el, $class)
{
$container = $el->getParent();
while ($container && $container->getTagName() != 'body') {
if ($container->isVisible() && in_array($class, explode(' ', $container->getAttribute('class')))) {
return $container;
}
$container = $container->getParent();
}
return null;
}
示例3: isReplyOfComment
/**
* @param NodeElement $reply
* @param NodeElement $comment
*
* @return bool
*/
public function isReplyOfComment(NodeElement $reply, NodeElement $comment)
{
return $reply->getParent()->getText() === $comment->getParent()->getText();
}
示例4: fillSelectField
/**
* Fills a select element with $value, identified by its $label.
*
* @param NodeElement $label
* @param string $value
*/
protected function fillSelectField(NodeElement $label, $value)
{
$field = $label->getParent()->find('css', 'select');
$field->selectOption($value);
}
示例5: get_field_node_type
/**
* Recursive method to find the field type.
*
* Depending on the field the felement class node is in a level or in another. We
* look recursively for a parent node with a 'felement' class to find the field type.
*
* @param NodeElement $fieldnode The current node.
* @param Session $session The behat browser session
* @return mixed A NodeElement if we continue looking for the element type and String or false when we are done.
*/
protected static function get_field_node_type(NodeElement $fieldnode, Session $session)
{
// Special handling for availability field which requires custom JavaScript.
if ($fieldnode->getAttribute('name') === 'availabilityconditionsjson') {
return 'availability';
}
if ($fieldnode->getTagName() == 'html') {
return false;
}
// If the type is explictly set on the element pointed to by the label - use it.
if ($type = $fieldnode->getParent()->getAttribute('data-fieldtype')) {
if ($type == 'tags') {
return 'autocomplete';
}
return $type;
}
// We look for a parent node with 'felement' class.
if ($class = $fieldnode->getParent()->getAttribute('class')) {
if (strstr($class, 'felement') != false) {
// Remove 'felement f' from class value.
return substr($class, 10);
}
// Stop propagation through the DOM, if it does not have a felement is not part of a moodle form.
if (strstr($class, 'fcontainer') != false) {
return false;
}
}
return self::get_field_node_type($fieldnode->getParent(), $session);
}
示例6: get_field_node_type
/**
* Recursive method to find the field type.
*
* Depending on the field the felement class node is in a level or in another. We
* look recursively for a parent node with a 'felement' class to find the field type.
*
* @param NodeElement $fieldnode The current node.
* @param Session $session The behat browser session
* @return mixed A NodeElement if we continue looking for the element type and String or false when we are done.
*/
protected static function get_field_node_type(NodeElement $fieldnode, Session $session)
{
// We look for a parent node with 'felement' class.
if ($class = $fieldnode->getParent()->getAttribute('class')) {
if (strstr($class, 'felement') != false) {
// Remove 'felement f' from class value.
return substr($class, 10);
}
// Stop propagation through the DOM, if it does not have a felement is not part of a moodle form.
if (strstr($class, 'fcontainer') != false) {
return false;
}
}
return self::get_field_node_type($fieldnode->getParent(), $session);
}
示例7: testGetParent
public function testGetParent()
{
$node = new NodeElement('elem', $this->session);
$parent = $this->getMockBuilder('Behat\\Mink\\Element\\NodeElement')->disableOriginalConstructor()->getMock();
$this->driver->expects($this->once())->method('find')->with('elem/..')->will($this->returnValue(array($parent)));
$this->selectors->expects($this->once())->method('selectorToXpath')->with('xpath', '..')->will($this->returnValue('..'));
$this->assertSame($parent, $node->getParent());
}
示例8: toggleResource
/**
* @param NodeElement $resource
*/
public function toggleResource(NodeElement $resource)
{
$groupTitleElement = $this->spin(function () use($resource) {
return $resource->getParent()->getParent()->getParent()->find('css', 'h3');
}, 'Group title not found for resource.');
$groupTitle = $groupTitleElement->getHtml();
$this->navigateToGroup($groupTitle);
$this->spin(function () use($resource) {
return $resource->isVisible();
}, sprintf('Resource is not visible on the group %s.', $groupTitle));
$resource->click();
}
示例9: get_node_type
/**
* Recursive method to find the field type.
*
* Depending on the field the felement class node is a level or in another. We
* look recursively for a parent node with a 'felement' class to find the field type.
*
* @throws ExpectationException
* @param NodeElement $fieldnode The current node
* @param string $locator Just to send an exception that makes sense for the user
* @return mixed String or NodeElement depending if we have reached the felement node
*/
protected function get_node_type(NodeElement $fieldnode, $locator) {
// We look for a parent node with 'felement' class.
if ($class = $fieldnode->getParent()->getAttribute('class')) {
if (strstr($class, 'felement') != false) {
// Remove 'felement f' from class value.
return substr($class, 10);
}
// Stop propagation through the DOM, something went wrong!.
if (strstr($class, 'fcontainer') != false) {
throw new ExpectationException('No field type for ' . $locator . ' found, ensure the field exists', $this->getSession());
}
}
return $this->get_node_type($fieldnode->getParent(), $locator);
}
示例10: fillTextField
/**
* Fills a text field element with $value, identified by its container or label.
*
* @param NodeElement $fieldContainerOrLabel
* @param string $value
*/
protected function fillTextField(NodeElement $fieldContainerOrLabel, $value)
{
$field = $fieldContainerOrLabel->find('css', 'div.field-input input');
// no field found, we're using a label
if (!$field) {
$field = $fieldContainerOrLabel->getParent()->getParent()->find('css', 'div.field-input input');
}
if (!$field) {
$field = $fieldContainerOrLabel->getParent()->find('css', 'div.controls input');
}
$field->setValue($value);
$this->getSession()->executeScript('$(\'.field-input input[type="text"]\').trigger(\'change\');');
}
示例11: fillTextField
/**
* Fills a text field element with $value, identified by its container or label.
*
* @param NodeElement $fieldContainerOrLabel
* @param string $value
*
* @throws ElementNotFoundException
*/
protected function fillTextField(NodeElement $fieldContainerOrLabel, $value)
{
$field = $fieldContainerOrLabel->find('css', 'div.field-input input');
// no field found, we're using a label
if (!$field) {
$field = $fieldContainerOrLabel->getParent()->getParent()->find('css', 'div.field-input input');
}
if (!$field) {
$field = $fieldContainerOrLabel->getParent()->find('css', 'div.controls input');
}
if (null === $field) {
throw new ElementNotFoundException(sprintf('No text field can be found from "%s".', $fieldContainerOrLabel->getText()));
}
$field->setValue($value);
$this->getSession()->executeScript('$(\'.field-input input[type="text"]\').trigger(\'change\');');
}
示例12: get_field_node_type
/**
* Recursive method to find the field type.
*
* Depending on the field the felement class node is in a level or in another. We
* look recursively for a parent node with a 'felement' class to find the field type.
*
* @param NodeElement $fieldnode The current node.
* @param Session $session The behat browser session
* @return mixed A NodeElement if we continue looking for the element type and String or false when we are done.
*/
protected static function get_field_node_type(NodeElement $fieldnode, Session $session)
{
// Special handling for availability field which requires custom JavaScript.
if ($fieldnode->getAttribute('name') === 'availabilityconditionsjson') {
return 'availability';
}
// We look for a parent node with 'felement' class.
if ($class = $fieldnode->getParent()->getAttribute('class')) {
if (strstr($class, 'felement') != false) {
// Remove 'felement f' from class value.
return substr($class, 10);
}
// Stop propagation through the DOM, if it does not have a felement is not part of a moodle form.
if (strstr($class, 'fcontainer') != false) {
return false;
}
}
return self::get_field_node_type($fieldnode->getParent(), $session);
}