PageRenderTime 64ms CodeModel.GetById 17ms app.highlight 38ms RepoModel.GetById 1ms app.codeStats 1ms

/vendor/phpunit/phpunit/src/Framework/Assert.php

https://bitbucket.org/alan_cordova/api-sb-map
PHP | 2952 lines | 1456 code | 331 blank | 1165 comment | 123 complexity | 8c10a314e739edce99ac0c220abd49d2 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1<?php
   2/*
   3 * This file is part of PHPUnit.
   4 *
   5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
   6 *
   7 * For the full copyright and license information, please view the LICENSE
   8 * file that was distributed with this source code.
   9 */
  10
  11/**
  12 * A set of assertion methods.
  13 */
  14abstract class PHPUnit_Framework_Assert
  15{
  16    /**
  17     * @var int
  18     */
  19    private static $count = 0;
  20
  21    /**
  22     * Asserts that an array has a specified key.
  23     *
  24     * @param mixed             $key
  25     * @param array|ArrayAccess $array
  26     * @param string            $message
  27     */
  28    public static function assertArrayHasKey($key, $array, $message = '')
  29    {
  30        if (!(is_int($key) || is_string($key))) {
  31            throw PHPUnit_Util_InvalidArgumentHelper::factory(
  32                1,
  33                'integer or string'
  34            );
  35        }
  36
  37        if (!(is_array($array) || $array instanceof ArrayAccess)) {
  38            throw PHPUnit_Util_InvalidArgumentHelper::factory(
  39                2,
  40                'array or ArrayAccess'
  41            );
  42        }
  43
  44        $constraint = new PHPUnit_Framework_Constraint_ArrayHasKey($key);
  45
  46        static::assertThat($array, $constraint, $message);
  47    }
  48
  49    /**
  50     * Asserts that an array has a specified subset.
  51     *
  52     * @param array|ArrayAccess $subset
  53     * @param array|ArrayAccess $array
  54     * @param bool              $strict  Check for object identity
  55     * @param string            $message
  56     */
  57    public static function assertArraySubset($subset, $array, $strict = false, $message = '')
  58    {
  59        if (!(is_array($subset) || $subset instanceof ArrayAccess)) {
  60            throw PHPUnit_Util_InvalidArgumentHelper::factory(
  61                1,
  62                'array or ArrayAccess'
  63            );
  64        }
  65
  66        if (!(is_array($array) || $array instanceof ArrayAccess)) {
  67            throw PHPUnit_Util_InvalidArgumentHelper::factory(
  68                2,
  69                'array or ArrayAccess'
  70            );
  71        }
  72
  73        $constraint = new PHPUnit_Framework_Constraint_ArraySubset($subset, $strict);
  74
  75        static::assertThat($array, $constraint, $message);
  76    }
  77
  78    /**
  79     * Asserts that an array does not have a specified key.
  80     *
  81     * @param mixed             $key
  82     * @param array|ArrayAccess $array
  83     * @param string            $message
  84     */
  85    public static function assertArrayNotHasKey($key, $array, $message = '')
  86    {
  87        if (!(is_int($key) || is_string($key))) {
  88            throw PHPUnit_Util_InvalidArgumentHelper::factory(
  89                1,
  90                'integer or string'
  91            );
  92        }
  93
  94        if (!(is_array($array) || $array instanceof ArrayAccess)) {
  95            throw PHPUnit_Util_InvalidArgumentHelper::factory(
  96                2,
  97                'array or ArrayAccess'
  98            );
  99        }
 100
 101        $constraint = new PHPUnit_Framework_Constraint_Not(
 102            new PHPUnit_Framework_Constraint_ArrayHasKey($key)
 103        );
 104
 105        static::assertThat($array, $constraint, $message);
 106    }
 107
 108    /**
 109     * Asserts that a haystack contains a needle.
 110     *
 111     * @param mixed  $needle
 112     * @param mixed  $haystack
 113     * @param string $message
 114     * @param bool   $ignoreCase
 115     * @param bool   $checkForObjectIdentity
 116     * @param bool   $checkForNonObjectIdentity
 117     */
 118    public static function assertContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
 119    {
 120        if (is_array($haystack) ||
 121            is_object($haystack) && $haystack instanceof Traversable) {
 122            $constraint = new PHPUnit_Framework_Constraint_TraversableContains(
 123                $needle,
 124                $checkForObjectIdentity,
 125                $checkForNonObjectIdentity
 126            );
 127        } elseif (is_string($haystack)) {
 128            if (!is_string($needle)) {
 129                throw PHPUnit_Util_InvalidArgumentHelper::factory(
 130                    1,
 131                    'string'
 132                );
 133            }
 134
 135            $constraint = new PHPUnit_Framework_Constraint_StringContains(
 136                $needle,
 137                $ignoreCase
 138            );
 139        } else {
 140            throw PHPUnit_Util_InvalidArgumentHelper::factory(
 141                2,
 142                'array, traversable or string'
 143            );
 144        }
 145
 146        static::assertThat($haystack, $constraint, $message);
 147    }
 148
 149    /**
 150     * Asserts that a haystack that is stored in a static attribute of a class
 151     * or an attribute of an object contains a needle.
 152     *
 153     * @param mixed         $needle
 154     * @param string        $haystackAttributeName
 155     * @param string|object $haystackClassOrObject
 156     * @param string        $message
 157     * @param bool          $ignoreCase
 158     * @param bool          $checkForObjectIdentity
 159     * @param bool          $checkForNonObjectIdentity
 160     */
 161    public static function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
 162    {
 163        static::assertContains(
 164            $needle,
 165            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
 166            $message,
 167            $ignoreCase,
 168            $checkForObjectIdentity,
 169            $checkForNonObjectIdentity
 170        );
 171    }
 172
 173    /**
 174     * Asserts that a haystack does not contain a needle.
 175     *
 176     * @param mixed  $needle
 177     * @param mixed  $haystack
 178     * @param string $message
 179     * @param bool   $ignoreCase
 180     * @param bool   $checkForObjectIdentity
 181     * @param bool   $checkForNonObjectIdentity
 182     */
 183    public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
 184    {
 185        if (is_array($haystack) ||
 186            is_object($haystack) && $haystack instanceof Traversable) {
 187            $constraint = new PHPUnit_Framework_Constraint_Not(
 188                new PHPUnit_Framework_Constraint_TraversableContains(
 189                    $needle,
 190                    $checkForObjectIdentity,
 191                    $checkForNonObjectIdentity
 192                )
 193            );
 194        } elseif (is_string($haystack)) {
 195            if (!is_string($needle)) {
 196                throw PHPUnit_Util_InvalidArgumentHelper::factory(
 197                    1,
 198                    'string'
 199                );
 200            }
 201
 202            $constraint = new PHPUnit_Framework_Constraint_Not(
 203                new PHPUnit_Framework_Constraint_StringContains(
 204                    $needle,
 205                    $ignoreCase
 206                )
 207            );
 208        } else {
 209            throw PHPUnit_Util_InvalidArgumentHelper::factory(
 210                2,
 211                'array, traversable or string'
 212            );
 213        }
 214
 215        static::assertThat($haystack, $constraint, $message);
 216    }
 217
 218    /**
 219     * Asserts that a haystack that is stored in a static attribute of a class
 220     * or an attribute of an object does not contain a needle.
 221     *
 222     * @param mixed         $needle
 223     * @param string        $haystackAttributeName
 224     * @param string|object $haystackClassOrObject
 225     * @param string        $message
 226     * @param bool          $ignoreCase
 227     * @param bool          $checkForObjectIdentity
 228     * @param bool          $checkForNonObjectIdentity
 229     */
 230    public static function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
 231    {
 232        static::assertNotContains(
 233            $needle,
 234            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
 235            $message,
 236            $ignoreCase,
 237            $checkForObjectIdentity,
 238            $checkForNonObjectIdentity
 239        );
 240    }
 241
 242    /**
 243     * Asserts that a haystack contains only values of a given type.
 244     *
 245     * @param string $type
 246     * @param mixed  $haystack
 247     * @param bool   $isNativeType
 248     * @param string $message
 249     */
 250    public static function assertContainsOnly($type, $haystack, $isNativeType = null, $message = '')
 251    {
 252        if (!(is_array($haystack) ||
 253            is_object($haystack) && $haystack instanceof Traversable)) {
 254            throw PHPUnit_Util_InvalidArgumentHelper::factory(
 255                2,
 256                'array or traversable'
 257            );
 258        }
 259
 260        if ($isNativeType == null) {
 261            $isNativeType = PHPUnit_Util_Type::isType($type);
 262        }
 263
 264        static::assertThat(
 265            $haystack,
 266            new PHPUnit_Framework_Constraint_TraversableContainsOnly(
 267                $type,
 268                $isNativeType
 269            ),
 270            $message
 271        );
 272    }
 273
 274    /**
 275     * Asserts that a haystack contains only instances of a given classname
 276     *
 277     * @param string            $classname
 278     * @param array|Traversable $haystack
 279     * @param string            $message
 280     */
 281    public static function assertContainsOnlyInstancesOf($classname, $haystack, $message = '')
 282    {
 283        if (!(is_array($haystack) ||
 284            is_object($haystack) && $haystack instanceof Traversable)) {
 285            throw PHPUnit_Util_InvalidArgumentHelper::factory(
 286                2,
 287                'array or traversable'
 288            );
 289        }
 290
 291        static::assertThat(
 292            $haystack,
 293            new PHPUnit_Framework_Constraint_TraversableContainsOnly(
 294                $classname,
 295                false
 296            ),
 297            $message
 298        );
 299    }
 300
 301    /**
 302     * Asserts that a haystack that is stored in a static attribute of a class
 303     * or an attribute of an object contains only values of a given type.
 304     *
 305     * @param string        $type
 306     * @param string        $haystackAttributeName
 307     * @param string|object $haystackClassOrObject
 308     * @param bool          $isNativeType
 309     * @param string        $message
 310     */
 311    public static function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '')
 312    {
 313        static::assertContainsOnly(
 314            $type,
 315            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
 316            $isNativeType,
 317            $message
 318        );
 319    }
 320
 321    /**
 322     * Asserts that a haystack does not contain only values of a given type.
 323     *
 324     * @param string $type
 325     * @param mixed  $haystack
 326     * @param bool   $isNativeType
 327     * @param string $message
 328     */
 329    public static function assertNotContainsOnly($type, $haystack, $isNativeType = null, $message = '')
 330    {
 331        if (!(is_array($haystack) ||
 332            is_object($haystack) && $haystack instanceof Traversable)) {
 333            throw PHPUnit_Util_InvalidArgumentHelper::factory(
 334                2,
 335                'array or traversable'
 336            );
 337        }
 338
 339        if ($isNativeType == null) {
 340            $isNativeType = PHPUnit_Util_Type::isType($type);
 341        }
 342
 343        static::assertThat(
 344            $haystack,
 345            new PHPUnit_Framework_Constraint_Not(
 346                new PHPUnit_Framework_Constraint_TraversableContainsOnly(
 347                    $type,
 348                    $isNativeType
 349                )
 350            ),
 351            $message
 352        );
 353    }
 354
 355    /**
 356     * Asserts that a haystack that is stored in a static attribute of a class
 357     * or an attribute of an object does not contain only values of a given
 358     * type.
 359     *
 360     * @param string        $type
 361     * @param string        $haystackAttributeName
 362     * @param string|object $haystackClassOrObject
 363     * @param bool          $isNativeType
 364     * @param string        $message
 365     */
 366    public static function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '')
 367    {
 368        static::assertNotContainsOnly(
 369            $type,
 370            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
 371            $isNativeType,
 372            $message
 373        );
 374    }
 375
 376    /**
 377     * Asserts the number of elements of an array, Countable or Traversable.
 378     *
 379     * @param int    $expectedCount
 380     * @param mixed  $haystack
 381     * @param string $message
 382     */
 383    public static function assertCount($expectedCount, $haystack, $message = '')
 384    {
 385        if (!is_int($expectedCount)) {
 386            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer');
 387        }
 388
 389        if (!$haystack instanceof Countable &&
 390            !$haystack instanceof Traversable &&
 391            !is_array($haystack)) {
 392            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'countable or traversable');
 393        }
 394
 395        static::assertThat(
 396            $haystack,
 397            new PHPUnit_Framework_Constraint_Count($expectedCount),
 398            $message
 399        );
 400    }
 401
 402    /**
 403     * Asserts the number of elements of an array, Countable or Traversable
 404     * that is stored in an attribute.
 405     *
 406     * @param int           $expectedCount
 407     * @param string        $haystackAttributeName
 408     * @param string|object $haystackClassOrObject
 409     * @param string        $message
 410     */
 411    public static function assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '')
 412    {
 413        static::assertCount(
 414            $expectedCount,
 415            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
 416            $message
 417        );
 418    }
 419
 420    /**
 421     * Asserts the number of elements of an array, Countable or Traversable.
 422     *
 423     * @param int    $expectedCount
 424     * @param mixed  $haystack
 425     * @param string $message
 426     */
 427    public static function assertNotCount($expectedCount, $haystack, $message = '')
 428    {
 429        if (!is_int($expectedCount)) {
 430            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer');
 431        }
 432
 433        if (!$haystack instanceof Countable &&
 434            !$haystack instanceof Traversable &&
 435            !is_array($haystack)) {
 436            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'countable or traversable');
 437        }
 438
 439        $constraint = new PHPUnit_Framework_Constraint_Not(
 440            new PHPUnit_Framework_Constraint_Count($expectedCount)
 441        );
 442
 443        static::assertThat($haystack, $constraint, $message);
 444    }
 445
 446    /**
 447     * Asserts the number of elements of an array, Countable or Traversable
 448     * that is stored in an attribute.
 449     *
 450     * @param int           $expectedCount
 451     * @param string        $haystackAttributeName
 452     * @param string|object $haystackClassOrObject
 453     * @param string        $message
 454     */
 455    public static function assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '')
 456    {
 457        static::assertNotCount(
 458            $expectedCount,
 459            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
 460            $message
 461        );
 462    }
 463
 464    /**
 465     * Asserts that two variables are equal.
 466     *
 467     * @param mixed  $expected
 468     * @param mixed  $actual
 469     * @param string $message
 470     * @param float  $delta
 471     * @param int    $maxDepth
 472     * @param bool   $canonicalize
 473     * @param bool   $ignoreCase
 474     */
 475    public static function assertEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
 476    {
 477        $constraint = new PHPUnit_Framework_Constraint_IsEqual(
 478            $expected,
 479            $delta,
 480            $maxDepth,
 481            $canonicalize,
 482            $ignoreCase
 483        );
 484
 485        static::assertThat($actual, $constraint, $message);
 486    }
 487
 488    /**
 489     * Asserts that a variable is equal to an attribute of an object.
 490     *
 491     * @param mixed         $expected
 492     * @param string        $actualAttributeName
 493     * @param string|object $actualClassOrObject
 494     * @param string        $message
 495     * @param float         $delta
 496     * @param int           $maxDepth
 497     * @param bool          $canonicalize
 498     * @param bool          $ignoreCase
 499     */
 500    public static function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
 501    {
 502        static::assertEquals(
 503            $expected,
 504            static::readAttribute($actualClassOrObject, $actualAttributeName),
 505            $message,
 506            $delta,
 507            $maxDepth,
 508            $canonicalize,
 509            $ignoreCase
 510        );
 511    }
 512
 513    /**
 514     * Asserts that two variables are not equal.
 515     *
 516     * @param mixed  $expected
 517     * @param mixed  $actual
 518     * @param string $message
 519     * @param float  $delta
 520     * @param int    $maxDepth
 521     * @param bool   $canonicalize
 522     * @param bool   $ignoreCase
 523     */
 524    public static function assertNotEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
 525    {
 526        $constraint = new PHPUnit_Framework_Constraint_Not(
 527            new PHPUnit_Framework_Constraint_IsEqual(
 528                $expected,
 529                $delta,
 530                $maxDepth,
 531                $canonicalize,
 532                $ignoreCase
 533            )
 534        );
 535
 536        static::assertThat($actual, $constraint, $message);
 537    }
 538
 539    /**
 540     * Asserts that a variable is not equal to an attribute of an object.
 541     *
 542     * @param mixed         $expected
 543     * @param string        $actualAttributeName
 544     * @param string|object $actualClassOrObject
 545     * @param string        $message
 546     * @param float         $delta
 547     * @param int           $maxDepth
 548     * @param bool          $canonicalize
 549     * @param bool          $ignoreCase
 550     */
 551    public static function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
 552    {
 553        static::assertNotEquals(
 554            $expected,
 555            static::readAttribute($actualClassOrObject, $actualAttributeName),
 556            $message,
 557            $delta,
 558            $maxDepth,
 559            $canonicalize,
 560            $ignoreCase
 561        );
 562    }
 563
 564    /**
 565     * Asserts that a variable is empty.
 566     *
 567     * @param mixed  $actual
 568     * @param string $message
 569     *
 570     * @throws PHPUnit_Framework_AssertionFailedError
 571     */
 572    public static function assertEmpty($actual, $message = '')
 573    {
 574        static::assertThat($actual, static::isEmpty(), $message);
 575    }
 576
 577    /**
 578     * Asserts that a static attribute of a class or an attribute of an object
 579     * is empty.
 580     *
 581     * @param string        $haystackAttributeName
 582     * @param string|object $haystackClassOrObject
 583     * @param string        $message
 584     */
 585    public static function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '')
 586    {
 587        static::assertEmpty(
 588            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
 589            $message
 590        );
 591    }
 592
 593    /**
 594     * Asserts that a variable is not empty.
 595     *
 596     * @param mixed  $actual
 597     * @param string $message
 598     *
 599     * @throws PHPUnit_Framework_AssertionFailedError
 600     */
 601    public static function assertNotEmpty($actual, $message = '')
 602    {
 603        static::assertThat($actual, static::logicalNot(static::isEmpty()), $message);
 604    }
 605
 606    /**
 607     * Asserts that a static attribute of a class or an attribute of an object
 608     * is not empty.
 609     *
 610     * @param string        $haystackAttributeName
 611     * @param string|object $haystackClassOrObject
 612     * @param string        $message
 613     */
 614    public static function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '')
 615    {
 616        static::assertNotEmpty(
 617            static::readAttribute($haystackClassOrObject, $haystackAttributeName),
 618            $message
 619        );
 620    }
 621
 622    /**
 623     * Asserts that a value is greater than another value.
 624     *
 625     * @param mixed  $expected
 626     * @param mixed  $actual
 627     * @param string $message
 628     */
 629    public static function assertGreaterThan($expected, $actual, $message = '')
 630    {
 631        static::assertThat($actual, static::greaterThan($expected), $message);
 632    }
 633
 634    /**
 635     * Asserts that an attribute is greater than another value.
 636     *
 637     * @param mixed         $expected
 638     * @param string        $actualAttributeName
 639     * @param string|object $actualClassOrObject
 640     * @param string        $message
 641     */
 642    public static function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '')
 643    {
 644        static::assertGreaterThan(
 645            $expected,
 646            static::readAttribute($actualClassOrObject, $actualAttributeName),
 647            $message
 648        );
 649    }
 650
 651    /**
 652     * Asserts that a value is greater than or equal to another value.
 653     *
 654     * @param mixed  $expected
 655     * @param mixed  $actual
 656     * @param string $message
 657     */
 658    public static function assertGreaterThanOrEqual($expected, $actual, $message = '')
 659    {
 660        static::assertThat(
 661            $actual,
 662            static::greaterThanOrEqual($expected),
 663            $message
 664        );
 665    }
 666
 667    /**
 668     * Asserts that an attribute is greater than or equal to another value.
 669     *
 670     * @param mixed         $expected
 671     * @param string        $actualAttributeName
 672     * @param string|object $actualClassOrObject
 673     * @param string        $message
 674     */
 675    public static function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '')
 676    {
 677        static::assertGreaterThanOrEqual(
 678            $expected,
 679            static::readAttribute($actualClassOrObject, $actualAttributeName),
 680            $message
 681        );
 682    }
 683
 684    /**
 685     * Asserts that a value is smaller than another value.
 686     *
 687     * @param mixed  $expected
 688     * @param mixed  $actual
 689     * @param string $message
 690     */
 691    public static function assertLessThan($expected, $actual, $message = '')
 692    {
 693        static::assertThat($actual, static::lessThan($expected), $message);
 694    }
 695
 696    /**
 697     * Asserts that an attribute is smaller than another value.
 698     *
 699     * @param mixed         $expected
 700     * @param string        $actualAttributeName
 701     * @param string|object $actualClassOrObject
 702     * @param string        $message
 703     */
 704    public static function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '')
 705    {
 706        static::assertLessThan(
 707            $expected,
 708            static::readAttribute($actualClassOrObject, $actualAttributeName),
 709            $message
 710        );
 711    }
 712
 713    /**
 714     * Asserts that a value is smaller than or equal to another value.
 715     *
 716     * @param mixed  $expected
 717     * @param mixed  $actual
 718     * @param string $message
 719     */
 720    public static function assertLessThanOrEqual($expected, $actual, $message = '')
 721    {
 722        static::assertThat($actual, static::lessThanOrEqual($expected), $message);
 723    }
 724
 725    /**
 726     * Asserts that an attribute is smaller than or equal to another value.
 727     *
 728     * @param mixed         $expected
 729     * @param string        $actualAttributeName
 730     * @param string|object $actualClassOrObject
 731     * @param string        $message
 732     */
 733    public static function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '')
 734    {
 735        static::assertLessThanOrEqual(
 736            $expected,
 737            static::readAttribute($actualClassOrObject, $actualAttributeName),
 738            $message
 739        );
 740    }
 741
 742    /**
 743     * Asserts that the contents of one file is equal to the contents of another
 744     * file.
 745     *
 746     * @param string $expected
 747     * @param string $actual
 748     * @param string $message
 749     * @param bool   $canonicalize
 750     * @param bool   $ignoreCase
 751     */
 752    public static function assertFileEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false)
 753    {
 754        static::assertFileExists($expected, $message);
 755        static::assertFileExists($actual, $message);
 756
 757        static::assertEquals(
 758            file_get_contents($expected),
 759            file_get_contents($actual),
 760            $message,
 761            0,
 762            10,
 763            $canonicalize,
 764            $ignoreCase
 765        );
 766    }
 767
 768    /**
 769     * Asserts that the contents of one file is not equal to the contents of
 770     * another file.
 771     *
 772     * @param string $expected
 773     * @param string $actual
 774     * @param string $message
 775     * @param bool   $canonicalize
 776     * @param bool   $ignoreCase
 777     */
 778    public static function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false)
 779    {
 780        static::assertFileExists($expected, $message);
 781        static::assertFileExists($actual, $message);
 782
 783        static::assertNotEquals(
 784            file_get_contents($expected),
 785            file_get_contents($actual),
 786            $message,
 787            0,
 788            10,
 789            $canonicalize,
 790            $ignoreCase
 791        );
 792    }
 793
 794    /**
 795     * Asserts that the contents of a string is equal
 796     * to the contents of a file.
 797     *
 798     * @param string $expectedFile
 799     * @param string $actualString
 800     * @param string $message
 801     * @param bool   $canonicalize
 802     * @param bool   $ignoreCase
 803     */
 804    public static function assertStringEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = false, $ignoreCase = false)
 805    {
 806        static::assertFileExists($expectedFile, $message);
 807
 808        static::assertEquals(
 809            file_get_contents($expectedFile),
 810            $actualString,
 811            $message,
 812            0,
 813            10,
 814            $canonicalize,
 815            $ignoreCase
 816        );
 817    }
 818
 819    /**
 820     * Asserts that the contents of a string is not equal
 821     * to the contents of a file.
 822     *
 823     * @param string $expectedFile
 824     * @param string $actualString
 825     * @param string $message
 826     * @param bool   $canonicalize
 827     * @param bool   $ignoreCase
 828     */
 829    public static function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = false, $ignoreCase = false)
 830    {
 831        static::assertFileExists($expectedFile, $message);
 832
 833        static::assertNotEquals(
 834            file_get_contents($expectedFile),
 835            $actualString,
 836            $message,
 837            0,
 838            10,
 839            $canonicalize,
 840            $ignoreCase
 841        );
 842    }
 843
 844    /**
 845     * Asserts that a file/dir is readable.
 846     *
 847     * @param string $filename
 848     * @param string $message
 849     */
 850    public static function assertIsReadable($filename, $message = '')
 851    {
 852        if (!is_string($filename)) {
 853            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
 854        }
 855
 856        $constraint = new PHPUnit_Framework_Constraint_IsReadable;
 857
 858        static::assertThat($filename, $constraint, $message);
 859    }
 860
 861    /**
 862     * Asserts that a file/dir exists and is not readable.
 863     *
 864     * @param string $filename
 865     * @param string $message
 866     */
 867    public static function assertNotIsReadable($filename, $message = '')
 868    {
 869        if (!is_string($filename)) {
 870            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
 871        }
 872
 873        $constraint = new PHPUnit_Framework_Constraint_Not(
 874            new PHPUnit_Framework_Constraint_IsReadable
 875        );
 876
 877        static::assertThat($filename, $constraint, $message);
 878    }
 879
 880    /**
 881     * Asserts that a file/dir exists and is writable.
 882     *
 883     * @param string $filename
 884     * @param string $message
 885     */
 886    public static function assertIsWritable($filename, $message = '')
 887    {
 888        if (!is_string($filename)) {
 889            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
 890        }
 891
 892        $constraint = new PHPUnit_Framework_Constraint_IsWritable;
 893
 894        static::assertThat($filename, $constraint, $message);
 895    }
 896
 897    /**
 898     * Asserts that a file/dir exists and is not writable.
 899     *
 900     * @param string $filename
 901     * @param string $message
 902     */
 903    public static function assertNotIsWritable($filename, $message = '')
 904    {
 905        if (!is_string($filename)) {
 906            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
 907        }
 908
 909        $constraint = new PHPUnit_Framework_Constraint_Not(
 910            new PHPUnit_Framework_Constraint_IsWritable
 911        );
 912
 913        static::assertThat($filename, $constraint, $message);
 914    }
 915
 916    /**
 917     * Asserts that a directory exists.
 918     *
 919     * @param string $directory
 920     * @param string $message
 921     */
 922    public static function assertDirectoryExists($directory, $message = '')
 923    {
 924        if (!is_string($directory)) {
 925            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
 926        }
 927
 928        $constraint = new PHPUnit_Framework_Constraint_DirectoryExists;
 929
 930        static::assertThat($directory, $constraint, $message);
 931    }
 932
 933    /**
 934     * Asserts that a directory does not exist.
 935     *
 936     * @param string $directory
 937     * @param string $message
 938     */
 939    public static function assertDirectoryNotExists($directory, $message = '')
 940    {
 941        if (!is_string($directory)) {
 942            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
 943        }
 944
 945        $constraint = new PHPUnit_Framework_Constraint_Not(
 946            new PHPUnit_Framework_Constraint_DirectoryExists
 947        );
 948
 949        static::assertThat($directory, $constraint, $message);
 950    }
 951
 952    /**
 953     * Asserts that a directory exists and is readable.
 954     *
 955     * @param string $directory
 956     * @param string $message
 957     */
 958    public static function assertDirectoryIsReadable($directory, $message = '')
 959    {
 960        self::assertDirectoryExists($directory, $message);
 961        self::assertIsReadable($directory, $message);
 962    }
 963
 964    /**
 965     * Asserts that a directory exists and is not readable.
 966     *
 967     * @param string $directory
 968     * @param string $message
 969     */
 970    public static function assertDirectoryNotIsReadable($directory, $message = '')
 971    {
 972        self::assertDirectoryExists($directory, $message);
 973        self::assertNotIsReadable($directory, $message);
 974    }
 975
 976    /**
 977     * Asserts that a directory exists and is writable.
 978     *
 979     * @param string $directory
 980     * @param string $message
 981     */
 982    public static function assertDirectoryIsWritable($directory, $message = '')
 983    {
 984        self::assertDirectoryExists($directory, $message);
 985        self::assertIsWritable($directory, $message);
 986    }
 987
 988    /**
 989     * Asserts that a directory exists and is not writable.
 990     *
 991     * @param string $directory
 992     * @param string $message
 993     */
 994    public static function assertDirectoryNotIsWritable($directory, $message = '')
 995    {
 996        self::assertDirectoryExists($directory, $message);
 997        self::assertNotIsWritable($directory, $message);
 998    }
 999
