├── CHANGELOG.md ├── LICENSE ├── README.md ├── UPGRADE.md ├── bin └── generate_readme ├── composer.json └── src └── PHPUnit ├── Asserts ├── AliasAssertTrait.php ├── AssertHelper.php ├── FileExistsAssertTrait.php ├── FileSystemAssertTrait.php ├── RangeAssertTrait.php ├── StringsAssertTrait.php └── XMLAssertTrait.php └── Constraints ├── DirectoryEmptyConstraint.php ├── FileExistsConstraint.php ├── FileIsLinkConstraint.php ├── FileIsValidLinkConstraint.php ├── FilePermissionsIsIdenticalConstraint.php ├── FilePermissionsMaskConstraint.php ├── NumberRangeConstraint.php ├── SameStringsConstraint.php ├── ScalarConstraint.php ├── UnsignedIntConstraint.php └── XML ├── AbstractXMLConstraint.php ├── XMLMatchesXSDConstraint.php ├── XMLValidConstraint.php └── schema └── xml.xsd /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | #### GeckoPackages 2 | 3 | # CHANGELOG for PHPUnit extensions 4 | 5 | This file contains the changelogs of the package. 6 | 7 | ### Changelog for v3.1 8 | ###### Jan 24, 2018 9 | 10 | - add missing conflict with PHPUnit in composer.json 11 | 12 | ### Changelog for v3.0 13 | ###### Aug 23, 2017 14 | 15 | For upgrading from 2.x to 3.x please see https://github.com/GeckoPackages/GeckoPHPUnit/blob/3.0/UPGRADE.md 16 | 17 | ### Changelog for v2.2 18 | ###### Aug 23, 2017 19 | 20 | - Fix duplicate copy in README 21 | - Travis - retry composer info, show packages installed 22 | - Update CS to PHP-CS-Fixer 2.4 23 | - Better exception messages on construction of `FilePermissionsIsIdenticalConstraint` 24 | - More strict testing and remove useless escaping 25 | - Remove dependency on `ctype` extension 26 | - Add missing CHANGELOG.md file 27 | 28 | ### Changelog for v2.1 29 | ###### Jun 20, 2017 30 | 31 | - Add fail message support for the asserts `assertStringIsEmpty`, `assertStringIsNotEmpty`, `assertStringIsWhiteSpace` and `assertStringIsNotWhiteSpace` 32 | 33 | ### Changelog for v2.0 34 | ###### Nov 22, 2016 35 | 36 | - PHP 5.3 support for constraints (keradus/SpacePossum) 37 | - Added `assertSameStrings` and `assertNotSameStrings` to the `StringsAssertTrait`. Added `SameStringsConstraint` (keradus) 38 | - Renamed `FileExistsTrait` to `FileExistsAssertTrait` 39 | - Added `RangeAssertTrait`, `UnsignedIntConstraint` and `NumberRangeConstraint` 40 | - Added `assertFileIsValidLink` to `FileSystemAssertTrait` and added `FileIsValidLinkConstraint` 41 | - README generation tweaks 42 | 43 | ### Changelog for v1.0 44 | ###### Nov 4, 2015 45 | 46 | - First stable release 47 | 48 | ###### Notes 49 | 50 | Kindly note: 51 | Clean ups may be have be done in each release, these changes are not (always) listed in the change log. The changes may include: 52 | - optimization updates (based on static code analysis for example) 53 | - code style updates 54 | - documentation updates, README (generation) updates 55 | - typo fixes (which do not effect code execution) 56 | - updates to the tests (suit) of the project 57 | 58 | Full details on [github :octocat:](https://github.com/GeckoPackages/GeckoPHPUnit) 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) https://github.com/GeckoPackages 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Abandoned! 2 | 3 | We will try to move anything of value from here to PHPUnit 7 if possible. 4 | -------------------------------------------------------------------------------- /UPGRADE.md: -------------------------------------------------------------------------------- 1 | UPGRADE GUIDE FROM 2.x to 3.0 2 | ============================= 3 | 4 | This is guide for upgrade from version 2.x to 3.0 for the project.
5 | Release 3.0 has been made to be compat with "phpunit/phpunit": "^6.0". 6 | 7 | Traits (asserts) 8 | -------------- 9 | 10 | `ScalarAssertTrait` has been renamed to `AliasAssertTrait`. 11 | 12 | The following methods have been removed from `FileSystemAssertTrait`: 13 | - `assertDirectoryExists` 14 | - `assertDirectoryNotExists` 15 | 16 | PHPUnit provides these asserts self now. 17 | 18 | Constraints 19 | -------------- 20 | 21 | The `DirectoryExistsConstraint` has been removed. 22 | 23 | UPGRADE GUIDE FROM 1.x to 2.0 24 | ============================= 25 | 26 | This is guide for upgrade from version 1.x to 2.0 for the project. 27 | 28 | Traits (asserts) 29 | -------------- 30 | 31 | The `FileExistsTrait` has been renamed to `FileExistsAssertTrait`. 32 | 33 | The following methods have been moved from `ScalarAssertTrait` to `StringsAssertTrait`: 34 | - `assertStringIsEmpty` 35 | - `assertStringIsNotEmpty` 36 | - `assertStringIsNotWhiteSpace` 37 | - `assertStringIsWhiteSpace` 38 | 39 | Constraints 40 | -------------- 41 | 42 | The constraints have been made atomic and are now part of the API supporting 5.3.6 and up. 43 | 44 | Therefor the constructors of the following constraints have been changed: 45 | - `FilePermissionsIsIdenticalConstraint` 46 | - `FilePermissionsMaskConstraint` 47 | 48 | The XML constraints have been changed: 49 | - `AbstractXMLConstraint` 50 | - `XMLValidConstraint` 51 | - `XMLMatchesXSDConstraint` 52 | -------------------------------------------------------------------------------- /bin/generate_readme: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | generateReadMe())) { 26 | echo sprintf("\nFailed to write content to \"%s\".", $readMeFile); 27 | exit(-1); 28 | } 29 | 30 | exit(0); 31 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gecko-packages/gecko-php-unit", 3 | "type": "library", 4 | "homepage": "https://github.com/GeckoPackages", 5 | "description": "Additional PHPUnit asserts and constraints.", 6 | "license": "MIT", 7 | "keywords": ["PHPUnit", "Extension", "FileSystem"], 8 | "require": { 9 | "php": "^7.0" 10 | }, 11 | "conflict": { 12 | "phpunit/phpunit": "<6.0 || >6.5" 13 | }, 14 | "require-dev": { 15 | "phpunit/phpunit": "^6.0" 16 | }, 17 | "autoload": { 18 | "psr-4": { 19 | "GeckoPackages\\PHPUnit\\": "src/PHPUnit" 20 | } 21 | }, 22 | "config": { 23 | "optimize-autoloader": true, 24 | "sort-packages": true 25 | }, 26 | "extra": { 27 | "branch-alias": { 28 | "dev-master": "3.0-dev" 29 | } 30 | }, 31 | "suggest": { 32 | "ext-dom": "When testing with xml.", 33 | "ext-libxml": "When testing with xml.", 34 | "phpunit/phpunit" : "This is an extension for PHPUnit so make sure you have that in some way." 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/PHPUnit/Asserts/AliasAssertTrait.php: -------------------------------------------------------------------------------- 1 | 1 ? 'methods' : 'method', implode(', ', $missing)) 49 | ); 50 | } 51 | } 52 | 53 | /** 54 | * @param string $trait name of the trait used 55 | * @param string $method called method name 56 | * @param string $expectedTypeForArgument expected type description 57 | * @param mixed $valueOfArgument given value 58 | * @param int $index argument position 59 | * 60 | * @return Exception 61 | */ 62 | public static function createArgumentException(string $trait, string $method, string $expectedTypeForArgument, $valueOfArgument, int $index = 1): Exception 63 | { 64 | return self::createArgumentExceptionWithMessage( 65 | $trait, 66 | $method, 67 | $valueOfArgument, 68 | sprintf('must be %s.', (in_array($expectedTypeForArgument[0], ['a', 'e', 'i', 'o', 'u'], true) ? 'an' : 'a').' '.$expectedTypeForArgument), 69 | $index 70 | ); 71 | } 72 | 73 | public static function createArgumentExceptionWithMessage(string $trait, string $method, $valueOfArgument, string $message, int $index = 1): Exception 74 | { 75 | if (is_object($valueOfArgument)) { 76 | $valueOfArgument = sprintf('%s#%s', get_class($valueOfArgument), method_exists($valueOfArgument, '__toString') ? $valueOfArgument->__toString() : ''); 77 | } elseif (null === $valueOfArgument) { 78 | $valueOfArgument = 'null'; 79 | } else { 80 | $valueOfArgument = gettype($valueOfArgument).'#'.$valueOfArgument; 81 | } 82 | 83 | return new Exception( 84 | sprintf( 85 | 'Argument #%d (%s) of %s::%s() %s', 86 | $index, 87 | $valueOfArgument, 88 | substr($trait, strrpos($trait, '\\') + 1), 89 | $method, 90 | $message 91 | ) 92 | ); 93 | } 94 | 95 | /** 96 | * @param string $trait name of the trait used 97 | * @param string $method called method name 98 | * @param string $message 99 | * 100 | * @return Exception 101 | */ 102 | private static function createException(string $trait, string $method, string $message): Exception 103 | { 104 | return new Exception( 105 | sprintf( 106 | '%s::%s() %s.', 107 | substr($trait, strrpos($trait, '\\') + 1), 108 | $method, 109 | $message 110 | ) 111 | ); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/PHPUnit/Asserts/FileExistsAssertTrait.php: -------------------------------------------------------------------------------- 1 | 25 | * Note. Since this changes the default behaviour of the PHPUnit assert this has been placed in a separate trait. 26 | * 27 | * @api 28 | * 29 | * @author SpacePossum 30 | */ 31 | trait FileExistsAssertTrait 32 | { 33 | /** 34 | * Assert the filename exists and is a regular file. 35 | * 36 | * @param mixed $filename 37 | * @param string $message 38 | */ 39 | public static function assertFileExists($filename, $message = '') 40 | { 41 | self::assertFileExisting($filename, $message, 'assertFileExists', new FileExistsConstraint()); 42 | } 43 | 44 | /** 45 | * Assert the filename does not exists or is not a regular file. 46 | * 47 | * @param mixed $filename 48 | * @param string $message 49 | */ 50 | public static function assertFileNotExists($filename, $message = '') 51 | { 52 | self::assertFileExisting($filename, $message, 'assertFileNotExists', new LogicalNot(new FileExistsConstraint())); 53 | } 54 | 55 | /** 56 | * @param mixed $filename 57 | * @param string $message 58 | * @param string $method 59 | * @param Constraint $constraint 60 | */ 61 | private static function assertFileExisting($filename, string $message, string $method, Constraint $constraint) 62 | { 63 | AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, $method, ['assertThat']); 64 | self::assertThat($filename, $constraint, $message); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/PHPUnit/Asserts/FileSystemAssertTrait.php: -------------------------------------------------------------------------------- 1 | 0 or string; format for example: 'drwxrwxrwx' 61 | * @param mixed $filename 62 | * @param string $message 63 | */ 64 | public static function assertFileHasPermissions($permissions, $filename, string $message = '') 65 | { 66 | if (!is_string($permissions) && !(is_int($permissions) && $permissions >= 0)) { 67 | throw AssertHelper::createArgumentException(__TRAIT__, 'assertFileHasPermissions', 'int (>= 0) or string', $permissions); 68 | } 69 | 70 | try { 71 | $constraint = new FilePermissionsIsIdenticalConstraint($permissions); 72 | } catch (\InvalidArgumentException $e) { 73 | throw AssertHelper::createArgumentExceptionWithMessage( 74 | __TRAIT__, 75 | 'assertFileHasPermissions', 76 | $permissions, 77 | $e->getMessage() 78 | ); 79 | } 80 | 81 | self::assertThatConstraint($filename, $message, 'assertFileHasPermissions', $constraint); 82 | } 83 | 84 | /** 85 | * Assert that a file is a symbolic link. 86 | * 87 | * @param mixed $filename 88 | * @param string $message 89 | */ 90 | public static function assertFileIsLink($filename, string $message = '') 91 | { 92 | self::assertThatConstraint($filename, $message, 'assertFileIsLink', new FileIsLinkConstraint()); 93 | } 94 | 95 | /** 96 | * Assert that a file is not a symbolic link. 97 | * 98 | * @param mixed $filename 99 | * @param string $message 100 | */ 101 | public static function assertFileIsNotLink($filename, string $message = '') 102 | { 103 | self::assertThatConstraint($filename, $message, 'assertFileIsNotLink', new LogicalNot(new FileIsLinkConstraint())); 104 | } 105 | 106 | /** 107 | * Assert given value is a string, symlink and points to a file or directory that exists. 108 | * 109 | * @param mixed $filename 110 | * @param string $message 111 | */ 112 | public static function assertFileIsValidLink($filename, string $message = '') 113 | { 114 | self::assertThatConstraint($filename, $message, 'assertFileIsValidLink', new FileIsValidLinkConstraint()); 115 | } 116 | 117 | /** 118 | * Asserts that a file permission matches mask, for example: '0007'. 119 | * 120 | * @param int $permissionMask 121 | * @param mixed $filename 122 | * @param string $message 123 | */ 124 | public static function assertFilePermissionMask($permissionMask, $filename, string $message = '') 125 | { 126 | self::filePermissionMask($permissionMask, $filename, 'assertFilePermissionMask', true, $message); 127 | } 128 | 129 | /** 130 | * Asserts that a file permission does not matches mask, for example: '0607'. 131 | * 132 | * @param int $permissionMask 133 | * @param mixed $filename 134 | * @param string $message 135 | */ 136 | public static function assertFilePermissionNotMask($permissionMask, $filename, string $message = '') 137 | { 138 | self::filePermissionMask($permissionMask, $filename, 'assertFilePermissionNotMask', false, $message); 139 | } 140 | 141 | /** 142 | * @param mixed $input 143 | * @param string $message 144 | * @param string $method 145 | * @param Constraint $constraint 146 | */ 147 | private static function assertThatConstraint($input, string $message, string $method, Constraint $constraint) 148 | { 149 | AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, $method, ['assertThat']); 150 | self::assertThat($input, $constraint, $message); 151 | } 152 | 153 | /** 154 | * @param int $permissionMask 155 | * @param mixed $filename 156 | * @param string $method 157 | * @param bool $positive 158 | * @param string $message 159 | */ 160 | private static function filePermissionMask($permissionMask, $filename, string $method, bool $positive, string $message = '') 161 | { 162 | if (!is_int($permissionMask)) { 163 | throw AssertHelper::createArgumentException(__TRAIT__, $method, 'int', $permissionMask); 164 | } 165 | 166 | $constraint = new FilePermissionsMaskConstraint($permissionMask); 167 | 168 | self::assertThatConstraint($filename, $message, $method, $positive ? $constraint : new LogicalNot($constraint)); 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /src/PHPUnit/Asserts/RangeAssertTrait.php: -------------------------------------------------------------------------------- 1 | = 0). 85 | * 86 | * @param mixed $actual 87 | * @param string $message 88 | */ 89 | public function assertUnsignedInt($actual, string $message = '') 90 | { 91 | AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertUnsignedInt', ['assertThat']); 92 | self::assertThat($actual, new UnsignedIntConstraint(), $message); 93 | } 94 | 95 | /** 96 | * @param int|float $lowerBoundary 97 | * @param int|float $upperBoundary 98 | * @param mixed $actual 99 | * @param string $message 100 | * @param string $method name of method doing the testing 101 | * @param bool $onBoundary test on boundary or between boundary values 102 | * @param bool $negative test as negative 103 | */ 104 | private static function assertNumberRangeMatch( 105 | $lowerBoundary, 106 | $upperBoundary, 107 | $actual, 108 | string $message, 109 | string $method, 110 | bool $onBoundary, 111 | bool $negative 112 | ) { 113 | if (!is_int($lowerBoundary) && !is_float($lowerBoundary)) { 114 | throw AssertHelper::createArgumentException(__TRAIT__, $method, 'float or int', $lowerBoundary); 115 | } 116 | 117 | if (!is_int($upperBoundary) && !is_float($upperBoundary)) { 118 | throw AssertHelper::createArgumentException(__TRAIT__, $method, 'float or int', $upperBoundary, 2); 119 | } 120 | 121 | if ($lowerBoundary >= $upperBoundary) { 122 | $message = sprintf( 123 | 'lower boundary %s must be smaller than upper boundary %s.', 124 | is_int($lowerBoundary) ? '%d' : '%.3f', 125 | is_int($upperBoundary) ? '%d' : '%.3f' 126 | ); 127 | 128 | throw AssertHelper::createArgumentExceptionWithMessage( 129 | __TRAIT__, 130 | $method, 131 | $lowerBoundary, 132 | sprintf($message, $lowerBoundary, $upperBoundary) 133 | ); 134 | } 135 | 136 | $rangeConstraint = new NumberRangeConstraint($lowerBoundary, $upperBoundary, $onBoundary); 137 | if ($negative) { 138 | $rangeConstraint = new LogicalNot($rangeConstraint); 139 | } 140 | 141 | AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, $method, ['assertThat']); 142 | self::assertThat($actual, $rangeConstraint, $message); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/PHPUnit/Asserts/StringsAssertTrait.php: -------------------------------------------------------------------------------- 1 | 27 | * @author SpacePossum 28 | */ 29 | trait StringsAssertTrait 30 | { 31 | /** 32 | * Assert that strings are not identical. 33 | * 34 | * @param string $expected 35 | * @param mixed $actual 36 | * @param string $message 37 | */ 38 | public static function assertNotSameStrings($expected, $actual, string $message = '') 39 | { 40 | self::assertStringsIdentity($actual, $message, __FUNCTION__, new LogicalNot(new SameStringsConstraint($expected))); 41 | } 42 | 43 | /** 44 | * Assert that strings are identical. 45 | * 46 | * @param string $expected 47 | * @param mixed $actual 48 | * @param string $message 49 | */ 50 | public static function assertSameStrings($expected, $actual, string $message = '') 51 | { 52 | self::assertStringsIdentity($actual, $message, __FUNCTION__, new SameStringsConstraint($expected)); 53 | } 54 | 55 | /** 56 | * Assert value is a string and is empty. 57 | * 58 | * @param mixed $actual 59 | * @param string $message 60 | */ 61 | public static function assertStringIsEmpty($actual, string $message = '') 62 | { 63 | AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertStringIsEmpty', ['assertThat', 'assertEmpty']); 64 | self::assertThat($actual, new IsType('string'), $message); 65 | self::assertEmpty($actual, $message); 66 | } 67 | 68 | /** 69 | * Assert value is a string and is not empty. 70 | * 71 | * @param mixed $actual 72 | * @param string $message 73 | */ 74 | public static function assertStringIsNotEmpty($actual, string $message = '') 75 | { 76 | AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertStringIsNotEmpty', ['assertThat', 'assertNotEmpty']); 77 | self::assertThat($actual, new IsType('string'), $message); 78 | self::assertNotEmpty($actual, $message); 79 | } 80 | 81 | /** 82 | * Assert value is a string and not only contains white space characters (" \t\n\r\0\x0B"). 83 | * 84 | * Uses PHP function trim @see http://php.net/manual/en/function.trim.php 85 | * The following characters are considered white space: 86 | * - " " (ASCII 32 (0x20)), an ordinary space. 87 | * - "\t" (ASCII 9 (0x09)), a tab. 88 | * - "\n" (ASCII 10 (0x0A)), a new line (line feed). 89 | * - "\r" (ASCII 13 (0x0D)), a carriage return. 90 | * - "\0" (ASCII 0 (0x00)), the NUL-byte. 91 | * - "\x0B" (ASCII 11 (0x0B)), a vertical tab. 92 | * 93 | * @param mixed $actual 94 | * @param string $message 95 | */ 96 | public static function assertStringIsNotWhiteSpace($actual, string $message = '') 97 | { 98 | AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertStringIsNotWhiteSpace', ['assertThat', 'assertNotEmpty']); 99 | self::assertThat($actual, new IsType('string'), $message); 100 | self::assertNotEmpty(trim($actual), $message); 101 | } 102 | 103 | /** 104 | * Assert value is a string and only contains white space characters (" \t\n\r\0\x0B"). 105 | * 106 | * Uses PHP function trim @see http://php.net/manual/en/function.trim.php 107 | * The following characters are considered white space: 108 | * - " " (ASCII 32 (0x20)), an ordinary space. 109 | * - "\t" (ASCII 9 (0x09)), a tab. 110 | * - "\n" (ASCII 10 (0x0A)), a new line (line feed). 111 | * - "\r" (ASCII 13 (0x0D)), a carriage return. 112 | * - "\0" (ASCII 0 (0x00)), the NUL-byte. 113 | * - "\x0B" (ASCII 11 (0x0B)), a vertical tab. 114 | * 115 | * @param mixed $actual 116 | * @param string $message 117 | */ 118 | public static function assertStringIsWhiteSpace($actual, string $message = '') 119 | { 120 | AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertStringIsWhiteSpace', ['assertThat', 'assertEmpty']); 121 | self::assertThat($actual, new IsType('string'), $message); 122 | self::assertEmpty(trim($actual), $message); 123 | } 124 | 125 | /** 126 | * @param mixed $actual 127 | * @param string $message 128 | * @param string $method 129 | * @param Constraint $constraint 130 | */ 131 | private static function assertStringsIdentity($actual, string $message, string $method, Constraint $constraint) 132 | { 133 | AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, $method, ['assertThat']); 134 | self::assertThat($actual, $constraint, $message); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/PHPUnit/Asserts/XMLAssertTrait.php: -------------------------------------------------------------------------------- 1 | isDot()) { 36 | continue; 37 | } 38 | 39 | return false; 40 | } 41 | 42 | return true; 43 | } 44 | 45 | /** 46 | * {@inheritdoc} 47 | */ 48 | protected function failureDescription($other) 49 | { 50 | if (is_object($other)) { 51 | $type = sprintf('%s#%s', get_class($other), method_exists($other, '__toString') ? $other->__toString() : ''); 52 | } elseif (null === $other) { 53 | $type = 'null'; 54 | } elseif (!is_string($other)) { 55 | $type = gettype($other).'#'.$other; 56 | } elseif (is_link($other)) { 57 | $type = 'link to file#'.$other; 58 | } elseif (is_file($other)) { 59 | $type = 'file#'.$other; 60 | } elseif (is_dir($other)) { 61 | $type = 'directory#'.$other; 62 | } else { 63 | $type = $other; 64 | } 65 | 66 | return $type.' is an empty directory'; 67 | } 68 | 69 | /** 70 | * {@inheritdoc} 71 | */ 72 | public function toString() 73 | { 74 | return 'is an empty directory'; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/FileExistsConstraint.php: -------------------------------------------------------------------------------- 1 | __toString() : ''); 40 | } elseif (null === $other) { 41 | $type = 'null'; 42 | } elseif (!is_string($other)) { 43 | $type = gettype($other).'#'.$other; 44 | } elseif (is_link($other)) { 45 | $type = 'link to directory#'.$other; 46 | } elseif (is_dir($other)) { 47 | $type = 'directory#'.$other; 48 | } else { 49 | $type = $other; 50 | } 51 | 52 | return $type.' '.$this->toString(); 53 | } 54 | 55 | /** 56 | * {@inheritdoc} 57 | */ 58 | public function toString() 59 | { 60 | return 'is a file'; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/FileIsLinkConstraint.php: -------------------------------------------------------------------------------- 1 | __toString() : ''); 40 | } elseif (null === $other) { 41 | $type = 'null'; 42 | } elseif (!is_string($other)) { 43 | $type = gettype($other).'#'.$other; 44 | } elseif (is_file($other)) { 45 | $type = 'file#'.$other; 46 | } elseif (is_dir($other)) { 47 | $type = 'directory#'.$other; 48 | } else { 49 | $type = $other; 50 | } 51 | 52 | return $type.' '.$this->toString(); 53 | } 54 | 55 | /** 56 | * {@inheritdoc} 57 | */ 58 | public function toString() 59 | { 60 | return 'is a link'; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/FileIsValidLinkConstraint.php: -------------------------------------------------------------------------------- 1 | __toString() : ''); 44 | } elseif (null === $other) { 45 | $type = 'null'; 46 | } elseif (!is_string($other)) { 47 | $type = gettype($other).'#'.$other; 48 | } elseif (!file_exists($other)) { 49 | if (is_link($other)) { 50 | $type = 'link#'.$other; 51 | } else { 52 | $type = 'string#'.$other; 53 | } 54 | } elseif (is_dir($other)) { 55 | $type = 'directory#'.$other; 56 | } elseif (is_file($other)) { 57 | $type = 'file#'.$other; 58 | } else { // is string, not dir, not file, not link, should never be reached 59 | $type = 'string#'.$other; 60 | } 61 | 62 | return $type.' '.$this->toString(); 63 | } 64 | 65 | /** 66 | * {@inheritdoc} 67 | */ 68 | public function toString() 69 | { 70 | return 'is a valid link'; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/FilePermissionsIsIdenticalConstraint.php: -------------------------------------------------------------------------------- 1 | permissions = '0' === $permissions[0] 44 | ? intval($permissions, 8) 45 | : (int) $permissions 46 | ; 47 | 48 | return; 49 | } 50 | 51 | if (1 === preg_match(self::$permissionFormat, $permissions)) { 52 | $this->permissions = $permissions; 53 | 54 | return; 55 | } 56 | 57 | throw new \InvalidArgumentException(sprintf('Permission to match "%s" is not formatted correctly.', $permissions)); 58 | } 59 | 60 | if (!is_int($permissions)) { 61 | if (is_object($permissions)) { 62 | $type = sprintf('%s#%s', get_class($permissions), method_exists($permissions, '__toString') ? $permissions->__toString() : ''); 63 | } elseif (null === $permissions) { 64 | $type = 'null'; 65 | } else { 66 | $type = gettype($permissions).'#'.$permissions; 67 | } 68 | 69 | throw new \InvalidArgumentException(sprintf('Invalid value for permission to match "%s", expected int >= 0 or string.', $type)); 70 | } 71 | 72 | if ($permissions < 0) { 73 | throw new \InvalidArgumentException(sprintf('Invalid value for permission to match "%d", expected int >= 0 or string.', $permissions)); 74 | } 75 | 76 | $this->permissions = $permissions; 77 | } 78 | 79 | /** 80 | * {@inheritdoc} 81 | */ 82 | protected function matches($other) 83 | { 84 | if (!is_string($other) || !file_exists($other)) { 85 | return false; 86 | } 87 | 88 | if (is_link($other)) { 89 | $perms = lstat($other); 90 | $perms = $perms['mode']; 91 | } else { 92 | $perms = fileperms($other); 93 | } 94 | 95 | if (is_string($this->permissions)) { 96 | return self::getFilePermissionsAsString($perms) === $this->permissions; 97 | } 98 | 99 | // $this->permissions is int 100 | // for example 0777 vs 100777 101 | if ($this->permissions < 1412) { 102 | $comp = (int) sprintf('%o', $this->permissions); 103 | $filePerm = (int) substr(sprintf('%o', $perms), -3); 104 | } else { 105 | $comp = $this->permissions; 106 | $filePerm = (int) sprintf('%o', $perms); 107 | } 108 | 109 | return $filePerm === $comp; 110 | } 111 | 112 | /** 113 | * {@inheritdoc} 114 | */ 115 | protected function failureDescription($other) 116 | { 117 | if (!is_string($other)) { 118 | if (is_object($other)) { 119 | $type = sprintf('%s#%s', get_class($other), method_exists($other, '__toString') ? $other->__toString() : ''); 120 | } elseif (null === $other) { 121 | $type = 'null'; 122 | } else { 123 | $type = gettype($other).'#'.$other; 124 | } 125 | 126 | return $type.' '.$this->toString(); 127 | } 128 | 129 | if (!file_exists($other)) { 130 | return 'not file or directory#'.$other.' '.$this->toString(); 131 | } 132 | 133 | if (is_link($other)) { 134 | $perms = lstat($other); 135 | $perms = $perms['mode']; 136 | $type = 'link'; 137 | } else { 138 | $perms = fileperms($other); 139 | $type = is_file($other) ? 'file' : (is_dir($other) ? 'directory' : 'other'); 140 | } 141 | 142 | if (is_string($this->permissions)) { 143 | return sprintf('%s#%s %s %s to %s', $type, $other, self::getFilePermissionsAsString($perms), $this->toString(), $this->permissions); 144 | } 145 | 146 | if ($this->permissions < 1412) { 147 | $comp = (int) sprintf('%o', $this->permissions); 148 | $perms = (int) substr(sprintf('%o', $perms), -3); 149 | } else { 150 | $comp = $this->permissions; 151 | $perms = (int) sprintf('%o', $perms); 152 | } 153 | 154 | return sprintf('%s#%s 0%d %s to 0%d', $type, $other, $perms, $this->toString(), $comp); 155 | } 156 | 157 | /** 158 | * {@inheritdoc} 159 | */ 160 | public function toString() 161 | { 162 | return 'permissions are equal'; 163 | } 164 | 165 | /** 166 | * @param int $perms 167 | * 168 | * @return string 169 | */ 170 | private static function getFilePermissionsAsString($perms) 171 | { 172 | if (0xC000 === ($perms & 0xC000)) { // Socket 173 | $info = 's'; 174 | } elseif (0xA000 === ($perms & 0xA000)) { // Symbolic Link 175 | $info = 'l'; 176 | } elseif (0x8000 === ($perms & 0x8000)) { // Regular 177 | $info = '-'; 178 | } elseif (0x6000 === ($perms & 0x6000)) { // Block special 179 | $info = 'b'; 180 | } elseif (0x4000 === ($perms & 0x4000)) { // Directory 181 | $info = 'd'; 182 | } elseif (0x2000 === ($perms & 0x2000)) { // Character special 183 | $info = 'c'; 184 | } elseif (0x1000 === ($perms & 0x1000)) { // FIFO pipe 185 | $info = 'p'; 186 | } else { // Unknown 187 | $info = 'u'; 188 | } 189 | 190 | // Owner 191 | $info .= (($perms & 0x0100) ? 'r' : '-'); 192 | $info .= (($perms & 0x0080) ? 'w' : '-'); 193 | $info .= (($perms & 0x0040) ? 194 | (($perms & 0x0800) ? 's' : 'x') : 195 | (($perms & 0x0800) ? 'S' : '-')); 196 | 197 | // Group 198 | $info .= (($perms & 0x0020) ? 'r' : '-'); 199 | $info .= (($perms & 0x0010) ? 'w' : '-'); 200 | $info .= (($perms & 0x0008) ? 201 | (($perms & 0x0400) ? 's' : 'x') : 202 | (($perms & 0x0400) ? 'S' : '-')); 203 | 204 | // World 205 | $info .= (($perms & 0x0004) ? 'r' : '-'); 206 | $info .= (($perms & 0x0002) ? 'w' : '-'); 207 | $info .= (($perms & 0x0001) ? 208 | (($perms & 0x0200) ? 't' : 'x') : 209 | (($perms & 0x0200) ? 'T' : '-')); 210 | 211 | return $info; 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/FilePermissionsMaskConstraint.php: -------------------------------------------------------------------------------- 1 | mask = $mask; 38 | } 39 | 40 | /** 41 | * {@inheritdoc} 42 | */ 43 | protected function matches($other) 44 | { 45 | if (!is_string($other) || !file_exists($other)) { 46 | return false; 47 | } 48 | 49 | if (is_link($other)) { 50 | $perms = lstat($other); 51 | $perms = $perms['mode']; 52 | } else { 53 | $perms = fileperms($other); 54 | } 55 | 56 | return ($perms & $this->mask) === $this->mask; 57 | } 58 | 59 | /** 60 | * {@inheritdoc} 61 | */ 62 | protected function failureDescription($other) 63 | { 64 | if (!is_string($other)) { 65 | if (is_object($other)) { 66 | $type = sprintf('%s#%s', get_class($other), method_exists($other, '__toString') ? $other->__toString() : ''); 67 | } elseif (null === $other) { 68 | $type = 'null'; 69 | } else { 70 | $type = gettype($other).'#'.$other; 71 | } 72 | 73 | return $type.' '.$this->toString(); 74 | } 75 | 76 | if (!file_exists($other)) { 77 | return 'not file or directory#'.$other.' '.$this->toString(); 78 | } 79 | 80 | if (is_link($other)) { 81 | $type = 'link'; 82 | $perms = lstat($other); 83 | $perms = $perms['mode']; 84 | } else { 85 | $type = is_file($other) ? 'file' : (is_dir($other) ? 'directory' : 'other'); 86 | $perms = fileperms($other); 87 | } 88 | 89 | return sprintf('%s#%s %o %s %o', $type, $other, $perms, $this->toString(), $this->mask); 90 | } 91 | 92 | /** 93 | * {@inheritdoc} 94 | */ 95 | public function toString() 96 | { 97 | return 'permissions matches mask'; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/NumberRangeConstraint.php: -------------------------------------------------------------------------------- 1 | lowerBoundary = $lowerBoundary; 50 | $this->upperBoundary = $upperBoundary; 51 | $this->onBoundary = $onBoundary; 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | public function toString() 58 | { 59 | return sprintf('is %s range', $this->onBoundary ? 'in' : 'within'); 60 | } 61 | 62 | /** 63 | * {@inheritdoc} 64 | */ 65 | protected function matches($other) 66 | { 67 | if ($this->onBoundary) { 68 | return $other >= $this->lowerBoundary && $other <= $this->upperBoundary; 69 | } 70 | 71 | return $other > $this->lowerBoundary && $other < $this->upperBoundary; 72 | } 73 | 74 | /** 75 | * {@inheritdoc} 76 | */ 77 | protected function failureDescription($other) 78 | { 79 | return sprintf( 80 | sprintf( 81 | '%%%s %%s %s%%%s, %%%s%s', 82 | is_int($other) ? 'd' : '.3f', 83 | $this->onBoundary ? '[' : '(', 84 | is_int($this->lowerBoundary) ? 'd' : '.3f', 85 | is_int($this->upperBoundary) ? 'd' : '.3f', 86 | $this->onBoundary ? ']' : ')' 87 | ), 88 | $other, 89 | $this->toString(), 90 | $this->lowerBoundary, 91 | $this->upperBoundary 92 | ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/SameStringsConstraint.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | final class SameStringsConstraint extends IsIdentical 24 | { 25 | /** 26 | * {@inheritdoc} 27 | */ 28 | protected function additionalFailureDescription($other) 29 | { 30 | if ( 31 | $other === $this->value 32 | || preg_replace('/(\r\n|\n\r|\r)/', "\n", $other) !== preg_replace('/(\r\n|\n\r|\r)/', "\n", $this->value) 33 | ) { 34 | return ''; 35 | } 36 | 37 | return ' #Warning: Strings contain different line endings! Debug using remapping ["\r" => "R", "\n" => "N", "\t" => "T"]:' 38 | ."\n" 39 | .' -'.str_replace(["\r", "\n", "\t"], ['R', 'N', 'T'], $other) 40 | ."\n" 41 | .' +'.str_replace(["\r", "\n", "\t"], ['R', 'N', 'T'], $this->value); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/ScalarConstraint.php: -------------------------------------------------------------------------------- 1 | testFunction = 'is_bool'; 45 | $this->type = 'bool'; 46 | 47 | break; 48 | case self::TYPE_INT: 49 | $this->testFunction = 'is_int'; 50 | $this->type = 'int'; 51 | 52 | break; 53 | case self::TYPE_STRING: 54 | $this->testFunction = 'is_string'; 55 | $this->type = 'string'; 56 | 57 | break; 58 | case self::TYPE_FLOAT: 59 | $this->testFunction = 'is_float'; 60 | $this->type = 'float'; 61 | 62 | break; 63 | case self::TYPE_ARRAY: 64 | $this->testFunction = 'is_array'; 65 | $this->type = 'array'; 66 | 67 | break; 68 | case self::TYPE_SCALAR: 69 | $this->testFunction = 'is_scalar'; 70 | $this->type = 'scalar'; 71 | 72 | break; 73 | default: 74 | throw new \InvalidArgumentException(sprintf( 75 | 'Unknown ScalarConstraint type "%s" provided.', 76 | is_object($type) ? get_class($type) : (null === $type ? 'null' : gettype($type).'#'.$type) 77 | )); 78 | } 79 | } 80 | 81 | /** 82 | * {@inheritdoc} 83 | */ 84 | protected function matches($other) 85 | { 86 | $m = $this->testFunction; 87 | 88 | return $m($other); 89 | } 90 | 91 | /** 92 | * {@inheritdoc} 93 | */ 94 | protected function failureDescription($other) 95 | { 96 | if (is_object($other)) { 97 | $input = sprintf('%s#%s', get_class($other), method_exists($other, '__toString') ? $other->__toString() : ''); 98 | } elseif (null === $other) { 99 | $input = 'null'; 100 | } else { 101 | $input = gettype($other).'#'.$other; 102 | } 103 | 104 | return sprintf('%s is of type %s', $input, $this->type); 105 | } 106 | 107 | /** 108 | * {@inheritdoc} 109 | */ 110 | public function toString() 111 | { 112 | return sprintf('is of type "%s".', $this->type); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/UnsignedIntConstraint.php: -------------------------------------------------------------------------------- 1 | = 0; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/XML/AbstractXMLConstraint.php: -------------------------------------------------------------------------------- 1 | stringMatches($other); 40 | } 41 | 42 | /** 43 | * @param string $other 44 | * 45 | * @return bool 46 | */ 47 | abstract protected function stringMatches($other); 48 | 49 | protected function setXMLConstraintErrors() 50 | { 51 | foreach (libxml_get_errors() as $error) { 52 | switch ($error->level) { 53 | case LIBXML_ERR_WARNING: 54 | $level = 'warning '; 55 | 56 | break; 57 | case LIBXML_ERR_ERROR: 58 | $level = 'error '; 59 | 60 | break; 61 | case LIBXML_ERR_FATAL: 62 | $level = 'fatal '; 63 | 64 | break; 65 | default: 66 | $level = ''; 67 | 68 | break; 69 | } 70 | 71 | $this->XMLConstraintErrors[] = sprintf('[%s%s] %s (line %d, column %d).', $level, $error->code, trim($error->message), $error->line, $error->column); 72 | } 73 | } 74 | 75 | /** 76 | * {@inheritdoc} 77 | */ 78 | protected function failureDescription($other) 79 | { 80 | if (!is_string($other)) { 81 | if (is_object($other)) { 82 | $type = sprintf('%s#%s', get_class($other), method_exists($other, '__toString') ? $other->__toString() : ''); 83 | } elseif (null === $other) { 84 | $type = 'null'; 85 | } else { 86 | $type = gettype($other).'#'.$other; 87 | } 88 | 89 | return $type.' '.$this->toString(); 90 | } 91 | 92 | return sprintf("%s %s.\n%s", $other, $this->toString(), implode("\n", $this->XMLConstraintErrors)); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/XML/XMLMatchesXSDConstraint.php: -------------------------------------------------------------------------------- 1 | XSD = str_replace('http://www.w3.org/2001/xml.xsd', 'file:////'.__DIR__.'/schema/xml.xsd', $XSD); 36 | } 37 | 38 | /** 39 | * {@inheritdoc} 40 | */ 41 | protected function stringMatches($other) 42 | { 43 | $internalErrors = libxml_use_internal_errors(true); 44 | $disableEntities = libxml_disable_entity_loader(true); 45 | libxml_clear_errors(); 46 | 47 | $dom = new \DOMDocument(); 48 | $dom->preserveWhiteSpace = false; 49 | $dom->validateOnParse = true; 50 | if (!@$dom->loadXML($other, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) { 51 | libxml_disable_entity_loader($disableEntities); 52 | $this->setXMLConstraintErrors(); 53 | libxml_clear_errors(); 54 | libxml_use_internal_errors($internalErrors); 55 | 56 | return false; 57 | } 58 | 59 | $dom->normalizeDocument(); 60 | 61 | libxml_disable_entity_loader($disableEntities); 62 | libxml_clear_errors(); 63 | 64 | if (false === $result = @$dom->schemaValidateSource($this->XSD)) { 65 | $this->setXMLConstraintErrors(); 66 | } 67 | 68 | libxml_clear_errors(); 69 | libxml_use_internal_errors($internalErrors); 70 | 71 | return $result; 72 | } 73 | 74 | /** 75 | * {@inheritdoc} 76 | */ 77 | public function toString() 78 | { 79 | return 'matches XSD'; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/XML/XMLValidConstraint.php: -------------------------------------------------------------------------------- 1 | preserveWhiteSpace = false; 34 | $dom->validateOnParse = true; 35 | if (!@$dom->loadXML($other, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) { 36 | libxml_disable_entity_loader($disableEntities); 37 | $this->setXMLConstraintErrors(); 38 | libxml_clear_errors(); 39 | libxml_use_internal_errors($internalErrors); 40 | 41 | return false; 42 | } 43 | 44 | libxml_disable_entity_loader($disableEntities); 45 | libxml_clear_errors(); 46 | 47 | return true; 48 | } 49 | 50 | /** 51 | * {@inheritdoc} 52 | */ 53 | public function toString() 54 | { 55 | return 'is valid XML'; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/PHPUnit/Constraints/XML/schema/xml.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 |
11 |

