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


PHP PHPUnit_Util_Type::isType方法代码示例

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


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

示例1: assertNotType

 /**
  * Asserts that a variable is not of a given type.
  *
  * @param  string $expected
  * @param  mixed  $actual
  * @param  string $message
  * @access public
  * @static
  * @since  Method available since Release 2.2.0
  */
 public static function assertNotType($expected, $actual, $message = '')
 {
     if (is_string($expected)) {
         if (PHPUnit_Util_Type::isType($expected)) {
             $constraint = new PHPUnit_Framework_Constraint_Not(new PHPUnit_Framework_Constraint_IsType($expected));
         } else {
             if (class_exists($expected) || interface_exists($expected)) {
                 $constraint = new PHPUnit_Framework_Constraint_Not(new PHPUnit_Framework_Constraint_IsInstanceOf($expected));
             } else {
                 throw new InvalidArgumentException();
             }
         }
     } else {
         throw new InvalidArgumentException();
     }
     self::assertThat($actual, $constraint, $message);
 }
开发者ID:ahmedadham88,项目名称:enhanced-social-network,代码行数:27,代码来源:Assert.php

示例2: assertType

 /**
  * Backported from PHPUnit 3.4 in order to maintain backwards
  * compatibility: assertType() is deprecated in PHPUnit 3.5 (with PHP 5.2.7+),
  * but as SilverStripe 2.3 and 2.4 support PHP 5.1 we can't require it.
  */
 public static function assertType($expected, $actual, $message = '')
 {
     // PHPUnit_Util_DeprecatedFeature_Logger::log(
     //   'assertType() will be removed in PHPUnit 3.6 and should no longer ' .
     //   'be used. assertInternalType() should be used for asserting ' .
     //   'internal types such as "integer" or "string" whereas ' .
     //   'assertInstanceOf() should be used for asserting that an object is ' .
     //   'an instance of a specified class or interface.'
     // );
     if (is_string($expected)) {
         if (PHPUnit_Util_Type::isType($expected)) {
             $constraint = new PHPUnit_Framework_Constraint_IsType($expected);
         } else {
             if (class_exists($expected) || interface_exists($expected)) {
                 $constraint = new PHPUnit_Framework_Constraint_IsInstanceOf($expected);
             } else {
                 throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class or interface name');
             }
         }
     } else {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
     }
     self::assertThat($actual, $constraint, $message);
 }
开发者ID:hamishcampbell,项目名称:silverstripe-sapphire,代码行数:29,代码来源:SapphireTest.php

示例3: assertNotContainsOnly

 /**
  * Asserts that a haystack does not contain only values of a given type.
  *
  * @param string $type
  * @param mixed  $haystack
  * @param bool   $isNativeType
  * @param string $message
  * @since  Method available since Release 3.1.4
  */
 public static function assertNotContainsOnly($type, $haystack, $isNativeType = null, $message = '')
 {
     if (!(is_array($haystack) || is_object($haystack) && $haystack instanceof Traversable)) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'array or traversable');
     }
     if ($isNativeType == null) {
         $isNativeType = PHPUnit_Util_Type::isType($type);
     }
     self::assertThat($haystack, new PHPUnit_Framework_Constraint_Not(new PHPUnit_Framework_Constraint_TraversableContainsOnly($type, $isNativeType)), $message);
 }
开发者ID:karnurik,项目名称:zf2-turtorial,代码行数:19,代码来源:Assert.php

示例4: assertNotType

 /**
  * Asserts that a variable is not of a given type.
  *
  * @param  string $expected
  * @param  mixed  $actual
  * @param  string $message
  * @since  Method available since Release 2.2.0
  */
 public static function assertNotType($expected, $actual, $message = '')
 {
     if (is_string($expected)) {
         if (PHPUnit_Util_Type::isType($expected)) {
             if (class_exists($expected) || interface_exists($expected)) {
                 throw new InvalidArgumentException(sprintf('"%s" is ambigious', $expected));
             }
             $constraint = new PHPUnit_Framework_Constraint_Not(new PHPUnit_Framework_Constraint_IsType($expected));
         } else {
             if (class_exists($expected) || interface_exists($expected)) {
                 $constraint = new PHPUnit_Framework_Constraint_Not(new PHPUnit_Framework_Constraint_IsInstanceOf($expected));
             } else {
                 throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class or interface name');
             }
         }
     } else {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
     }
     self::assertThat($actual, $constraint, $message);
 }
开发者ID:redlion09,项目名称:pcppi,代码行数:28,代码来源:Assert.php


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