1000    /**
1001     * Asserts that a file exists.
1002     *
1003     * @param string $filename
1004     * @param string $message
1005     */
1006    public static function assertFileExists($filename, $message = '')
1007    {
1008        if (!is_string($filename)) {
1009            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1010        }
1011
1012        $constraint = new PHPUnit_Framework_Constraint_FileExists;
1013
1014        static::assertThat($filename, $constraint, $message);
1015    }
1016
1017    /**
1018     * Asserts that a file does not exist.
1019     *
1020     * @param string $filename
1021     * @param string $message
1022     */
1023    public static function assertFileNotExists($filename, $message = '')
1024    {
1025        if (!is_string($filename)) {
1026            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1027        }
1028
1029        $constraint = new PHPUnit_Framework_Constraint_Not(
1030            new PHPUnit_Framework_Constraint_FileExists
1031        );
1032
1033        static::assertThat($filename, $constraint, $message);
1034    }
1035
1036    /**
1037     * Asserts that a file exists and is readable.
1038     *
1039     * @param string $file
1040     * @param string $message
1041     */
1042    public static function assertFileIsReadable($file, $message = '')
1043    {
1044        self::assertFileExists($file, $message);
1045        self::assertIsReadable($file, $message);
1046    }
1047
1048    /**
1049     * Asserts that a file exists and is not readable.
1050     *
1051     * @param string $file
1052     * @param string $message
1053     */
1054    public static function assertFileNotIsReadable($file, $message = '')
1055    {
1056        self::assertFileExists($file, $message);
1057        self::assertNotIsReadable($file, $message);
1058    }
1059
1060    /**
1061     * Asserts that a file exists and is writable.
1062     *
1063     * @param string $file
1064     * @param string $message
1065     */
1066    public static function assertFileIsWritable($file, $message = '')
1067    {
1068        self::assertFileExists($file, $message);
1069        self::assertIsWritable($file, $message);
1070    }
1071
1072    /**
1073     * Asserts that a file exists and is not writable.
1074     *
1075     * @param string $file
1076     * @param string $message
1077     */
1078    public static function assertFileNotIsWritable($file, $message = '')
1079    {
1080        self::assertFileExists($file, $message);
1081        self::assertNotIsWritable($file, $message);
1082    }
1083
1084    /**
1085     * Asserts that a condition is true.
1086     *
1087     * @param bool   $condition
1088     * @param string $message
1089     *
1090     * @throws PHPUnit_Framework_AssertionFailedError
1091     */
1092    public static function assertTrue($condition, $message = '')
1093    {
1094        static::assertThat($condition, static::isTrue(), $message);
1095    }
1096
1097    /**
1098     * Asserts that a condition is not true.
1099     *
1100     * @param bool   $condition
1101     * @param string $message
1102     *
1103     * @throws PHPUnit_Framework_AssertionFailedError
1104     */
1105    public static function assertNotTrue($condition, $message = '')
1106    {
1107        static::assertThat($condition, static::logicalNot(static::isTrue()), $message);
1108    }
1109
1110    /**
1111     * Asserts that a condition is false.
1112     *
1113     * @param bool   $condition
1114     * @param string $message
1115     *
1116     * @throws PHPUnit_Framework_AssertionFailedError
1117     */
1118    public static function assertFalse($condition, $message = '')
1119    {
1120        static::assertThat($condition, static::isFalse(), $message);
1121    }
1122
1123    /**
1124     * Asserts that a condition is not false.
1125     *
1126     * @param bool   $condition
1127     * @param string $message
1128     *
1129     * @throws PHPUnit_Framework_AssertionFailedError
1130     */
1131    public static function assertNotFalse($condition, $message = '')
1132    {
1133        static::assertThat($condition, static::logicalNot(static::isFalse()), $message);
1134    }
1135
1136    /**
1137     * Asserts that a variable is null.
1138     *
1139     * @param mixed  $actual
1140     * @param string $message
1141     */
1142    public static function assertNull($actual, $message = '')
1143    {
1144        static::assertThat($actual, static::isNull(), $message);
1145    }
1146
1147    /**
1148     * Asserts that a variable is not null.
1149     *
1150     * @param mixed  $actual
1151     * @param string $message
1152     */
1153    public static function assertNotNull($actual, $message = '')
1154    {
1155        static::assertThat($actual, static::logicalNot(static::isNull()), $message);
1156    }
1157
1158    /**
1159     * Asserts that a variable is finite.
1160     *
1161     * @param mixed  $actual
1162     * @param string $message
1163     */
1164    public static function assertFinite($actual, $message = '')
1165    {
1166        static::assertThat($actual, static::isFinite(), $message);
1167    }
1168
1169    /**
1170     * Asserts that a variable is infinite.
1171     *
1172     * @param mixed  $actual
1173     * @param string $message
1174     */
1175    public static function assertInfinite($actual, $message = '')
1176    {
1177        static::assertThat($actual, static::isInfinite(), $message);
1178    }
1179
1180    /**
1181     * Asserts that a variable is nan.
1182     *
1183     * @param mixed  $actual
1184     * @param string $message
1185     */
1186    public static function assertNan($actual, $message = '')
1187    {
1188        static::assertThat($actual, static::isNan(), $message);
1189    }
1190
1191    /**
1192     * Asserts that a class has a specified attribute.
1193     *
1194     * @param string $attributeName
1195     * @param string $className
1196     * @param string $message
1197     */
1198    public static function assertClassHasAttribute($attributeName, $className, $message = '')
1199    {
1200        if (!is_string($attributeName)) {
1201            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1202        }
1203
1204        if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1205            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name');
1206        }
1207
1208        if (!is_string($className) || !class_exists($className)) {
1209            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name', $className);
1210        }
1211
1212        $constraint = new PHPUnit_Framework_Constraint_ClassHasAttribute(
1213            $attributeName
1214        );
1215
1216        static::assertThat($className, $constraint, $message);
1217    }
1218
1219    /**
1220     * Asserts that a class does not have a specified attribute.
1221     *
1222     * @param string $attributeName
1223     * @param string $className
1224     * @param string $message
1225     */
1226    public static function assertClassNotHasAttribute($attributeName, $className, $message = '')
1227    {
1228        if (!is_string($attributeName)) {
1229            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1230        }
1231
1232        if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1233            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name');
1234        }
1235
1236        if (!is_string($className) || !class_exists($className)) {
1237            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name', $className);
1238        }
1239
1240        $constraint = new PHPUnit_Framework_Constraint_Not(
1241            new PHPUnit_Framework_Constraint_ClassHasAttribute($attributeName)
1242        );
1243
1244        static::assertThat($className, $constraint, $message);
1245    }
1246
1247    /**
1248     * Asserts that a class has a specified static attribute.
1249     *
1250     * @param string $attributeName
1251     * @param string $className
1252     * @param string $message
1253     */
1254    public static function assertClassHasStaticAttribute($attributeName, $className, $message = '')
1255    {
1256        if (!is_string($attributeName)) {
1257            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1258        }
1259
1260        if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1261            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name');
1262        }
1263
1264        if (!is_string($className) || !class_exists($className)) {
1265            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name', $className);
1266        }
1267
1268        $constraint = new PHPUnit_Framework_Constraint_ClassHasStaticAttribute(
1269            $attributeName
1270        );
1271
1272        static::assertThat($className, $constraint, $message);
1273    }
1274
1275    /**
1276     * Asserts that a class does not have a specified static attribute.
1277     *
1278     * @param string $attributeName
1279     * @param string $className
1280     * @param string $message
1281     */
1282    public static function assertClassNotHasStaticAttribute($attributeName, $className, $message = '')
1283    {
1284        if (!is_string($attributeName)) {
1285            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1286        }
1287
1288        if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1289            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name');
1290        }
1291
1292        if (!is_string($className) || !class_exists($className)) {
1293            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name', $className);
1294        }
1295
1296        $constraint = new PHPUnit_Framework_Constraint_Not(
1297            new PHPUnit_Framework_Constraint_ClassHasStaticAttribute(
1298                $attributeName
1299            )
1300        );
1301
1302        static::assertThat($className, $constraint, $message);
1303    }
1304
1305    /**
1306     * Asserts that an object has a specified attribute.
1307     *
1308     * @param string $attributeName
1309     * @param object $object
1310     * @param string $message
1311     */
1312    public static function assertObjectHasAttribute($attributeName, $object, $message = '')
1313    {
1314        if (!is_string($attributeName)) {
1315            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1316        }
1317
1318        if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1319            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name');
1320        }
1321
1322        if (!is_object($object)) {
1323            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'object');
1324        }
1325
1326        $constraint = new PHPUnit_Framework_Constraint_ObjectHasAttribute(
1327            $attributeName
1328        );
1329
1330        static::assertThat($object, $constraint, $message);
1331    }
1332
1333    /**
1334     * Asserts that an object does not have a specified attribute.
1335     *
1336     * @param string $attributeName
1337     * @param object $object
1338     * @param string $message
1339     */
1340    public static function assertObjectNotHasAttribute($attributeName, $object, $message = '')
1341    {
1342        if (!is_string($attributeName)) {
1343            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1344        }
1345
1346        if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) {
1347            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name');
1348        }
1349
1350        if (!is_object($object)) {
1351            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'object');
1352        }
1353
1354        $constraint = new PHPUnit_Framework_Constraint_Not(
1355            new PHPUnit_Framework_Constraint_ObjectHasAttribute($attributeName)
1356        );
1357
1358        static::assertThat($object, $constraint, $message);
1359    }
1360
1361    /**
1362     * Asserts that two variables have the same type and value.
1363     * Used on objects, it asserts that two variables reference
1364     * the same object.
1365     *
1366     * @param mixed  $expected
1367     * @param mixed  $actual
1368     * @param string $message
1369     */
1370    public static function assertSame($expected, $actual, $message = '')
1371    {
1372        if (is_bool($expected) && is_bool($actual)) {
1373            static::assertEquals($expected, $actual, $message);
1374        } else {
1375            $constraint = new PHPUnit_Framework_Constraint_IsIdentical(
1376                $expected
1377            );
1378
1379            static::assertThat($actual, $constraint, $message);
1380        }
1381    }
1382
1383    /**
1384     * Asserts that a variable and an attribute of an object have the same type
1385     * and value.
1386     *
1387     * @param mixed         $expected
1388     * @param string        $actualAttributeName
1389     * @param string|object $actualClassOrObject
1390     * @param string        $message
1391     */
1392    public static function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '')
1393    {
1394        static::assertSame(
1395            $expected,
1396            static::readAttribute($actualClassOrObject, $actualAttributeName),
1397            $message
1398        );
1399    }
1400
1401    /**
1402     * Asserts that two variables do not have the same type and value.
1403     * Used on objects, it asserts that two variables do not reference
1404     * the same object.
1405     *
1406     * @param mixed  $expected
1407     * @param mixed  $actual
1408     * @param string $message
1409     */
1410    public static function assertNotSame($expected, $actual, $message = '')
1411    {
1412        if (is_bool($expected) && is_bool($actual)) {
1413            static::assertNotEquals($expected, $actual, $message);
1414        } else {
1415            $constraint = new PHPUnit_Framework_Constraint_Not(
1416                new PHPUnit_Framework_Constraint_IsIdentical($expected)
1417            );
1418
1419            static::assertThat($actual, $constraint, $message);
1420        }
1421    }
1422
1423    /**
1424     * Asserts that a variable and an attribute of an object do not have the
1425     * same type and value.
1426     *
1427     * @param mixed         $expected
1428     * @param string        $actualAttributeName
1429     * @param string|object $actualClassOrObject
1430     * @param string        $message
1431     */
1432    public static function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '')
1433    {
1434        static::assertNotSame(
1435            $expected,
1436            static::readAttribute($actualClassOrObject, $actualAttributeName),
1437            $message
1438        );
1439    }
1440
1441    /**
1442     * Asserts that a variable is of a given type.
1443     *
1444     * @param string $expected
1445     * @param mixed  $actual
1446     * @param string $message
1447     */
1448    public static function assertInstanceOf($expected, $actual, $message = '')
1449    {
1450        if (!(is_string($expected) && (class_exists($expected) || interface_exists($expected)))) {
1451            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class or interface name');
1452        }
1453
1454        $constraint = new PHPUnit_Framework_Constraint_IsInstanceOf(
1455            $expected
1456        );
1457
1458        static::assertThat($actual, $constraint, $message);
1459    }
1460
1461    /**
1462     * Asserts that an attribute is of a given type.
1463     *
1464     * @param string        $expected
1465     * @param string        $attributeName
1466     * @param string|object $classOrObject
1467     * @param string        $message
1468     */
1469    public static function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '')
1470    {
1471        static::assertInstanceOf(
1472            $expected,
1473            static::readAttribute($classOrObject, $attributeName),
1474            $message
1475        );
1476    }
1477
1478    /**
1479     * Asserts that a variable is not of a given type.
1480     *
1481     * @param string $expected
1482     * @param mixed  $actual
1483     * @param string $message
1484     */
1485    public static function assertNotInstanceOf($expected, $actual, $message = '')
1486    {
1487        if (!(is_string($expected) && (class_exists($expected) || interface_exists($expected)))) {
1488            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class or interface name');
1489        }
1490
1491        $constraint = new PHPUnit_Framework_Constraint_Not(
1492            new PHPUnit_Framework_Constraint_IsInstanceOf($expected)
1493        );
1494
1495        static::assertThat($actual, $constraint, $message);
1496    }
1497
1498    /**
1499     * Asserts that an attribute is of a given type.
1500     *
1501     * @param string        $expected
1502     * @param string        $attributeName
1503     * @param string|object $classOrObject
1504     * @param string        $message
1505     */
1506    public static function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '')
1507    {
1508        static::assertNotInstanceOf(
1509            $expected,
1510            static::readAttribute($classOrObject, $attributeName),
1511            $message
1512        );
1513    }
1514
1515    /**
1516     * Asserts that a variable is of a given type.
1517     *
1518     * @param string $expected
1519     * @param mixed  $actual
1520     * @param string $message
1521     */
1522    public static function assertInternalType($expected, $actual, $message = '')
1523    {
1524        if (!is_string($expected)) {
1525            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1526        }
1527
1528        $constraint = new PHPUnit_Framework_Constraint_IsType(
1529            $expected
1530        );
1531
1532        static::assertThat($actual, $constraint, $message);
1533    }
1534
1535    /**
1536     * Asserts that an attribute is of a given type.
1537     *
1538     * @param string        $expected
1539     * @param string        $attributeName
1540     * @param string|object $classOrObject
1541     * @param string        $message
1542     */
1543    public static function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '')
1544    {
1545        static::assertInternalType(
1546            $expected,
1547            static::readAttribute($classOrObject, $attributeName),
1548            $message
1549        );
1550    }
1551
1552    /**
1553     * Asserts that a variable is not of a given type.
1554     *
1555     * @param string $expected
1556     * @param mixed  $actual
1557     * @param string $message
1558     */
1559    public static function assertNotInternalType($expected, $actual, $message = '')
1560    {
1561        if (!is_string($expected)) {
1562            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1563        }
1564
1565        $constraint = new PHPUnit_Framework_Constraint_Not(
1566            new PHPUnit_Framework_Constraint_IsType($expected)
1567        );
1568
1569        static::assertThat($actual, $constraint, $message);
1570    }
1571
1572    /**
1573     * Asserts that an attribute is of a given type.
1574     *
1575     * @param string        $expected
1576     * @param string        $attributeName
1577     * @param string|object $classOrObject
1578     * @param string        $message
1579     */
1580    public static function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '')
1581    {
1582        static::assertNotInternalType(
1583            $expected,
1584            static::readAttribute($classOrObject, $attributeName),
1585            $message
1586        );
1587    }
1588
1589    /**
1590     * Asserts that a string matches a given regular expression.
1591     *
1592     * @param string $pattern
1593     * @param string $string
1594     * @param string $message
1595     */
1596    public static function assertRegExp($pattern, $string, $message = '')
1597    {
1598        if (!is_string($pattern)) {
1599            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
1600        }
1601
1602        if (!is_string($string)) {
1603            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string');
1604        }
1605
1606        $constraint = new PHPUnit_Framework_Constraint_PCREMatch($pattern);
1607
1608        static::assertThat($string, $constraint, $message);
1609    }
1610
1611    /**
1612     * Asserts that a string does not match a given regular expression.
1613     *
1614     * @param string $pattern
1615     * @param string $string
1616     * @param 

Large files files are truncated, but you can click here to view the full file