About the XML namespace

12 | 13 |
14 |

15 | 16 | This schema document describes the XML namespace, in a form 17 | suitable for import by other schema documents. 18 |

19 |

20 | See 21 | http://www.w3.org/XML/1998/namespace.html and 22 | 23 | http://www.w3.org/TR/REC-xml for information 24 | about this namespace. 25 |

26 | 27 |

28 | Note that local names in this namespace are intended to be 29 | defined only by the World Wide Web Consortium or its subgroups. 30 | The names currently defined in this namespace are listed below. 31 | They should not be used with conflicting semantics by any Working 32 | Group, specification, or document instance. 33 |

34 |

35 | See further below in this document for more information about how to refer to this schema document from your own 37 | XSD schema documents and about the 38 | namespace-versioning policy governing this schema document. 39 |

40 |
41 |
42 | 43 |
44 |
45 | 46 | 47 | 48 | 49 |
50 | 51 |

lang (as an attribute name)

52 |

53 | 54 | denotes an attribute whose value 55 | is a language code for the natural language of the content of 56 | any element; its value is inherited. This name is reserved 57 | by virtue of its definition in the XML specification.

58 | 59 |
60 |
61 |

Notes

62 |

63 | Attempting to install the relevant ISO 2- and 3-letter 64 | codes as the enumerated possible values is probably never 65 | going to be a realistic possibility. 66 |

