当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPUnit_Util_XML::cssSelect方法代码示例

本文整理汇总了PHP中PHPUnit_Util_XML::cssSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_XML::cssSelect方法的具体用法?PHP PHPUnit_Util_XML::cssSelect怎么用?PHP PHPUnit_Util_XML::cssSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPUnit_Util_XML的用法示例。


在下文中一共展示了PHPUnit_Util_XML::cssSelect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: assertTourTips

 /**
  * Assert function to determine if tips rendered to the page
  * have a corresponding page element.
  *
  * @param array $tips
  *   A list of tips which provide either a "data-id" or "data-class".
  *
  * @code
  * // Basic example.
  * $this->assertTourTips();
  *
  * // Advanced example. The following would be used for multipage or
  * // targeting a specific subset of tips.
  * $tips = array();
  * $tips[] = array('data-id' => 'foo');
  * $tips[] = array('data-id' => 'bar');
  * $tips[] = array('data-class' => 'baz');
  * $this->assertTourTips($tips);
  * @endcode
  */
 public function assertTourTips($tips = array())
 {
     // Get the rendered tips and their data-id and data-class attributes.
     if (empty($tips)) {
         // Tips are rendered as <li> elements inside <ol id="tour">.
         $rendered_tips = $this->xpath('//ol[@id = "tour"]//li[starts-with(@class, "tip")]');
         foreach ($rendered_tips as $rendered_tip) {
             $attributes = (array) $rendered_tip->attributes();
             $tips[] = $attributes['@attributes'];
         }
     }
     // If the tips are still empty we need to fail.
     if (empty($tips)) {
         $this->fail('Could not find tour tips on the current page.');
     } else {
         // Check for corresponding page elements.
         $total = 0;
         $modals = 0;
         foreach ($tips as $tip) {
             if (!empty($tip['data-id'])) {
                 $elements = \PHPUnit_Util_XML::cssSelect('#' . $tip['data-id'], TRUE, $this->content, TRUE);
                 $this->assertTrue(!empty($elements) && count($elements) === 1, format_string('Found corresponding page element for tour tip with id #%data-id', array('%data-id' => $tip['data-id'])));
             } elseif (!empty($tip['data-class'])) {
                 $elements = \PHPUnit_Util_XML::cssSelect('.' . $tip['data-class'], TRUE, $this->content, TRUE);
                 $this->assertFalse(empty($elements), format_string('Found corresponding page element for tour tip with class .%data-class', array('%data-class' => $tip['data-class'])));
             } else {
                 // It's a modal.
                 $modals++;
             }
             $total++;
         }
         $this->pass(format_string('Total %total Tips tested of which %modals modal(s).', array('%total' => $total, '%modals' => $modals)));
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:54,代码来源:TourTestBase.php

示例2: assertSelectEquals

 /**
  * assertSelectEquals("#binder .name", "Chuck", true,  $xml);  // any?
  * assertSelectEquals("#binder .name", "Chuck", false, $xml);  // none?
  *
  * @param array          $selector
  * @param string         $content
  * @param int|bool|array $count
  * @param mixed          $actual
  * @param string         $message
  * @param bool           $isHtml
  * @since  Method available since Release 3.3.0
  * @author Mike Naberezny <mike@maintainable.com>
  * @author Derek DeVries <derek@maintainable.com>
  * @deprecated
  */
 public static function assertSelectEquals($selector, $content, $count, $actual, $message = '', $isHtml = true)
 {
     trigger_error(__METHOD__ . ' is deprecated', E_USER_DEPRECATED);
     $tags = PHPUnit_Util_XML::cssSelect($selector, $content, $actual, $isHtml);
     // assert specific number of elements
     if (is_numeric($count)) {
         $counted = $tags ? count($tags) : 0;
         self::assertEquals($count, $counted, $message);
     } elseif (is_bool($count)) {
         $any = count($tags) > 0 && $tags[0] instanceof DOMNode;
         if ($count) {
             self::assertTrue($any, $message);
         } else {
             self::assertFalse($any, $message);
         }
     } elseif (is_array($count) && (isset($count['>']) || isset($count['<']) || isset($count['>=']) || isset($count['<=']))) {
         $counted = $tags ? count($tags) : 0;
         if (isset($count['>'])) {
             self::assertTrue($counted > $count['>'], $message);
         }
         if (isset($count['>='])) {
             self::assertTrue($counted >= $count['>='], $message);
         }
         if (isset($count['<'])) {
             self::assertTrue($counted < $count['<'], $message);
         }
         if (isset($count['<='])) {
             self::assertTrue($counted <= $count['<='], $message);
         }
     } else {
         throw new PHPUnit_Framework_Exception();
     }
 }
开发者ID:karnurik,项目名称:zf2-turtorial,代码行数:48,代码来源:Assert.php

示例3: assertSelectEquals

 /**
  * assertSelectEquals("#binder .name", "Chuck", true,  $xml);  // any?
  * assertSelectEquals("#binder .name", "Chuck", false, $xml);  // none?
  *
  * @param  array   $selector
  * @param  string  $content
  * @param  integer $count
  * @param  mixed   $actual
  * @param  string  $message
  * @param  boolean $isHtml
  * @since  Method available since Release 3.3.0
  * @author Mike Naberezny <mike@maintainable.com>
  * @author Derek DeVries <derek@maintainable.com>
  */
 public static function assertSelectEquals($selector, $content, $count, $actual, $message = '', $isHtml = TRUE)
 {
     $tags = PHPUnit_Util_XML::cssSelect($selector, $content, $actual, $isHtml);
     // assert specific number of elements
     if (is_numeric($count)) {
         $counted = $tags ? count($tags) : 0;
         self::assertEquals($count, $counted);
     } else {
         if (is_bool($count)) {
             $any = count($tags) > 0 && $tags[0] instanceof DOMNode;
             if ($count) {
                 self::assertTrue($any, $message);
             } else {
                 self::assertFalse($any, $message);
             }
         } else {
             if (is_array($count) && (isset($count['>']) || isset($count['<']) || isset($count['>=']) || isset($count['<=']))) {
                 $counted = $tags ? count($tags) : 0;
                 if (isset($count['>'])) {
                     self::assertTrue($counted > $count['>'], $message);
                 }
                 if (isset($count['>='])) {
                     self::assertTrue($counted >= $count['>='], $message);
                 }
                 if (isset($count['<'])) {
                     self::assertTrue($counted < $count['<'], $message);
                 }
                 if (isset($count['<='])) {
                     self::assertTrue($counted <= $count['<='], $message);
                 }
             } else {
                 throw new InvalidArgumentException();
             }
         }
     }
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:50,代码来源:Assert.php


注:本文中的PHPUnit_Util_XML::cssSelect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。