67 |

68 | 69 | See BCP 47 at 70 | http://www.rfc-editor.org/rfc/bcp/bcp47.txt 71 | and the IANA language subtag registry at 72 | 73 | http://www.iana.org/assignments/language-subtag-registry 74 | for further information. 75 |

76 |

77 | 78 | The union allows for the 'un-declaration' of xml:lang with 79 | the empty string. 80 |

81 |
82 |
83 |
84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 |
95 | 96 | 97 | 98 | 99 | 100 |
101 | 102 |

space (as an attribute name)

103 |

104 | denotes an attribute whose 105 | value is a keyword indicating what whitespace processing 106 | discipline is intended for the content of the element; its 107 | value is inherited. This name is reserved by virtue of its 108 | definition in the XML specification.

109 | 110 |
111 |
112 |
113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 |
121 | 122 | 123 | 124 | 125 |
126 | 127 |

base (as an attribute name)

128 |

129 | denotes an attribute whose value 130 | provides a URI to be used as the base for interpreting any 131 | relative URIs in the scope of the element on which it 132 | appears; its value is inherited. This name is reserved 133 | by virtue of its definition in the XML Base specification.

134 | 135 |

136 | See http://www.w3.org/TR/xmlbase/ 138 | for information about this attribute. 139 |

140 | 141 |
142 |
143 |
144 |
145 | 146 | 147 | 148 | 149 |
150 | 151 |

id (as an attribute name)

152 |

153 | 154 | denotes an attribute whose value 155 | should be interpreted as if declared to be of type ID. 156 | This name is reserved by virtue of its definition in the 157 | xml:id specification.

158 | 159 |

160 | See http://www.w3.org/TR/xml-id/ 162 | for information about this attribute. 163 |

164 |
165 |
166 |
167 | 168 |
169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 |
181 | 182 |

Father (in any context at all)

183 | 184 |
185 |

186 | denotes Jon Bosak, the chair of 187 | the original XML Working Group. This name is reserved by 188 | the following decision of the W3C XML Plenary and 189 | XML Coordination groups: 190 |

191 |
192 |

193 | 194 | In appreciation for his vision, leadership and 195 | dedication the W3C XML Plenary on this 10th day of 196 | February, 2000, reserves for Jon Bosak in perpetuity 197 | the XML name "xml:Father". 198 |

199 |
200 |
201 |
202 |
203 |
204 | 205 | 206 | 207 | 208 |
209 |

About this schema document

210 | 211 |
212 |

213 | This schema defines attributes and an attribute group suitable 214 | for use by schemas wishing to allow xml:base, 215 | xml:lang, xml:space or 216 | xml:id attributes on elements they define. 217 |

218 | 219 |

220 | To enable this, such a schema must import this schema for 221 | the XML namespace, e.g. as follows: 222 |

223 |
224 |           <schema.. .>
225 |           .. .
226 |            <import namespace="http://www.w3.org/XML/1998/namespace"
227 |                       schemaLocation="http://www.w3.org/2001/xml.xsd"/>
228 |      
229 |

230 | or 231 |

232 |
233 | 
234 |            <import namespace="http://www.w3.org/XML/1998/namespace"
235 |                       schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
236 |      
237 |

238 | Subsequently, qualified reference to any of the attributes or the 239 | group defined below will have the desired effect, e.g. 240 |

241 |
242 |           <type.. .>
243 |           .. .
244 |            <attributeGroup ref="xml:specialAttrs"/>
245 |      
246 |

247 | will define a type which will schema-validate an instance element 248 | with any of those attributes. 249 |

250 | 251 |
252 |
253 |
254 |
255 | 256 | 257 | 258 |
259 |

Versioning policy for this schema document

260 | 261 |
262 |

263 | In keeping with the XML Schema WG's standard versioning 264 | policy, this schema document will persist at 265 | 266 | http://www.w3.org/2009/01/xml.xsd. 267 |

268 |

269 | At the date of issue it can also be found at 270 | 271 | http://www.w3.org/2001/xml.xsd. 272 |

273 | 274 |

275 | The schema document at that URI may however change in the future, 276 | in order to remain compatible with the latest version of XML 277 | Schema itself, or with the XML namespace itself. In other words, 278 | if the XML Schema or XML namespaces change, the version of this 279 | document at 280 | http://www.w3.org/2001/xml.xsd 281 | 282 | will change accordingly; the version at 283 | 284 | http://www.w3.org/2009/01/xml.xsd 285 | 286 | will not change. 287 |

288 |

289 | 290 | Previous dated (and unchanging) versions of this schema 291 | document are at: 292 |

293 | 304 |
305 |
306 |
307 |
308 | 309 |
310 | --------------------------------------------------------------------------------