create-prisma-php-app 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +9 -0
- package/README.md +158 -0
- package/composer.json +23 -0
- package/composer.lock +812 -0
- package/dist/bootstrap.php +4 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/prisma-client-php/index.enc +1 -0
- package/dist/node_modules/prisma-client-php/index.js +2 -0
- package/dist/node_modules/prisma-client-php/key.enc +1 -0
- package/dist/node_modules/prisma-client-php/package.json +7 -0
- package/dist/prisma/schema.prisma +32 -0
- package/dist/prisma/seed.js +68 -0
- package/dist/public/assets/images/prisma-php.png +0 -0
- package/dist/public/css/styles.css +0 -0
- package/dist/public/css/tailwind.css +3 -0
- package/dist/public/favicon.ico +0 -0
- package/dist/public/index.php +64 -0
- package/dist/settings/paths.php +10 -0
- package/dist/settings/project-settings.js +6 -0
- package/dist/src/app/api/api.php +39 -0
- package/dist/src/app/classes/Validator.php +77 -0
- package/dist/src/app/model/IModel.php +22 -0
- package/package.json +35 -0
- package/tsconfig.json +110 -0
- package/vendor/autoload.php +25 -0
- package/vendor/brick/math/.editorconfig +15 -0
- package/vendor/brick/math/.gitattributes +11 -0
- package/vendor/brick/math/.github/FUNDING.yml +1 -0
- package/vendor/brick/math/.github/workflows/ci.yml +80 -0
- package/vendor/brick/math/CHANGELOG.md +445 -0
- package/vendor/brick/math/LICENSE +20 -0
- package/vendor/brick/math/README.md +247 -0
- package/vendor/brick/math/composer.json +34 -0
- package/vendor/brick/math/phpunit.php +51 -0
- package/vendor/brick/math/phpunit.xml +13 -0
- package/vendor/brick/math/psalm.xml +28 -0
- package/vendor/brick/math/random-tests.php +162 -0
- package/vendor/brick/math/src/BigDecimal.php +786 -0
- package/vendor/brick/math/src/BigInteger.php +1079 -0
- package/vendor/brick/math/src/BigNumber.php +512 -0
- package/vendor/brick/math/src/BigRational.php +445 -0
- package/vendor/brick/math/src/Exception/DivisionByZeroException.php +35 -0
- package/vendor/brick/math/src/Exception/IntegerOverflowException.php +23 -0
- package/vendor/brick/math/src/Exception/MathException.php +12 -0
- package/vendor/brick/math/src/Exception/NegativeNumberException.php +12 -0
- package/vendor/brick/math/src/Exception/NumberFormatException.php +33 -0
- package/vendor/brick/math/src/Exception/RoundingNecessaryException.php +19 -0
- package/vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php +75 -0
- package/vendor/brick/math/src/Internal/Calculator/GmpCalculator.php +108 -0
- package/vendor/brick/math/src/Internal/Calculator/NativeCalculator.php +581 -0
- package/vendor/brick/math/src/Internal/Calculator.php +676 -0
- package/vendor/brick/math/src/RoundingMode.php +107 -0
- package/vendor/brick/math/tests/AbstractTestCase.php +86 -0
- package/vendor/brick/math/tests/BigDecimalTest.php +2596 -0
- package/vendor/brick/math/tests/BigIntegerTest.php +3782 -0
- package/vendor/brick/math/tests/BigNumberTest.php +53 -0
- package/vendor/brick/math/tests/BigRationalTest.php +993 -0
- package/vendor/brick/math/tests/CalculatorDetectTest.php +25 -0
- package/vendor/brick/math/tests/Internal/Calculator/NativeCalculatorTest.php +87 -0
- package/vendor/composer/ClassLoader.php +579 -0
- package/vendor/composer/InstalledVersions.php +359 -0
- package/vendor/composer/LICENSE +21 -0
- package/vendor/composer/autoload_classmap.php +15 -0
- package/vendor/composer/autoload_files.php +13 -0
- package/vendor/composer/autoload_namespaces.php +9 -0
- package/vendor/composer/autoload_psr4.php +20 -0
- package/vendor/composer/autoload_real.php +50 -0
- package/vendor/composer/autoload_static.php +122 -0
- package/vendor/composer/installed.json +825 -0
- package/vendor/composer/installed.php +132 -0
- package/vendor/composer/platform_check.php +26 -0
- package/vendor/firebase/php-jwt/.gitattributes +9 -0
- package/vendor/firebase/php-jwt/.github/release-please.yml +3 -0
- package/vendor/firebase/php-jwt/.github/workflows/tests.yml +57 -0
- package/vendor/firebase/php-jwt/.php-cs-fixer.dist.php +24 -0
- package/vendor/firebase/php-jwt/CHANGELOG.md +170 -0
- package/vendor/firebase/php-jwt/LICENSE +30 -0
- package/vendor/firebase/php-jwt/README.md +424 -0
- package/vendor/firebase/php-jwt/composer.json +42 -0
- package/vendor/firebase/php-jwt/phpstan.neon.dist +5 -0
- package/vendor/firebase/php-jwt/phpunit.xml.dist +18 -0
- package/vendor/firebase/php-jwt/src/BeforeValidException.php +18 -0
- package/vendor/firebase/php-jwt/src/CachedKeySet.php +268 -0
- package/vendor/firebase/php-jwt/src/ExpiredException.php +18 -0
- package/vendor/firebase/php-jwt/src/JWK.php +349 -0
- package/vendor/firebase/php-jwt/src/JWT.php +669 -0
- package/vendor/firebase/php-jwt/src/JWTExceptionWithPayloadInterface.php +20 -0
- package/vendor/firebase/php-jwt/src/Key.php +64 -0
- package/vendor/firebase/php-jwt/src/SignatureInvalidException.php +7 -0
- package/vendor/firebase/php-jwt/tests/CachedKeySetTest.php +598 -0
- package/vendor/firebase/php-jwt/tests/JWKTest.php +172 -0
- package/vendor/firebase/php-jwt/tests/JWTTest.php +543 -0
- package/vendor/firebase/php-jwt/tests/data/ec-jwkset.json +40 -0
- package/vendor/firebase/php-jwt/tests/data/ecdsa-private.pem +18 -0
- package/vendor/firebase/php-jwt/tests/data/ecdsa-public.pem +9 -0
- package/vendor/firebase/php-jwt/tests/data/ecdsa256-private.pem +4 -0
- package/vendor/firebase/php-jwt/tests/data/ecdsa384-private.pem +6 -0
- package/vendor/firebase/php-jwt/tests/data/ecdsa384-public.pem +5 -0
- package/vendor/firebase/php-jwt/tests/data/ed25519-1.pub +1 -0
- package/vendor/firebase/php-jwt/tests/data/ed25519-1.sec +1 -0
- package/vendor/firebase/php-jwt/tests/data/ed25519-jwkset.json +11 -0
- package/vendor/firebase/php-jwt/tests/data/rsa-jwkset.json +18 -0
- package/vendor/firebase/php-jwt/tests/data/rsa-with-passphrase.pem +42 -0
- package/vendor/firebase/php-jwt/tests/data/rsa1-private.pem +27 -0
- package/vendor/firebase/php-jwt/tests/data/rsa1-public.pub +9 -0
- package/vendor/firebase/php-jwt/tests/data/rsa2-private.pem +27 -0
- package/vendor/firebase/php-jwt/tests/data/secp256k1-private.pem +5 -0
- package/vendor/firebase/php-jwt/tests/data/secp256k1-public.pem +4 -0
- package/vendor/graham-campbell/result-type/.gitattributes +9 -0
- package/vendor/graham-campbell/result-type/.github/CODE_OF_CONDUCT.md +132 -0
- package/vendor/graham-campbell/result-type/.github/CONTRIBUTING.md +31 -0
- package/vendor/graham-campbell/result-type/.github/FUNDING.yml +2 -0
- package/vendor/graham-campbell/result-type/.github/SECURITY.md +14 -0
- package/vendor/graham-campbell/result-type/.github/workflows/tests.yml +40 -0
- package/vendor/graham-campbell/result-type/CHANGELOG.md +43 -0
- package/vendor/graham-campbell/result-type/LICENSE +21 -0
- package/vendor/graham-campbell/result-type/README.md +42 -0
- package/vendor/graham-campbell/result-type/composer.json +33 -0
- package/vendor/graham-campbell/result-type/phpunit.xml.dist +13 -0
- package/vendor/graham-campbell/result-type/src/Error.php +121 -0
- package/vendor/graham-campbell/result-type/src/Result.php +69 -0
- package/vendor/graham-campbell/result-type/src/Success.php +120 -0
- package/vendor/graham-campbell/result-type/tests/ResultTest.php +95 -0
- package/vendor/hidehalo/nanoid-php/.editorconfig +15 -0
- package/vendor/hidehalo/nanoid-php/.gitattributes +8 -0
- package/vendor/hidehalo/nanoid-php/.github/workflows/php.yml +49 -0
- package/vendor/hidehalo/nanoid-php/.styleci.yml +1 -0
- package/vendor/hidehalo/nanoid-php/CHANGELOG.md +36 -0
- package/vendor/hidehalo/nanoid-php/CODE_OF_CONDUCT.md +74 -0
- package/vendor/hidehalo/nanoid-php/CONTRIBUTING.md +32 -0
- package/vendor/hidehalo/nanoid-php/ISSUE_TEMPLATE.md +27 -0
- package/vendor/hidehalo/nanoid-php/LICENSE.md +21 -0
- package/vendor/hidehalo/nanoid-php/PULL_REQUEST_TEMPLATE.md +43 -0
- package/vendor/hidehalo/nanoid-php/README.md +108 -0
- package/vendor/hidehalo/nanoid-php/benchmark/benchmark.php +24 -0
- package/vendor/hidehalo/nanoid-php/composer.json +62 -0
- package/vendor/hidehalo/nanoid-php/examples/basic_usage.php +24 -0
- package/vendor/hidehalo/nanoid-php/examples/custom_formated.php +29 -0
- package/vendor/hidehalo/nanoid-php/phpunit.xml +31 -0
- package/vendor/hidehalo/nanoid-php/src/Client.php +120 -0
- package/vendor/hidehalo/nanoid-php/src/Core.php +31 -0
- package/vendor/hidehalo/nanoid-php/src/CoreInterface.php +19 -0
- package/vendor/hidehalo/nanoid-php/src/Generator.php +13 -0
- package/vendor/hidehalo/nanoid-php/src/GeneratorInterface.php +13 -0
- package/vendor/hidehalo/nanoid-php/tests/ClientTest.php +76 -0
- package/vendor/hidehalo/nanoid-php/tests/CoreTest.php +37 -0
- package/vendor/hidehalo/nanoid-php/tests/GeneratorTest.php +34 -0
- package/vendor/hidehalo/nanoid-php/tests/Support/DummyGenerator.php +20 -0
- package/vendor/paragonie/random_compat/.gitattributes +14 -0
- package/vendor/paragonie/random_compat/.scrutinizer.yml +4 -0
- package/vendor/paragonie/random_compat/.travis.yml +59 -0
- package/vendor/paragonie/random_compat/CHANGELOG.md +3 -0
- package/vendor/paragonie/random_compat/LICENSE +22 -0
- package/vendor/paragonie/random_compat/RATIONALE.md +36 -0
- package/vendor/paragonie/random_compat/README.md +232 -0
- package/vendor/paragonie/random_compat/SECURITY.md +108 -0
- package/vendor/paragonie/random_compat/build-phar.sh +5 -0
- package/vendor/paragonie/random_compat/composer.json +34 -0
- package/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey +5 -0
- package/vendor/paragonie/random_compat/dist/random_compat.phar.pubkey.asc +11 -0
- package/vendor/paragonie/random_compat/lib/random.php +32 -0
- package/vendor/paragonie/random_compat/other/build_phar.php +57 -0
- package/vendor/paragonie/random_compat/other/ide_stubs/COM.php +20 -0
- package/vendor/paragonie/random_compat/other/ide_stubs/README.md +7 -0
- package/vendor/paragonie/random_compat/other/ide_stubs/com_exception.php +11 -0
- package/vendor/paragonie/random_compat/other/ide_stubs/libsodium.php +90 -0
- package/vendor/paragonie/random_compat/phpunit.sh +60 -0
- package/vendor/paragonie/random_compat/phpunit.xml.dist +31 -0
- package/vendor/paragonie/random_compat/psalm-autoload.php +9 -0
- package/vendor/paragonie/random_compat/psalm.xml +19 -0
- package/vendor/paragonie/random_compat/tests/full/DieHardTest.php +61 -0
- package/vendor/paragonie/random_compat/tests/full/StatTest.php +52 -0
- package/vendor/paragonie/random_compat/tests/specific/capicom.php +7 -0
- package/vendor/paragonie/random_compat/tests/specific/dev_urandom.php +7 -0
- package/vendor/paragonie/random_compat/tests/specific/libsodium.php +7 -0
- package/vendor/paragonie/random_compat/tests/specific/libsodium_legacy.php +7 -0
- package/vendor/paragonie/random_compat/tests/specific/mcrypt.php +7 -0
- package/vendor/paragonie/random_compat/tests/unit/RandomBytesTest.php +80 -0
- package/vendor/paragonie/random_compat/tests/unit/RandomIntTest.php +63 -0
- package/vendor/paragonie/random_compat/tests/unit/UtilityTest.php +95 -0
- package/vendor/paragonie/random_compat/tests/unit_with_basedir/RandomBytesTest.php +100 -0
- package/vendor/paragonie/random_compat/tests/unit_with_basedir/RandomIntTest.php +82 -0
- package/vendor/paragonie/random_compat/tests/unit_with_basedir/UtilityTest.php +95 -0
- package/vendor/phpoption/phpoption/.gitattributes +14 -0
- package/vendor/phpoption/phpoption/.github/CODE_OF_CONDUCT.md +132 -0
- package/vendor/phpoption/phpoption/.github/CONTRIBUTING.md +30 -0
- package/vendor/phpoption/phpoption/.github/FUNDING.yml +2 -0
- package/vendor/phpoption/phpoption/.github/SECURITY.md +14 -0
- package/vendor/phpoption/phpoption/.github/workflows/static.yml +74 -0
- package/vendor/phpoption/phpoption/.github/workflows/tests.yml +40 -0
- package/vendor/phpoption/phpoption/LICENSE +201 -0
- package/vendor/phpoption/phpoption/Makefile +26 -0
- package/vendor/phpoption/phpoption/README.md +194 -0
- package/vendor/phpoption/phpoption/composer.json +52 -0
- package/vendor/phpoption/phpoption/phpstan-baseline.neon +32 -0
- package/vendor/phpoption/phpoption/phpstan.neon.dist +8 -0
- package/vendor/phpoption/phpoption/phpunit.xml.dist +13 -0
- package/vendor/phpoption/phpoption/psalm.xml +12 -0
- package/vendor/phpoption/phpoption/src/PhpOption/LazyOption.php +175 -0
- package/vendor/phpoption/phpoption/src/PhpOption/None.php +136 -0
- package/vendor/phpoption/phpoption/src/PhpOption/Option.php +434 -0
- package/vendor/phpoption/phpoption/src/PhpOption/Some.php +169 -0
- package/vendor/phpoption/phpoption/tests/PhpOption/Tests/EnsureTest.php +77 -0
- package/vendor/phpoption/phpoption/tests/PhpOption/Tests/LazyOptionTest.php +200 -0
- package/vendor/phpoption/phpoption/tests/PhpOption/Tests/NoneTest.php +153 -0
- package/vendor/phpoption/phpoption/tests/PhpOption/Tests/OptionTest.php +160 -0
- package/vendor/phpoption/phpoption/tests/PhpOption/Tests/SomeTest.php +194 -0
- package/vendor/phpoption/phpoption/tests/bootstrap.php +8 -0
- package/vendor/phpoption/phpoption/vendor-bin/phpstan/composer.json +8 -0
- package/vendor/phpoption/phpoption/vendor-bin/psalm/composer.json +8 -0
- package/vendor/ramsey/uuid/.editorconfig +16 -0
- package/vendor/ramsey/uuid/.gitattributes +26 -0
- package/vendor/ramsey/uuid/.github/CODEOWNERS +1 -0
- package/vendor/ramsey/uuid/.github/FUNDING.yml +2 -0
- package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/Bug_Report.md +35 -0
- package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/Feature_Request.md +31 -0
- package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/Question.md +19 -0
- package/vendor/ramsey/uuid/.github/ISSUE_TEMPLATE/config.yml +1 -0
- package/vendor/ramsey/uuid/.github/dependabot.yml +15 -0
- package/vendor/ramsey/uuid/.github/pull_request_template.md +27 -0
- package/vendor/ramsey/uuid/.github/workflows/continuous-integration.yml +181 -0
- package/vendor/ramsey/uuid/.github/workflows/merge-dependabot-upgrades.yml +24 -0
- package/vendor/ramsey/uuid/.readthedocs.yml +11 -0
- package/vendor/ramsey/uuid/CHANGELOG.md +1511 -0
- package/vendor/ramsey/uuid/CODE_OF_CONDUCT.md +73 -0
- package/vendor/ramsey/uuid/CONTRIBUTING.md +171 -0
- package/vendor/ramsey/uuid/LICENSE +19 -0
- package/vendor/ramsey/uuid/README.md +83 -0
- package/vendor/ramsey/uuid/SECURITY.md +170 -0
- package/vendor/ramsey/uuid/build/.gitignore +6 -0
- package/vendor/ramsey/uuid/build/cache/.gitkeep +0 -0
- package/vendor/ramsey/uuid/build/logs/.gitkeep +0 -0
- package/vendor/ramsey/uuid/captainhook.json +105 -0
- package/vendor/ramsey/uuid/codecov.yml +29 -0
- package/vendor/ramsey/uuid/composer.json +106 -0
- package/vendor/ramsey/uuid/composer.lock +7208 -0
- package/vendor/ramsey/uuid/docs/Makefile +20 -0
- package/vendor/ramsey/uuid/docs/README.md +36 -0
- package/vendor/ramsey/uuid/docs/_static/.gitkeep +0 -0
- package/vendor/ramsey/uuid/docs/conf.py +103 -0
- package/vendor/ramsey/uuid/docs/copyright.rst +18 -0
- package/vendor/ramsey/uuid/docs/customize/calculators.rst +75 -0
- package/vendor/ramsey/uuid/docs/customize/factory.rst +93 -0
- package/vendor/ramsey/uuid/docs/customize/ordered-time-codec.rst +86 -0
- package/vendor/ramsey/uuid/docs/customize/timestamp-first-comb-codec.rst +72 -0
- package/vendor/ramsey/uuid/docs/customize/validators.rst +39 -0
- package/vendor/ramsey/uuid/docs/customize.rst +56 -0
- package/vendor/ramsey/uuid/docs/database.rst +260 -0
- package/vendor/ramsey/uuid/docs/faq.rst +132 -0
- package/vendor/ramsey/uuid/docs/index.rst +51 -0
- package/vendor/ramsey/uuid/docs/introduction.rst +31 -0
- package/vendor/ramsey/uuid/docs/nonstandard/guid.rst +152 -0
- package/vendor/ramsey/uuid/docs/nonstandard/other.rst +49 -0
- package/vendor/ramsey/uuid/docs/nonstandard/version6.rst +17 -0
- package/vendor/ramsey/uuid/docs/nonstandard.rst +40 -0
- package/vendor/ramsey/uuid/docs/quickstart.rst +112 -0
- package/vendor/ramsey/uuid/docs/reference/calculators.rst +168 -0
- package/vendor/ramsey/uuid/docs/reference/exceptions.rst +92 -0
- package/vendor/ramsey/uuid/docs/reference/fields-fieldsinterface.rst +16 -0
- package/vendor/ramsey/uuid/docs/reference/guid-fields.rst +13 -0
- package/vendor/ramsey/uuid/docs/reference/guid-guid.rst +20 -0
- package/vendor/ramsey/uuid/docs/reference/helper.rst +62 -0
- package/vendor/ramsey/uuid/docs/reference/name-based-namespaces.rst +31 -0
- package/vendor/ramsey/uuid/docs/reference/nonstandard-fields.rst +13 -0
- package/vendor/ramsey/uuid/docs/reference/nonstandard-uuid.rst +20 -0
- package/vendor/ramsey/uuid/docs/reference/nonstandard-uuidv6.rst +34 -0
- package/vendor/ramsey/uuid/docs/reference/rfc4122-fieldsinterface.rst +78 -0
- package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidinterface.rst +20 -0
- package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv1.rst +21 -0
- package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv2.rst +47 -0
- package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv3.rst +13 -0
- package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv4.rst +13 -0
- package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv5.rst +13 -0
- package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv6.rst +31 -0
- package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv7.rst +20 -0
- package/vendor/ramsey/uuid/docs/reference/rfc4122-uuidv8.rst +13 -0
- package/vendor/ramsey/uuid/docs/reference/rfc4122-version.rst +87 -0
- package/vendor/ramsey/uuid/docs/reference/timebaseduuidinterface.rst +16 -0
- package/vendor/ramsey/uuid/docs/reference/types.rst +79 -0
- package/vendor/ramsey/uuid/docs/reference/uuid.rst +161 -0
- package/vendor/ramsey/uuid/docs/reference/uuidfactoryinterface.rst +102 -0
- package/vendor/ramsey/uuid/docs/reference/uuidinterface.rst +60 -0
- package/vendor/ramsey/uuid/docs/reference/validators.rst +34 -0
- package/vendor/ramsey/uuid/docs/reference/variant.rst +32 -0
- package/vendor/ramsey/uuid/docs/reference.rst +37 -0
- package/vendor/ramsey/uuid/docs/requirements.txt +3 -0
- package/vendor/ramsey/uuid/docs/rfc4122/version1.rst +192 -0
- package/vendor/ramsey/uuid/docs/rfc4122/version2.rst +273 -0
- package/vendor/ramsey/uuid/docs/rfc4122/version3.rst +68 -0
- package/vendor/ramsey/uuid/docs/rfc4122/version4.rst +39 -0
- package/vendor/ramsey/uuid/docs/rfc4122/version5.rst +108 -0
- package/vendor/ramsey/uuid/docs/rfc4122/version6.rst +213 -0
- package/vendor/ramsey/uuid/docs/rfc4122/version7.rst +173 -0
- package/vendor/ramsey/uuid/docs/rfc4122/version8.rst +51 -0
- package/vendor/ramsey/uuid/docs/rfc4122.rst +67 -0
- package/vendor/ramsey/uuid/docs/testing.rst +199 -0
- package/vendor/ramsey/uuid/docs/tidelift.rst +74 -0
- package/vendor/ramsey/uuid/docs/upgrading/2-to-3.rst +31 -0
- package/vendor/ramsey/uuid/docs/upgrading/3-to-4.rst +512 -0
- package/vendor/ramsey/uuid/docs/upgrading.rst +11 -0
- package/vendor/ramsey/uuid/phpbench.json +10 -0
- package/vendor/ramsey/uuid/phpcs.xml.dist +476 -0
- package/vendor/ramsey/uuid/phpstan-tests.neon +32 -0
- package/vendor/ramsey/uuid/phpstan.neon.dist +25 -0
- package/vendor/ramsey/uuid/phpunit.xml.dist +26 -0
- package/vendor/ramsey/uuid/psalm-baseline.xml +133 -0
- package/vendor/ramsey/uuid/psalm.xml +25 -0
- package/vendor/ramsey/uuid/resources/vagrant/README.md +10 -0
- package/vendor/ramsey/uuid/resources/vagrant/freebsd/README.md +15 -0
- package/vendor/ramsey/uuid/resources/vagrant/freebsd/Vagrantfile +35 -0
- package/vendor/ramsey/uuid/resources/vagrant/linux/README.md +15 -0
- package/vendor/ramsey/uuid/resources/vagrant/linux/Vagrantfile +27 -0
- package/vendor/ramsey/uuid/resources/vagrant/windows/README.md +16 -0
- package/vendor/ramsey/uuid/resources/vagrant/windows/Vagrantfile +22 -0
- package/vendor/ramsey/uuid/src/BinaryUtils.php +106 -0
- package/vendor/ramsey/uuid/src/Builder/FallbackBuilder.php +68 -0
- package/vendor/ramsey/uuid/src/Builder/UuidBuilderInterface.php +39 -0
- package/vendor/ramsey/uuid/src/Codec/CodecInterface.php +67 -0
- package/vendor/ramsey/uuid/src/Codec/GuidStringCodec.php +82 -0
- package/vendor/ramsey/uuid/src/Codec/OrderedTimeCodec.php +114 -0
- package/vendor/ramsey/uuid/src/Codec/StringCodec.php +128 -0
- package/vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php +105 -0
- package/vendor/ramsey/uuid/src/Codec/TimestampLastCombCodec.php +51 -0
- package/vendor/ramsey/uuid/src/Converter/Number/GenericNumberConverter.php +48 -0
- package/vendor/ramsey/uuid/src/Converter/NumberConverterInterface.php +53 -0
- package/vendor/ramsey/uuid/src/Converter/Time/GenericTimeConverter.php +118 -0
- package/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php +163 -0
- package/vendor/ramsey/uuid/src/Converter/Time/UnixTimeConverter.php +90 -0
- package/vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php +58 -0
- package/vendor/ramsey/uuid/src/Exception/BuilderNotFoundException.php +24 -0
- package/vendor/ramsey/uuid/src/Exception/DateTimeException.php +24 -0
- package/vendor/ramsey/uuid/src/Exception/DceSecurityException.php +25 -0
- package/vendor/ramsey/uuid/src/Exception/InvalidArgumentException.php +24 -0
- package/vendor/ramsey/uuid/src/Exception/InvalidBytesException.php +24 -0
- package/vendor/ramsey/uuid/src/Exception/InvalidUuidStringException.php +25 -0
- package/vendor/ramsey/uuid/src/Exception/NameException.php +25 -0
- package/vendor/ramsey/uuid/src/Exception/NodeException.php +24 -0
- package/vendor/ramsey/uuid/src/Exception/RandomSourceException.php +27 -0
- package/vendor/ramsey/uuid/src/Exception/TimeSourceException.php +24 -0
- package/vendor/ramsey/uuid/src/Exception/UnableToBuildUuidException.php +24 -0
- package/vendor/ramsey/uuid/src/Exception/UnsupportedOperationException.php +24 -0
- package/vendor/ramsey/uuid/src/Exception/UuidExceptionInterface.php +21 -0
- package/vendor/ramsey/uuid/src/FeatureSet.php +395 -0
- package/vendor/ramsey/uuid/src/Fields/FieldsInterface.php +42 -0
- package/vendor/ramsey/uuid/src/Fields/SerializableFieldsTrait.php +70 -0
- package/vendor/ramsey/uuid/src/Generator/CombGenerator.php +124 -0
- package/vendor/ramsey/uuid/src/Generator/DceSecurityGenerator.php +139 -0
- package/vendor/ramsey/uuid/src/Generator/DceSecurityGeneratorInterface.php +53 -0
- package/vendor/ramsey/uuid/src/Generator/DefaultNameGenerator.php +51 -0
- package/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php +131 -0
- package/vendor/ramsey/uuid/src/Generator/NameGeneratorFactory.php +30 -0
- package/vendor/ramsey/uuid/src/Generator/NameGeneratorInterface.php +38 -0
- package/vendor/ramsey/uuid/src/Generator/PeclUuidNameGenerator.php +52 -0
- package/vendor/ramsey/uuid/src/Generator/PeclUuidRandomGenerator.php +37 -0
- package/vendor/ramsey/uuid/src/Generator/PeclUuidTimeGenerator.php +39 -0
- package/vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php +45 -0
- package/vendor/ramsey/uuid/src/Generator/RandomGeneratorFactory.php +30 -0
- package/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php +31 -0
- package/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php +45 -0
- package/vendor/ramsey/uuid/src/Generator/TimeGeneratorInterface.php +38 -0
- package/vendor/ramsey/uuid/src/Generator/UnixTimeGenerator.php +170 -0
- package/vendor/ramsey/uuid/src/Guid/Fields.php +208 -0
- package/vendor/ramsey/uuid/src/Guid/Guid.php +61 -0
- package/vendor/ramsey/uuid/src/Guid/GuidBuilder.php +79 -0
- package/vendor/ramsey/uuid/src/Lazy/LazyUuidFromString.php +226 -0
- package/vendor/ramsey/uuid/src/Math/BrickMathCalculator.php +145 -0
- package/vendor/ramsey/uuid/src/Math/CalculatorInterface.php +106 -0
- package/vendor/ramsey/uuid/src/Math/RoundingMode.php +146 -0
- package/vendor/ramsey/uuid/src/Nonstandard/Fields.php +154 -0
- package/vendor/ramsey/uuid/src/Nonstandard/Uuid.php +37 -0
- package/vendor/ramsey/uuid/src/Nonstandard/UuidBuilder.php +78 -0
- package/vendor/ramsey/uuid/src/Nonstandard/UuidV6.php +113 -0
- package/vendor/ramsey/uuid/src/Provider/Dce/SystemDceSecurityProvider.php +236 -0
- package/vendor/ramsey/uuid/src/Provider/DceSecurityProviderInterface.php +41 -0
- package/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php +54 -0
- package/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php +69 -0
- package/vendor/ramsey/uuid/src/Provider/Node/StaticNodeProvider.php +74 -0
- package/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php +190 -0
- package/vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php +30 -0
- package/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php +57 -0
- package/vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php +33 -0
- package/vendor/ramsey/uuid/src/Provider/TimeProviderInterface.php +28 -0
- package/vendor/ramsey/uuid/src/Rfc4122/Fields.php +214 -0
- package/vendor/ramsey/uuid/src/Rfc4122/FieldsInterface.php +129 -0
- package/vendor/ramsey/uuid/src/Rfc4122/MaxTrait.php +41 -0
- package/vendor/ramsey/uuid/src/Rfc4122/MaxUuid.php +27 -0
- package/vendor/ramsey/uuid/src/Rfc4122/NilTrait.php +41 -0
- package/vendor/ramsey/uuid/src/Rfc4122/NilUuid.php +27 -0
- package/vendor/ramsey/uuid/src/Rfc4122/TimeTrait.php +55 -0
- package/vendor/ramsey/uuid/src/Rfc4122/UuidBuilder.php +116 -0
- package/vendor/ramsey/uuid/src/Rfc4122/UuidInterface.php +30 -0
- package/vendor/ramsey/uuid/src/Rfc4122/UuidV1.php +61 -0
- package/vendor/ramsey/uuid/src/Rfc4122/UuidV2.php +119 -0
- package/vendor/ramsey/uuid/src/Rfc4122/UuidV3.php +58 -0
- package/vendor/ramsey/uuid/src/Rfc4122/UuidV4.php +58 -0
- package/vendor/ramsey/uuid/src/Rfc4122/UuidV5.php +58 -0
- package/vendor/ramsey/uuid/src/Rfc4122/UuidV6.php +30 -0
- package/vendor/ramsey/uuid/src/Rfc4122/UuidV7.php +63 -0
- package/vendor/ramsey/uuid/src/Rfc4122/UuidV8.php +65 -0
- package/vendor/ramsey/uuid/src/Rfc4122/Validator.php +45 -0
- package/vendor/ramsey/uuid/src/Rfc4122/VariantTrait.php +87 -0
- package/vendor/ramsey/uuid/src/Rfc4122/Version.php +139 -0
- package/vendor/ramsey/uuid/src/Rfc4122/VersionTrait.php +57 -0
- package/vendor/ramsey/uuid/src/TimeBasedUuidFactoryInterface.php +48 -0
- package/vendor/ramsey/uuid/src/TimeBasedUuidInterface.php +30 -0
- package/vendor/ramsey/uuid/src/Type/Decimal.php +135 -0
- package/vendor/ramsey/uuid/src/Type/Hexadecimal.php +109 -0
- package/vendor/ramsey/uuid/src/Type/Integer.php +145 -0
- package/vendor/ramsey/uuid/src/Type/NumberInterface.php +28 -0
- package/vendor/ramsey/uuid/src/Type/Time.php +108 -0
- package/vendor/ramsey/uuid/src/Type/TypeInterface.php +45 -0
- package/vendor/ramsey/uuid/src/Uuid.php +645 -0
- package/vendor/ramsey/uuid/src/UuidFactory.php +503 -0
- package/vendor/ramsey/uuid/src/UuidFactoryInterface.php +184 -0
- package/vendor/ramsey/uuid/src/UuidInterface.php +114 -0
- package/vendor/ramsey/uuid/src/Validator/GenericValidator.php +45 -0
- package/vendor/ramsey/uuid/src/Validator/ValidatorInterface.php +39 -0
- package/vendor/ramsey/uuid/src/Variant.php +60 -0
- package/vendor/ramsey/uuid/src/functions.php +160 -0
- package/vendor/ramsey/uuid/tests/BinaryUtilsTest.php +381 -0
- package/vendor/ramsey/uuid/tests/Builder/FallbackBuilderTest.php +198 -0
- package/vendor/ramsey/uuid/tests/Codec/GuidStringCodecTest.php +118 -0
- package/vendor/ramsey/uuid/tests/Codec/OrderedTimeCodecTest.php +258 -0
- package/vendor/ramsey/uuid/tests/Codec/StringCodecTest.php +149 -0
- package/vendor/ramsey/uuid/tests/Converter/Number/GenericNumberConverterTest.php +28 -0
- package/vendor/ramsey/uuid/tests/Converter/Time/GenericTimeConverterTest.php +147 -0
- package/vendor/ramsey/uuid/tests/Converter/Time/PhpTimeConverterTest.php +199 -0
- package/vendor/ramsey/uuid/tests/Converter/Time/UnixTimeConverterTest.php +202 -0
- package/vendor/ramsey/uuid/tests/Encoder/TimestampFirstCombCodecTest.php +105 -0
- package/vendor/ramsey/uuid/tests/Encoder/TimestampLastCombCodecTest.php +106 -0
- package/vendor/ramsey/uuid/tests/ExpectedBehaviorTest.php +573 -0
- package/vendor/ramsey/uuid/tests/FeatureSetTest.php +88 -0
- package/vendor/ramsey/uuid/tests/FunctionsTest.php +151 -0
- package/vendor/ramsey/uuid/tests/Generator/CombGeneratorTest.php +134 -0
- package/vendor/ramsey/uuid/tests/Generator/DceSecurityGeneratorTest.php +282 -0
- package/vendor/ramsey/uuid/tests/Generator/DefaultNameGeneratorTest.php +83 -0
- package/vendor/ramsey/uuid/tests/Generator/DefaultTimeGeneratorTest.php +202 -0
- package/vendor/ramsey/uuid/tests/Generator/NameGeneratorFactoryTest.php +19 -0
- package/vendor/ramsey/uuid/tests/Generator/PeclUuidNameGeneratorTest.php +107 -0
- package/vendor/ramsey/uuid/tests/Generator/PeclUuidRandomGeneratorTest.php +30 -0
- package/vendor/ramsey/uuid/tests/Generator/PeclUuidTimeGeneratorTest.php +30 -0
- package/vendor/ramsey/uuid/tests/Generator/RandomBytesGeneratorTest.php +70 -0
- package/vendor/ramsey/uuid/tests/Generator/RandomGeneratorFactoryTest.php +19 -0
- package/vendor/ramsey/uuid/tests/Generator/TimeGeneratorFactoryTest.php +33 -0
- package/vendor/ramsey/uuid/tests/Generator/UnixTimeGeneratorTest.php +204 -0
- package/vendor/ramsey/uuid/tests/Guid/FieldsTest.php +235 -0
- package/vendor/ramsey/uuid/tests/Guid/GuidBuilderTest.php +33 -0
- package/vendor/ramsey/uuid/tests/Math/BrickMathCalculatorTest.php +116 -0
- package/vendor/ramsey/uuid/tests/Nonstandard/FieldsTest.php +84 -0
- package/vendor/ramsey/uuid/tests/Nonstandard/UuidBuilderTest.php +33 -0
- package/vendor/ramsey/uuid/tests/Nonstandard/UuidV6Test.php +192 -0
- package/vendor/ramsey/uuid/tests/Provider/Dce/SystemDceSecurityProviderTest.php +505 -0
- package/vendor/ramsey/uuid/tests/Provider/Node/FallbackNodeProviderTest.php +87 -0
- package/vendor/ramsey/uuid/tests/Provider/Node/RandomNodeProviderTest.php +124 -0
- package/vendor/ramsey/uuid/tests/Provider/Node/StaticNodeProviderTest.php +58 -0
- package/vendor/ramsey/uuid/tests/Provider/Node/SystemNodeProviderTest.php +950 -0
- package/vendor/ramsey/uuid/tests/Provider/Time/FixedTimeProviderTest.php +41 -0
- package/vendor/ramsey/uuid/tests/Provider/Time/SystemTimeProviderTest.php +20 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/FieldsTest.php +260 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/UuidBuilderTest.php +145 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/UuidV1Test.php +123 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/UuidV2Test.php +214 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/UuidV3Test.php +56 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/UuidV4Test.php +56 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/UuidV5Test.php +56 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/UuidV6Test.php +221 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/UuidV7Test.php +131 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/UuidV8Test.php +56 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/ValidatorTest.php +122 -0
- package/vendor/ramsey/uuid/tests/Rfc4122/VariantTraitTest.php +109 -0
- package/vendor/ramsey/uuid/tests/TestCase.php +29 -0
- package/vendor/ramsey/uuid/tests/Type/DecimalTest.php +305 -0
- package/vendor/ramsey/uuid/tests/Type/HexadecimalTest.php +112 -0
- package/vendor/ramsey/uuid/tests/Type/IntegerTest.php +235 -0
- package/vendor/ramsey/uuid/tests/Type/TimeTest.php +120 -0
- package/vendor/ramsey/uuid/tests/UuidFactoryTest.php +233 -0
- package/vendor/ramsey/uuid/tests/UuidTest.php +1910 -0
- package/vendor/ramsey/uuid/tests/Validator/GenericValidatorTest.php +98 -0
- package/vendor/ramsey/uuid/tests/benchmark/GuidConversionBench.php +43 -0
- package/vendor/ramsey/uuid/tests/benchmark/NonLazyUuidConversionBench.php +39 -0
- package/vendor/ramsey/uuid/tests/benchmark/UuidFieldExtractionBench.php +86 -0
- package/vendor/ramsey/uuid/tests/benchmark/UuidGenerationBench.php +113 -0
- package/vendor/ramsey/uuid/tests/benchmark/UuidSerializationBench.php +206 -0
- package/vendor/ramsey/uuid/tests/benchmark/UuidStringConversionBench.php +257 -0
- package/vendor/ramsey/uuid/tests/bootstrap.php +12 -0
- package/vendor/ramsey/uuid/tests/static-analysis/UuidIsImmutable.php +96 -0
- package/vendor/ramsey/uuid/tests/static-analysis/UuidIsNeverEmpty.php +36 -0
- package/vendor/ramsey/uuid/tests/static-analysis/ValidUuidIsNonEmpty.php +44 -0
- package/vendor/ramsey/uuid/tests/static-analysis/stubs.php +33 -0
- package/vendor/symfony/polyfill-ctype/Ctype.php +232 -0
- package/vendor/symfony/polyfill-ctype/LICENSE +19 -0
- package/vendor/symfony/polyfill-ctype/README.md +12 -0
- package/vendor/symfony/polyfill-ctype/bootstrap.php +50 -0
- package/vendor/symfony/polyfill-ctype/bootstrap80.php +46 -0
- package/vendor/symfony/polyfill-ctype/composer.json +41 -0
- package/vendor/symfony/polyfill-mbstring/LICENSE +19 -0
- package/vendor/symfony/polyfill-mbstring/Mbstring.php +947 -0
- package/vendor/symfony/polyfill-mbstring/README.md +13 -0
- package/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php +119 -0
- package/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +1397 -0
- package/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php +5 -0
- package/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php +1489 -0
- package/vendor/symfony/polyfill-mbstring/bootstrap.php +151 -0
- package/vendor/symfony/polyfill-mbstring/bootstrap80.php +147 -0
- package/vendor/symfony/polyfill-mbstring/composer.json +41 -0
- package/vendor/symfony/polyfill-php80/LICENSE +19 -0
- package/vendor/symfony/polyfill-php80/Php80.php +115 -0
- package/vendor/symfony/polyfill-php80/PhpToken.php +103 -0
- package/vendor/symfony/polyfill-php80/README.md +25 -0
- package/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php +31 -0
- package/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php +16 -0
- package/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php +20 -0
- package/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php +16 -0
- package/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php +16 -0
- package/vendor/symfony/polyfill-php80/bootstrap.php +42 -0
- package/vendor/symfony/polyfill-php80/composer.json +40 -0
- package/vendor/vlucas/phpdotenv/.editorconfig +15 -0
- package/vendor/vlucas/phpdotenv/.gitattributes +17 -0
- package/vendor/vlucas/phpdotenv/.github/CODE_OF_CONDUCT.md +132 -0
- package/vendor/vlucas/phpdotenv/.github/CONTRIBUTING.md +30 -0
- package/vendor/vlucas/phpdotenv/.github/FUNDING.yml +2 -0
- package/vendor/vlucas/phpdotenv/.github/SECURITY.md +14 -0
- package/vendor/vlucas/phpdotenv/.github/workflows/static.yml +74 -0
- package/vendor/vlucas/phpdotenv/.github/workflows/tests.yml +70 -0
- package/vendor/vlucas/phpdotenv/LICENSE +30 -0
- package/vendor/vlucas/phpdotenv/Makefile +26 -0
- package/vendor/vlucas/phpdotenv/README.md +363 -0
- package/vendor/vlucas/phpdotenv/UPGRADING.md +196 -0
- package/vendor/vlucas/phpdotenv/composer.json +60 -0
- package/vendor/vlucas/phpdotenv/phpstan-baseline.neon +21 -0
- package/vendor/vlucas/phpdotenv/phpstan.neon.dist +7 -0
- package/vendor/vlucas/phpdotenv/phpunit.xml.dist +13 -0
- package/vendor/vlucas/phpdotenv/psalm-baseline.xml +28 -0
- package/vendor/vlucas/phpdotenv/psalm.xml +13 -0
- package/vendor/vlucas/phpdotenv/src/Dotenv.php +267 -0
- package/vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php +12 -0
- package/vendor/vlucas/phpdotenv/src/Exception/InvalidEncodingException.php +12 -0
- package/vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php +12 -0
- package/vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php +12 -0
- package/vendor/vlucas/phpdotenv/src/Exception/ValidationException.php +12 -0
- package/vendor/vlucas/phpdotenv/src/Loader/Loader.php +47 -0
- package/vendor/vlucas/phpdotenv/src/Loader/LoaderInterface.php +20 -0
- package/vendor/vlucas/phpdotenv/src/Loader/Resolver.php +65 -0
- package/vendor/vlucas/phpdotenv/src/Parser/Entry.php +59 -0
- package/vendor/vlucas/phpdotenv/src/Parser/EntryParser.php +300 -0
- package/vendor/vlucas/phpdotenv/src/Parser/Lexer.php +58 -0
- package/vendor/vlucas/phpdotenv/src/Parser/Lines.php +127 -0
- package/vendor/vlucas/phpdotenv/src/Parser/Parser.php +53 -0
- package/vendor/vlucas/phpdotenv/src/Parser/ParserInterface.php +19 -0
- package/vendor/vlucas/phpdotenv/src/Parser/Value.php +88 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/AdapterInterface.php +15 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php +89 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php +80 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php +89 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/GuardedWriter.php +85 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ImmutableWriter.php +110 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiReader.php +48 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiWriter.php +64 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php +91 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php +17 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReplacingWriter.php +104 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php +89 -0
- package/vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php +27 -0
- package/vendor/vlucas/phpdotenv/src/Repository/AdapterRepository.php +107 -0
- package/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php +272 -0
- package/vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php +51 -0
- package/vendor/vlucas/phpdotenv/src/Store/File/Paths.php +44 -0
- package/vendor/vlucas/phpdotenv/src/Store/File/Reader.php +81 -0
- package/vendor/vlucas/phpdotenv/src/Store/FileStore.php +72 -0
- package/vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php +141 -0
- package/vendor/vlucas/phpdotenv/src/Store/StoreInterface.php +17 -0
- package/vendor/vlucas/phpdotenv/src/Store/StringStore.php +37 -0
- package/vendor/vlucas/phpdotenv/src/Util/Regex.php +112 -0
- package/vendor/vlucas/phpdotenv/src/Util/Str.php +98 -0
- package/vendor/vlucas/phpdotenv/src/Validator.php +209 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/DotenvTest.php +387 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/Loader/LoaderTest.php +86 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/EntryParserTest.php +234 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LexerTest.php +40 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LinesTest.php +53 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/ParserTest.php +98 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ArrayAdapterTest.php +57 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/EnvConstAdapterTest.php +75 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/PutenvAdapterTest.php +52 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ServerConstAdapterTest.php +75 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/RepositoryTest.php +305 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/Store/StoreTest.php +141 -0
- package/vendor/vlucas/phpdotenv/tests/Dotenv/ValidatorTest.php +479 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/.env +5 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/assertions.env +18 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/booleans.env +33 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/commented.env +15 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/empty.env +1 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/example.env +1 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/exported.env +7 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/immutable.env +1 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/integers.env +17 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/large.env +2 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/multibyte.env +3 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/multiline.env +14 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/multiple.env +4 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/mutable.env +1 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/nested.env +15 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/quoted.env +11 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/specialchars.env +8 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/unicodevarnames.env +2 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/utf8-with-bom-encoding.env +3 -0
- package/vendor/vlucas/phpdotenv/tests/fixtures/env/windows.env +1 -0
- package/vendor/vlucas/phpdotenv/vendor-bin/phpstan/composer.json +16 -0
- package/vendor/vlucas/phpdotenv/vendor-bin/psalm/composer.json +9 -0
|
@@ -0,0 +1,1910 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
namespace Ramsey\Uuid\Test;
|
|
6
|
+
|
|
7
|
+
use BadMethodCallException;
|
|
8
|
+
use Brick\Math\BigDecimal;
|
|
9
|
+
use Brick\Math\RoundingMode;
|
|
10
|
+
use DateTimeImmutable;
|
|
11
|
+
use DateTimeInterface;
|
|
12
|
+
use Mockery;
|
|
13
|
+
use Mockery\MockInterface;
|
|
14
|
+
use PHPUnit\Framework\MockObject\MockObject;
|
|
15
|
+
use Ramsey\Uuid\Codec\StringCodec;
|
|
16
|
+
use Ramsey\Uuid\Codec\TimestampFirstCombCodec;
|
|
17
|
+
use Ramsey\Uuid\Codec\TimestampLastCombCodec;
|
|
18
|
+
use Ramsey\Uuid\Converter\Number\GenericNumberConverter;
|
|
19
|
+
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
|
20
|
+
use Ramsey\Uuid\Exception\DateTimeException;
|
|
21
|
+
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
|
22
|
+
use Ramsey\Uuid\Exception\InvalidUuidStringException;
|
|
23
|
+
use Ramsey\Uuid\Exception\UnsupportedOperationException;
|
|
24
|
+
use Ramsey\Uuid\FeatureSet;
|
|
25
|
+
use Ramsey\Uuid\Generator\CombGenerator;
|
|
26
|
+
use Ramsey\Uuid\Generator\RandomGeneratorFactory;
|
|
27
|
+
use Ramsey\Uuid\Generator\RandomGeneratorInterface;
|
|
28
|
+
use Ramsey\Uuid\Guid\Guid;
|
|
29
|
+
use Ramsey\Uuid\Lazy\LazyUuidFromString;
|
|
30
|
+
use Ramsey\Uuid\Math\BrickMathCalculator;
|
|
31
|
+
use Ramsey\Uuid\Nonstandard\UuidV6;
|
|
32
|
+
use Ramsey\Uuid\Provider\Node\RandomNodeProvider;
|
|
33
|
+
use Ramsey\Uuid\Provider\Time\FixedTimeProvider;
|
|
34
|
+
use Ramsey\Uuid\Rfc4122\Fields;
|
|
35
|
+
use Ramsey\Uuid\Rfc4122\FieldsInterface;
|
|
36
|
+
use Ramsey\Uuid\Rfc4122\UuidBuilder;
|
|
37
|
+
use Ramsey\Uuid\Rfc4122\UuidV1;
|
|
38
|
+
use Ramsey\Uuid\Rfc4122\UuidV7;
|
|
39
|
+
use Ramsey\Uuid\Rfc4122\UuidV8;
|
|
40
|
+
use Ramsey\Uuid\Rfc4122\Version;
|
|
41
|
+
use Ramsey\Uuid\Type\Hexadecimal;
|
|
42
|
+
use Ramsey\Uuid\Type\Time;
|
|
43
|
+
use Ramsey\Uuid\Uuid;
|
|
44
|
+
use Ramsey\Uuid\UuidFactory;
|
|
45
|
+
use Ramsey\Uuid\UuidFactoryInterface;
|
|
46
|
+
use Ramsey\Uuid\UuidInterface;
|
|
47
|
+
use Ramsey\Uuid\Validator\GenericValidator;
|
|
48
|
+
use Ramsey\Uuid\Validator\ValidatorInterface;
|
|
49
|
+
use Ramsey\Uuid\Variant;
|
|
50
|
+
use Stringable;
|
|
51
|
+
use stdClass;
|
|
52
|
+
|
|
53
|
+
use function base64_decode;
|
|
54
|
+
use function base64_encode;
|
|
55
|
+
use function gmdate;
|
|
56
|
+
use function hex2bin;
|
|
57
|
+
use function json_encode;
|
|
58
|
+
use function serialize;
|
|
59
|
+
use function str_pad;
|
|
60
|
+
use function strlen;
|
|
61
|
+
use function strtotime;
|
|
62
|
+
use function strtoupper;
|
|
63
|
+
use function substr;
|
|
64
|
+
use function uniqid;
|
|
65
|
+
use function unserialize;
|
|
66
|
+
use function usleep;
|
|
67
|
+
|
|
68
|
+
class UuidTest extends TestCase
|
|
69
|
+
{
|
|
70
|
+
protected function setUp(): void
|
|
71
|
+
{
|
|
72
|
+
Uuid::setFactory(new UuidFactory());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public function testFromString(): void
|
|
76
|
+
{
|
|
77
|
+
$this->assertSame(
|
|
78
|
+
'ff6f8cb0-c57d-11e1-9b21-0800200c9a66',
|
|
79
|
+
Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66')
|
|
80
|
+
->toString()
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public function testFromHexadecimal(): void
|
|
85
|
+
{
|
|
86
|
+
$hex = new Hexadecimal('0x1EA78DEB37CE625E8F1A025041000001');
|
|
87
|
+
$uuid = Uuid::fromHexadecimal($hex);
|
|
88
|
+
$this->assertInstanceOf(Uuid::class, $uuid);
|
|
89
|
+
$this->assertEquals('1ea78deb-37ce-625e-8f1a-025041000001', $uuid->toString());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public function testFromHexadecimalShort(): void
|
|
93
|
+
{
|
|
94
|
+
$hex = new Hexadecimal('0x1EA78DEB37CE625E8F1A0250410000');
|
|
95
|
+
|
|
96
|
+
$this->expectException(InvalidUuidStringException::class);
|
|
97
|
+
$this->expectExceptionMessage('Invalid UUID string:');
|
|
98
|
+
|
|
99
|
+
Uuid::fromHexadecimal($hex);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public function testFromHexadecimalThrowsWhenMethodDoesNotExist(): void
|
|
103
|
+
{
|
|
104
|
+
$factory = Mockery::mock(UuidFactoryInterface::class);
|
|
105
|
+
Uuid::setFactory($factory);
|
|
106
|
+
|
|
107
|
+
$hex = new Hexadecimal('0x1EA78DEB37CE625E8F1A025041000001');
|
|
108
|
+
|
|
109
|
+
$this->expectException(BadMethodCallException::class);
|
|
110
|
+
$this->expectExceptionMessage('The method fromHexadecimal() does not exist on the provided factory');
|
|
111
|
+
|
|
112
|
+
Uuid::fromHexadecimal($hex);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Tests that UUID and GUID's have the same textual representation but not
|
|
117
|
+
* the same binary representation.
|
|
118
|
+
*/
|
|
119
|
+
public function testFromGuidString(): void
|
|
120
|
+
{
|
|
121
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
122
|
+
|
|
123
|
+
Uuid::setFactory(new UuidFactory(new FeatureSet(true)));
|
|
124
|
+
|
|
125
|
+
$guid = Guid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
126
|
+
|
|
127
|
+
// UUID's and GUID's share the same textual representation.
|
|
128
|
+
$this->assertSame($uuid->toString(), $guid->toString());
|
|
129
|
+
|
|
130
|
+
// But not the same binary representation.
|
|
131
|
+
$this->assertNotSame($uuid->getBytes(), $guid->getBytes());
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public function testFromStringWithCurlyBraces(): void
|
|
135
|
+
{
|
|
136
|
+
$uuid = Uuid::fromString('{ff6f8cb0-c57d-11e1-9b21-0800200c9a66}');
|
|
137
|
+
$this->assertSame('ff6f8cb0-c57d-11e1-9b21-0800200c9a66', $uuid->toString());
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public function testFromStringWithInvalidUuidString(): void
|
|
141
|
+
{
|
|
142
|
+
$this->expectException(InvalidUuidStringException::class);
|
|
143
|
+
$this->expectExceptionMessage('Invalid UUID string:');
|
|
144
|
+
|
|
145
|
+
Uuid::fromString('ff6f8cb0-c57d-11e1-9b21');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public function testFromStringWithLeadingNewLine(): void
|
|
149
|
+
{
|
|
150
|
+
$this->expectException(InvalidUuidStringException::class);
|
|
151
|
+
$this->expectExceptionMessage('Invalid UUID string:');
|
|
152
|
+
|
|
153
|
+
Uuid::fromString("\nd0d5f586-21d1-470c-8088-55c8857728dc");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public function testFromStringWithTrailingNewLine(): void
|
|
157
|
+
{
|
|
158
|
+
$this->expectException(InvalidUuidStringException::class);
|
|
159
|
+
$this->expectExceptionMessage('Invalid UUID string:');
|
|
160
|
+
|
|
161
|
+
Uuid::fromString("d0d5f586-21d1-470c-8088-55c8857728dc\n");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public function testFromStringWithUrn(): void
|
|
165
|
+
{
|
|
166
|
+
$uuid = Uuid::fromString('urn:uuid:ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
167
|
+
$this->assertSame('ff6f8cb0-c57d-11e1-9b21-0800200c9a66', $uuid->toString());
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public function testFromStringWithEmptyString(): void
|
|
171
|
+
{
|
|
172
|
+
$this->expectException(InvalidUuidStringException::class);
|
|
173
|
+
$this->expectExceptionMessage('Invalid UUID string: ');
|
|
174
|
+
|
|
175
|
+
/** @phpstan-ignore-next-line */
|
|
176
|
+
Uuid::fromString('');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public function testFromStringUppercase(): void
|
|
180
|
+
{
|
|
181
|
+
$uuid = Uuid::fromString('FF6F8CB0-C57D-11E1-9B21-0800200C9A66');
|
|
182
|
+
$this->assertSame('ff6f8cb0-c57d-11e1-9b21-0800200c9a66', $uuid->toString());
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
public function testFromStringLazyUuidFromUppercase(): void
|
|
186
|
+
{
|
|
187
|
+
$this->assertInstanceOf(LazyUuidFromString::class, Uuid::fromString('FF6F8CB0-C57D-11E1-9B21-0800200C9A66'));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public function testFromStringWithNilUuid(): void
|
|
191
|
+
{
|
|
192
|
+
$uuid = Uuid::fromString(Uuid::NIL);
|
|
193
|
+
|
|
194
|
+
/** @var Fields $fields */
|
|
195
|
+
$fields = $uuid->getFields();
|
|
196
|
+
|
|
197
|
+
$this->assertSame('00000000-0000-0000-0000-000000000000', $uuid->toString());
|
|
198
|
+
$this->assertTrue($fields->isNil());
|
|
199
|
+
$this->assertFalse($fields->isMax());
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public function testFromStringWithMaxUuid(): void
|
|
203
|
+
{
|
|
204
|
+
$uuid = Uuid::fromString(Uuid::MAX);
|
|
205
|
+
|
|
206
|
+
/** @var Fields $fields */
|
|
207
|
+
$fields = $uuid->getFields();
|
|
208
|
+
|
|
209
|
+
$this->assertSame('ffffffff-ffff-ffff-ffff-ffffffffffff', $uuid->toString());
|
|
210
|
+
$this->assertFalse($fields->isNil());
|
|
211
|
+
$this->assertTrue($fields->isMax());
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public function testGetBytes(): void
|
|
215
|
+
{
|
|
216
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
217
|
+
$this->assertSame(16, strlen($uuid->getBytes()));
|
|
218
|
+
$this->assertSame('/2+MsMV9EeGbIQgAIAyaZg==', base64_encode($uuid->getBytes()));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public function testGetClockSeqHiAndReservedHex(): void
|
|
222
|
+
{
|
|
223
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
224
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
225
|
+
$this->assertSame('9b', $uuid->getFields()->getClockSeqHiAndReserved()->toString());
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
public function testGetClockSeqLowHex(): void
|
|
229
|
+
{
|
|
230
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
231
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
232
|
+
$this->assertSame('21', $uuid->getFields()->getClockSeqLow()->toString());
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
public function testGetClockSequenceHex(): void
|
|
236
|
+
{
|
|
237
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
238
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
239
|
+
$this->assertSame('1b21', $uuid->getFields()->getClockSeq()->toString());
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
public function testGetDateTime(): void
|
|
243
|
+
{
|
|
244
|
+
// Check a recent date
|
|
245
|
+
/** @var UuidV1 $uuid */
|
|
246
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
247
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
248
|
+
$this->assertSame('2012-07-04T02:14:34+00:00', $uuid->getDateTime()->format('c'));
|
|
249
|
+
$this->assertSame('1341368074.491000', $uuid->getDateTime()->format('U.u'));
|
|
250
|
+
|
|
251
|
+
// Check an old date
|
|
252
|
+
/** @var UuidV1 $uuid */
|
|
253
|
+
$uuid = Uuid::fromString('0901e600-0154-1000-9b21-0800200c9a66');
|
|
254
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
255
|
+
$this->assertSame('1582-10-16T16:34:04+00:00', $uuid->getDateTime()->format('c'));
|
|
256
|
+
$this->assertSame('-12219146756.000000', $uuid->getDateTime()->format('U.u'));
|
|
257
|
+
|
|
258
|
+
// Check a future date
|
|
259
|
+
/** @var UuidV1 $uuid */
|
|
260
|
+
$uuid = Uuid::fromString('ff9785f6-ffff-1fff-9669-00007ffffffe');
|
|
261
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
262
|
+
$this->assertSame('5236-03-31T21:20:59+00:00', $uuid->getDateTime()->format('c'));
|
|
263
|
+
$this->assertSame('103072857659.999999', $uuid->getDateTime()->format('U.u'));
|
|
264
|
+
|
|
265
|
+
// Check the last possible time supported by v1 UUIDs
|
|
266
|
+
// See inline comments in
|
|
267
|
+
// {@see \Ramsey\Uuid\Test\Converter\Time\GenericTimeConverterTest::provideCalculateTime()}
|
|
268
|
+
/** @var UuidV1 $uuid */
|
|
269
|
+
$uuid = Uuid::fromString('fffffffa-ffff-1fff-8b1e-acde48001122');
|
|
270
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
271
|
+
$this->assertSame('5236-03-31T21:21:00+00:00', $uuid->getDateTime()->format('c'));
|
|
272
|
+
$this->assertSame('103072857660.684697', $uuid->getDateTime()->format('U.u'));
|
|
273
|
+
|
|
274
|
+
// Check the oldest date
|
|
275
|
+
/** @var UuidV1 $uuid */
|
|
276
|
+
$uuid = Uuid::fromString('00000000-0000-1000-9669-00007ffffffe');
|
|
277
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
278
|
+
$this->assertSame('1582-10-15T00:00:00+00:00', $uuid->getDateTime()->format('c'));
|
|
279
|
+
$this->assertSame('-12219292800.000000', $uuid->getDateTime()->format('U.u'));
|
|
280
|
+
|
|
281
|
+
// The Unix epoch
|
|
282
|
+
/** @var UuidV1 $uuid */
|
|
283
|
+
$uuid = Uuid::fromString('13814000-1dd2-11b2-9669-00007ffffffe');
|
|
284
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
285
|
+
$this->assertSame('1970-01-01T00:00:00+00:00', $uuid->getDateTime()->format('c'));
|
|
286
|
+
$this->assertSame('0.000000', $uuid->getDateTime()->format('U.u'));
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
public function testGetDateTimeForUuidV6(): void
|
|
290
|
+
{
|
|
291
|
+
// Check a recent date
|
|
292
|
+
/** @var UuidV6 $uuid */
|
|
293
|
+
$uuid = Uuid::fromString('1e1c57df-f6f8-6cb0-9b21-0800200c9a66');
|
|
294
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
295
|
+
$this->assertSame('2012-07-04T02:14:34+00:00', $uuid->getDateTime()->format('c'));
|
|
296
|
+
$this->assertSame('1341368074.491000', $uuid->getDateTime()->format('U.u'));
|
|
297
|
+
|
|
298
|
+
// Check an old date
|
|
299
|
+
/** @var UuidV6 $uuid */
|
|
300
|
+
$uuid = Uuid::fromString('00001540-901e-6600-9b21-0800200c9a66');
|
|
301
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
302
|
+
$this->assertSame('1582-10-16T16:34:04+00:00', $uuid->getDateTime()->format('c'));
|
|
303
|
+
$this->assertSame('-12219146756.000000', $uuid->getDateTime()->format('U.u'));
|
|
304
|
+
|
|
305
|
+
// Check a future date
|
|
306
|
+
/** @var UuidV6 $uuid */
|
|
307
|
+
$uuid = Uuid::fromString('ffffffff-f978-65f6-9669-00007ffffffe');
|
|
308
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
309
|
+
$this->assertSame('5236-03-31T21:20:59+00:00', $uuid->getDateTime()->format('c'));
|
|
310
|
+
$this->assertSame('103072857659.999999', $uuid->getDateTime()->format('U.u'));
|
|
311
|
+
|
|
312
|
+
// Check the last possible time supported by UUIDs
|
|
313
|
+
// See inline comments in
|
|
314
|
+
// {@see \Ramsey\Uuid\Test\Converter\Time\GenericTimeConverterTest::provideCalculateTime()}
|
|
315
|
+
/** @var UuidV6 $uuid */
|
|
316
|
+
$uuid = Uuid::fromString('ffffffff-ffff-6ffa-8b1e-acde48001122');
|
|
317
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
318
|
+
$this->assertSame('5236-03-31T21:21:00+00:00', $uuid->getDateTime()->format('c'));
|
|
319
|
+
$this->assertSame('103072857660.684697', $uuid->getDateTime()->format('U.u'));
|
|
320
|
+
|
|
321
|
+
// Check the oldest date
|
|
322
|
+
/** @var UuidV6 $uuid */
|
|
323
|
+
$uuid = Uuid::fromString('00000000-0000-6000-9669-00007ffffffe');
|
|
324
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
325
|
+
$this->assertSame('1582-10-15T00:00:00+00:00', $uuid->getDateTime()->format('c'));
|
|
326
|
+
$this->assertSame('-12219292800.000000', $uuid->getDateTime()->format('U.u'));
|
|
327
|
+
|
|
328
|
+
// The Unix epoch
|
|
329
|
+
/** @var UuidV6 $uuid */
|
|
330
|
+
$uuid = Uuid::fromString('1b21dd21-3814-6000-9669-00007ffffffe');
|
|
331
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
332
|
+
$this->assertSame('1970-01-01T00:00:00+00:00', $uuid->getDateTime()->format('c'));
|
|
333
|
+
$this->assertSame('0.000000', $uuid->getDateTime()->format('U.u'));
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
public function testGetDateTimeFromNonVersion1Uuid(): void
|
|
337
|
+
{
|
|
338
|
+
// Using a version 4 UUID to test
|
|
339
|
+
$uuid = Uuid::fromString('bf17b594-41f2-474f-bf70-4c90220f75de');
|
|
340
|
+
|
|
341
|
+
$this->assertInstanceOf(LazyUuidFromString::class, $uuid);
|
|
342
|
+
|
|
343
|
+
$this->expectException(UnsupportedOperationException::class);
|
|
344
|
+
$this->expectExceptionMessage('Not a time-based UUID');
|
|
345
|
+
|
|
346
|
+
$uuid->getDateTime();
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
public function testGetFields(): void
|
|
350
|
+
{
|
|
351
|
+
/** @var Uuid $uuid */
|
|
352
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
353
|
+
|
|
354
|
+
$this->assertInstanceOf(FieldsInterface::class, $uuid->getFields());
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
public function testGetNodeHex(): void
|
|
358
|
+
{
|
|
359
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
360
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
361
|
+
$this->assertSame('0800200c9a66', $uuid->getFields()->getNode()->toString());
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
public function testGetTimeHiAndVersionHex(): void
|
|
365
|
+
{
|
|
366
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
367
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
368
|
+
$this->assertSame('11e1', $uuid->getFields()->getTimeHiAndVersion()->toString());
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
public function testGetTimeLowHex(): void
|
|
372
|
+
{
|
|
373
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
374
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
375
|
+
$this->assertSame('ff6f8cb0', $uuid->getFields()->getTimeLow()->toString());
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
public function testGetTimeMidHex(): void
|
|
379
|
+
{
|
|
380
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
381
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
382
|
+
$this->assertSame('c57d', $uuid->getFields()->getTimeMid()->toString());
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
public function testGetTimestampHex(): void
|
|
386
|
+
{
|
|
387
|
+
// Check for a recent date
|
|
388
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
389
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
390
|
+
$this->assertSame('1e1c57dff6f8cb0', $uuid->getFields()->getTimestamp()->toString());
|
|
391
|
+
|
|
392
|
+
// Check for an old date
|
|
393
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
394
|
+
$uuid = Uuid::fromString('0901e600-0154-1000-9b21-0800200c9a66');
|
|
395
|
+
$this->assertSame('00001540901e600', $uuid->getFields()->getTimestamp()->toString());
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
public function testGetTimestampHexFromNonVersion1Uuid(): void
|
|
399
|
+
{
|
|
400
|
+
// Using a version 4 UUID to test
|
|
401
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
402
|
+
$uuid = Uuid::fromString('bf17b594-41f2-474f-bf70-4c90220f75de');
|
|
403
|
+
|
|
404
|
+
// This threw an exception in versions of ramsey/uuid earlier than 5.0.0.
|
|
405
|
+
// The test is here now to ensure we don't throw an exception.
|
|
406
|
+
$this->assertSame('74f41f2bf17b594', $uuid->getFields()->getTimestamp()->toString());
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
public function testGetUrn(): void
|
|
410
|
+
{
|
|
411
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
412
|
+
$this->assertSame('urn:uuid:ff6f8cb0-c57d-11e1-9b21-0800200c9a66', $uuid->getUrn());
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* @param non-empty-string $uuid
|
|
417
|
+
*
|
|
418
|
+
* @dataProvider provideVariousVariantUuids
|
|
419
|
+
*/
|
|
420
|
+
public function testGetVariantForVariousVariantUuids(string $uuid, Variant $variant): void
|
|
421
|
+
{
|
|
422
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuidInstance */
|
|
423
|
+
$uuidInstance = Uuid::fromString($uuid);
|
|
424
|
+
$this->assertSame($variant, $uuidInstance->getFields()->getVariant());
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
|
|
429
|
+
*/
|
|
430
|
+
public function provideVariousVariantUuids(): array
|
|
431
|
+
{
|
|
432
|
+
return [
|
|
433
|
+
['ff6f8cb0-c57d-11e1-0b21-0800200c9a66', Variant::ReservedNcs],
|
|
434
|
+
['ff6f8cb0-c57d-11e1-1b21-0800200c9a66', Variant::ReservedNcs],
|
|
435
|
+
['ff6f8cb0-c57d-11e1-2b21-0800200c9a66', Variant::ReservedNcs],
|
|
436
|
+
['ff6f8cb0-c57d-11e1-3b21-0800200c9a66', Variant::ReservedNcs],
|
|
437
|
+
['ff6f8cb0-c57d-11e1-4b21-0800200c9a66', Variant::ReservedNcs],
|
|
438
|
+
['ff6f8cb0-c57d-11e1-5b21-0800200c9a66', Variant::ReservedNcs],
|
|
439
|
+
['ff6f8cb0-c57d-11e1-6b21-0800200c9a66', Variant::ReservedNcs],
|
|
440
|
+
['ff6f8cb0-c57d-11e1-7b21-0800200c9a66', Variant::ReservedNcs],
|
|
441
|
+
['ff6f8cb0-c57d-11e1-8b21-0800200c9a66', Variant::Rfc4122],
|
|
442
|
+
['ff6f8cb0-c57d-11e1-9b21-0800200c9a66', Variant::Rfc4122],
|
|
443
|
+
['ff6f8cb0-c57d-11e1-ab21-0800200c9a66', Variant::Rfc4122],
|
|
444
|
+
['ff6f8cb0-c57d-11e1-bb21-0800200c9a66', Variant::Rfc4122],
|
|
445
|
+
['ff6f8cb0-c57d-11e1-cb21-0800200c9a66', Variant::ReservedMicrosoft],
|
|
446
|
+
['ff6f8cb0-c57d-11e1-db21-0800200c9a66', Variant::ReservedMicrosoft],
|
|
447
|
+
['ff6f8cb0-c57d-11e1-eb21-0800200c9a66', Variant::ReservedFuture],
|
|
448
|
+
['ff6f8cb0-c57d-11e1-fb21-0800200c9a66', Variant::ReservedFuture],
|
|
449
|
+
];
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
public function testGetVersionForVersion1(): void
|
|
453
|
+
{
|
|
454
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
455
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
456
|
+
$this->assertSame(Version::Time, $uuid->getFields()->getVersion());
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
public function testGetVersionForVersion2(): void
|
|
460
|
+
{
|
|
461
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
462
|
+
$uuid = Uuid::fromString('6fa459ea-ee8a-2ca4-894e-db77e160355e');
|
|
463
|
+
$this->assertSame(Version::DceSecurity, $uuid->getFields()->getVersion());
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
public function testGetVersionForVersion3(): void
|
|
467
|
+
{
|
|
468
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
469
|
+
$uuid = Uuid::fromString('6fa459ea-ee8a-3ca4-894e-db77e160355e');
|
|
470
|
+
$this->assertSame(Version::HashMd5, $uuid->getFields()->getVersion());
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
public function testGetVersionForVersion4(): void
|
|
474
|
+
{
|
|
475
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
476
|
+
$uuid = Uuid::fromString('6fabf0bc-603a-42f2-925b-d9f779bd0032');
|
|
477
|
+
$this->assertSame(Version::Random, $uuid->getFields()->getVersion());
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
public function testGetVersionForVersion5(): void
|
|
481
|
+
{
|
|
482
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
483
|
+
$uuid = Uuid::fromString('886313e1-3b8a-5372-9b90-0c9aee199e5d');
|
|
484
|
+
$this->assertSame(Version::HashSha1, $uuid->getFields()->getVersion());
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
public function testToString(): void
|
|
488
|
+
{
|
|
489
|
+
// Check with a recent date
|
|
490
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
491
|
+
$this->assertSame('ff6f8cb0-c57d-11e1-9b21-0800200c9a66', $uuid->toString());
|
|
492
|
+
$this->assertSame('ff6f8cb0-c57d-11e1-9b21-0800200c9a66', (string) $uuid);
|
|
493
|
+
$this->assertSame(
|
|
494
|
+
'ff6f8cb0-c57d-11e1-9b21-0800200c9a66',
|
|
495
|
+
(static fn (Stringable $uuid) => (string) $uuid)($uuid)
|
|
496
|
+
);
|
|
497
|
+
|
|
498
|
+
// Check with an old date
|
|
499
|
+
$uuid = Uuid::fromString('0901e600-0154-1000-9b21-0800200c9a66');
|
|
500
|
+
$this->assertSame('0901e600-0154-1000-9b21-0800200c9a66', $uuid->toString());
|
|
501
|
+
$this->assertSame('0901e600-0154-1000-9b21-0800200c9a66', (string) $uuid);
|
|
502
|
+
$this->assertSame(
|
|
503
|
+
'0901e600-0154-1000-9b21-0800200c9a66',
|
|
504
|
+
(static fn (Stringable $uuid) => (string) $uuid)($uuid)
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
public function testUuid1(): void
|
|
509
|
+
{
|
|
510
|
+
/** @var UuidV1 $uuid */
|
|
511
|
+
$uuid = Uuid::uuid1();
|
|
512
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
513
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
514
|
+
$this->assertSame(Version::Time, $uuid->getFields()->getVersion());
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
public function testUuid1WithNodeAndClockSequence(): void
|
|
518
|
+
{
|
|
519
|
+
/** @var UuidV1 $uuid */
|
|
520
|
+
$uuid = Uuid::uuid1('0800200c9a66', 0x1669);
|
|
521
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
522
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
523
|
+
$this->assertSame(Version::Time, $uuid->getFields()->getVersion());
|
|
524
|
+
$this->assertSame('1669', $uuid->getFields()->getClockSeq()->toString());
|
|
525
|
+
$this->assertSame('0800200c9a66', $uuid->getFields()->getNode()->toString());
|
|
526
|
+
$this->assertSame('9669-0800200c9a66', substr($uuid->toString(), 19));
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
public function testUuid1WithHexadecimalObjectNodeAndClockSequence(): void
|
|
530
|
+
{
|
|
531
|
+
/** @var UuidV1 $uuid */
|
|
532
|
+
$uuid = Uuid::uuid1(new Hexadecimal('0800200c9a66'), 0x1669);
|
|
533
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
534
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
535
|
+
$this->assertSame(Version::Time, $uuid->getFields()->getVersion());
|
|
536
|
+
$this->assertSame('1669', $uuid->getFields()->getClockSeq()->toString());
|
|
537
|
+
$this->assertSame('0800200c9a66', $uuid->getFields()->getNode()->toString());
|
|
538
|
+
$this->assertSame('9669-0800200c9a66', substr($uuid->toString(), 19));
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
public function testUuid1WithHexadecimalNode(): void
|
|
542
|
+
{
|
|
543
|
+
/** @var UuidV1 $uuid */
|
|
544
|
+
$uuid = Uuid::uuid1('7160355e');
|
|
545
|
+
|
|
546
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
547
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
548
|
+
$this->assertSame(Version::Time, $uuid->getFields()->getVersion());
|
|
549
|
+
$this->assertSame('00007160355e', $uuid->getFields()->getNode()->toString());
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
public function testUuid1WithHexadecimalObjectNode(): void
|
|
553
|
+
{
|
|
554
|
+
/** @var UuidV1 $uuid */
|
|
555
|
+
$uuid = Uuid::uuid1(new Hexadecimal('7160355e'));
|
|
556
|
+
|
|
557
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
558
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
559
|
+
$this->assertSame(Version::Time, $uuid->getFields()->getVersion());
|
|
560
|
+
$this->assertSame('00007160355e', $uuid->getFields()->getNode()->toString());
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
public function testUuid1WithMixedCaseHexadecimalNode(): void
|
|
564
|
+
{
|
|
565
|
+
/** @var UuidV1 $uuid */
|
|
566
|
+
$uuid = Uuid::uuid1('71B0aD5e');
|
|
567
|
+
|
|
568
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
569
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
570
|
+
$this->assertSame(Version::Time, $uuid->getFields()->getVersion());
|
|
571
|
+
$this->assertSame('000071b0ad5e', $uuid->getFields()->getNode()->toString());
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
public function testUuid1WithOutOfBoundsNode(): void
|
|
575
|
+
{
|
|
576
|
+
$this->expectException(InvalidArgumentException::class);
|
|
577
|
+
$this->expectExceptionMessage('Invalid node value');
|
|
578
|
+
|
|
579
|
+
Uuid::uuid1('9223372036854775808');
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
public function testUuid1WithNonHexadecimalNode(): void
|
|
583
|
+
{
|
|
584
|
+
$this->expectException(InvalidArgumentException::class);
|
|
585
|
+
$this->expectExceptionMessage('Invalid node value');
|
|
586
|
+
|
|
587
|
+
Uuid::uuid1('db77e160355g');
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
public function testUuid1WithNon48bitNumber(): void
|
|
591
|
+
{
|
|
592
|
+
$this->expectException(InvalidArgumentException::class);
|
|
593
|
+
$this->expectExceptionMessage('Invalid node value');
|
|
594
|
+
|
|
595
|
+
Uuid::uuid1('db77e160355ef');
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
public function testUuid1WithRandomNode(): void
|
|
599
|
+
{
|
|
600
|
+
Uuid::setFactory(new UuidFactory(new FeatureSet(false, false, true)));
|
|
601
|
+
|
|
602
|
+
/** @var UuidV1 $uuid */
|
|
603
|
+
$uuid = Uuid::uuid1();
|
|
604
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
605
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
606
|
+
$this->assertSame(Version::Time, $uuid->getFields()->getVersion());
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
public function testUuid1WithUserGeneratedRandomNode(): void
|
|
610
|
+
{
|
|
611
|
+
/** @var UuidV1 $uuid */
|
|
612
|
+
$uuid = Uuid::uuid1(new Hexadecimal((string) (new RandomNodeProvider())->getNode()));
|
|
613
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
614
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
615
|
+
$this->assertSame(Version::Time, $uuid->getFields()->getVersion());
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
public function testUuid6(): void
|
|
619
|
+
{
|
|
620
|
+
/** @var UuidV6 $uuid */
|
|
621
|
+
$uuid = Uuid::uuid6();
|
|
622
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
623
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
624
|
+
$this->assertSame(Version::ReorderedTime, $uuid->getFields()->getVersion());
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
public function testUuid6WithNodeAndClockSequence(): void
|
|
628
|
+
{
|
|
629
|
+
/** @var UuidV6 $uuid */
|
|
630
|
+
$uuid = Uuid::uuid6(new Hexadecimal('0800200c9a66'), 0x1669);
|
|
631
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
632
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
633
|
+
$this->assertSame(Version::ReorderedTime, $uuid->getFields()->getVersion());
|
|
634
|
+
$this->assertSame('1669', $uuid->getFields()->getClockSeq()->toString());
|
|
635
|
+
$this->assertSame('0800200c9a66', $uuid->getFields()->getNode()->toString());
|
|
636
|
+
$this->assertSame('9669-0800200c9a66', substr($uuid->toString(), 19));
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
public function testUuid6WithHexadecimalNode(): void
|
|
640
|
+
{
|
|
641
|
+
/** @var UuidV6 $uuid */
|
|
642
|
+
$uuid = Uuid::uuid6(new Hexadecimal('7160355e'));
|
|
643
|
+
|
|
644
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
645
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
646
|
+
$this->assertSame(Version::ReorderedTime, $uuid->getFields()->getVersion());
|
|
647
|
+
$this->assertSame('00007160355e', $uuid->getFields()->getNode()->toString());
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
public function testUuid6WithMixedCaseHexadecimalNode(): void
|
|
651
|
+
{
|
|
652
|
+
/** @var UuidV6 $uuid */
|
|
653
|
+
$uuid = Uuid::uuid6(new Hexadecimal('71B0aD5e'));
|
|
654
|
+
|
|
655
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
656
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
657
|
+
$this->assertSame(Version::ReorderedTime, $uuid->getFields()->getVersion());
|
|
658
|
+
$this->assertSame('000071b0ad5e', $uuid->getFields()->getNode()->toString());
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
public function testUuid6WithOutOfBoundsNode(): void
|
|
662
|
+
{
|
|
663
|
+
$this->expectException(InvalidArgumentException::class);
|
|
664
|
+
$this->expectExceptionMessage('Invalid node value');
|
|
665
|
+
|
|
666
|
+
Uuid::uuid6(new Hexadecimal('9223372036854775808'));
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
public function testUuid6WithNon48bitNumber(): void
|
|
670
|
+
{
|
|
671
|
+
$this->expectException(InvalidArgumentException::class);
|
|
672
|
+
$this->expectExceptionMessage('Invalid node value');
|
|
673
|
+
|
|
674
|
+
Uuid::uuid6(new Hexadecimal('db77e160355ef'));
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
public function testUuid6WithRandomNode(): void
|
|
678
|
+
{
|
|
679
|
+
Uuid::setFactory(new UuidFactory(new FeatureSet(false, false, true)));
|
|
680
|
+
|
|
681
|
+
/** @var UuidV6 $uuid */
|
|
682
|
+
$uuid = Uuid::uuid6();
|
|
683
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
684
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
685
|
+
$this->assertSame(Version::ReorderedTime, $uuid->getFields()->getVersion());
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
public function testUuid6WithUserGeneratedRandomNode(): void
|
|
689
|
+
{
|
|
690
|
+
/** @var UuidV6 $uuid */
|
|
691
|
+
$uuid = Uuid::uuid6(new Hexadecimal((string) (new RandomNodeProvider())->getNode()));
|
|
692
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
693
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
694
|
+
$this->assertSame(Version::ReorderedTime, $uuid->getFields()->getVersion());
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
public function testUuid7(): void
|
|
698
|
+
{
|
|
699
|
+
/** @var UuidV7 $uuid */
|
|
700
|
+
$uuid = Uuid::uuid7();
|
|
701
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
702
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
703
|
+
$this->assertSame(Version::UnixTime, $uuid->getFields()->getVersion());
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
public function testUuid7ThrowsExceptionForUnsupportedFactory(): void
|
|
707
|
+
{
|
|
708
|
+
/** @var UuidFactoryInterface&MockInterface $factory */
|
|
709
|
+
$factory = Mockery::mock(UuidFactoryInterface::class);
|
|
710
|
+
|
|
711
|
+
Uuid::setFactory($factory);
|
|
712
|
+
|
|
713
|
+
$this->expectException(UnsupportedOperationException::class);
|
|
714
|
+
$this->expectExceptionMessage('The provided factory does not support the uuid7() method');
|
|
715
|
+
|
|
716
|
+
Uuid::uuid7();
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
public function testUuid7WithDateTime(): void
|
|
720
|
+
{
|
|
721
|
+
$dateTime = new DateTimeImmutable('@281474976710.655');
|
|
722
|
+
|
|
723
|
+
/** @var UuidV7 $uuid */
|
|
724
|
+
$uuid = Uuid::uuid7($dateTime);
|
|
725
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
726
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
727
|
+
$this->assertSame(Version::UnixTime, $uuid->getFields()->getVersion());
|
|
728
|
+
$this->assertSame(
|
|
729
|
+
'10889-08-02T05:31:50.655+00:00',
|
|
730
|
+
$uuid->getDateTime()->format(DateTimeInterface::RFC3339_EXTENDED),
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
public function testUuid7SettingTheClockBackwards(): void
|
|
735
|
+
{
|
|
736
|
+
$dates = [
|
|
737
|
+
new DateTimeImmutable('now'),
|
|
738
|
+
new DateTimeImmutable('last year'),
|
|
739
|
+
new DateTimeImmutable('1979-01-01 00:00:00.000000'),
|
|
740
|
+
];
|
|
741
|
+
|
|
742
|
+
foreach ($dates as $dateTime) {
|
|
743
|
+
/** @var UuidV7 $previous */
|
|
744
|
+
$previous = Uuid::uuid7($dateTime);
|
|
745
|
+
|
|
746
|
+
for ($i = 0; $i < 25; $i++) {
|
|
747
|
+
/** @var UuidV7 $uuid */
|
|
748
|
+
$uuid = Uuid::uuid7($dateTime);
|
|
749
|
+
$this->assertGreaterThan(0, $uuid->compareTo($previous));
|
|
750
|
+
$this->assertSame($dateTime->format('Y-m-d H:i'), $uuid->getDateTime()->format('Y-m-d H:i'));
|
|
751
|
+
$previous = $uuid;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
public function testUuid7WithMinimumDateTime(): void
|
|
757
|
+
{
|
|
758
|
+
$dateTime = new DateTimeImmutable('1979-01-01 00:00:00.000000');
|
|
759
|
+
|
|
760
|
+
/** @var UuidV7 $uuid */
|
|
761
|
+
$uuid = Uuid::uuid7($dateTime);
|
|
762
|
+
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
|
763
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
764
|
+
$this->assertSame(Version::UnixTime, $uuid->getFields()->getVersion());
|
|
765
|
+
|
|
766
|
+
$this->assertSame(
|
|
767
|
+
'1979-01-01T00:00:00.000+00:00',
|
|
768
|
+
$uuid->getDateTime()->format(DateTimeInterface::RFC3339_EXTENDED),
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
public function testUuid7EachUuidIsMonotonicallyIncreasing(): void
|
|
773
|
+
{
|
|
774
|
+
/** @var UuidV7 $previous */
|
|
775
|
+
$previous = Uuid::uuid7();
|
|
776
|
+
|
|
777
|
+
for ($i = 0; $i < 25; $i++) {
|
|
778
|
+
/** @var UuidV7 $uuid */
|
|
779
|
+
$uuid = Uuid::uuid7();
|
|
780
|
+
$now = gmdate('Y-m-d H:i');
|
|
781
|
+
$this->assertGreaterThan(0, $uuid->compareTo($previous));
|
|
782
|
+
$this->assertSame($now, $uuid->getDateTime()->format('Y-m-d H:i'));
|
|
783
|
+
$previous = $uuid;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
public function testUuid7EachUuidFromSameDateTimeIsMonotonicallyIncreasing(): void
|
|
788
|
+
{
|
|
789
|
+
$dateTime = new DateTimeImmutable();
|
|
790
|
+
|
|
791
|
+
/** @var UuidV7 $previous */
|
|
792
|
+
$previous = Uuid::uuid7($dateTime);
|
|
793
|
+
|
|
794
|
+
for ($i = 0; $i < 25; $i++) {
|
|
795
|
+
/** @var UuidV7 $uuid */
|
|
796
|
+
$uuid = Uuid::uuid7($dateTime);
|
|
797
|
+
$this->assertGreaterThan(0, $uuid->compareTo($previous));
|
|
798
|
+
$this->assertSame($dateTime->format('Y-m-d H:i'), $uuid->getDateTime()->format('Y-m-d H:i'));
|
|
799
|
+
$previous = $uuid;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
public function testUuid8(): void
|
|
804
|
+
{
|
|
805
|
+
/** @var UuidV8 $uuid */
|
|
806
|
+
$uuid = Uuid::uuid8("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff");
|
|
807
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
808
|
+
$this->assertSame(Version::Custom, $uuid->getFields()->getVersion());
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
public function testUuid8ThrowsExceptionForUnsupportedFactory(): void
|
|
812
|
+
{
|
|
813
|
+
/** @var UuidFactoryInterface&MockInterface $factory */
|
|
814
|
+
$factory = Mockery::mock(UuidFactoryInterface::class);
|
|
815
|
+
|
|
816
|
+
Uuid::setFactory($factory);
|
|
817
|
+
|
|
818
|
+
$this->expectException(UnsupportedOperationException::class);
|
|
819
|
+
$this->expectExceptionMessage('The provided factory does not support the uuid8() method');
|
|
820
|
+
|
|
821
|
+
Uuid::uuid8("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff");
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Tests known version-3 UUIDs
|
|
826
|
+
*
|
|
827
|
+
* Taken from the Python UUID tests in
|
|
828
|
+
* http://hg.python.org/cpython/file/2f4c4db9aee5/Lib/test/test_uuid.py
|
|
829
|
+
*
|
|
830
|
+
* @param non-empty-string $uuid
|
|
831
|
+
* @param non-empty-string $ns
|
|
832
|
+
*
|
|
833
|
+
* @dataProvider provideUuid3WithKnownUuids
|
|
834
|
+
*/
|
|
835
|
+
public function testUuid3WithKnownUuids(string $uuid, string $ns, string $name): void
|
|
836
|
+
{
|
|
837
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uobj1 */
|
|
838
|
+
$uobj1 = Uuid::uuid3($ns, $name);
|
|
839
|
+
|
|
840
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uobj2 */
|
|
841
|
+
$uobj2 = Uuid::uuid3(Uuid::fromString($ns), $name);
|
|
842
|
+
|
|
843
|
+
$this->assertSame(Variant::Rfc4122, $uobj1->getFields()->getVariant());
|
|
844
|
+
$this->assertSame(Version::HashMd5, $uobj1->getFields()->getVersion());
|
|
845
|
+
$this->assertSame(Uuid::fromString($uuid)->toString(), $uobj1->toString());
|
|
846
|
+
$this->assertTrue($uobj1->equals($uobj2));
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
|
|
851
|
+
*/
|
|
852
|
+
public function provideUuid3WithKnownUuids(): array
|
|
853
|
+
{
|
|
854
|
+
return [
|
|
855
|
+
[
|
|
856
|
+
'uuid' => '6fa459ea-ee8a-3ca4-894e-db77e160355e',
|
|
857
|
+
'ns' => Uuid::NAMESPACE_DNS,
|
|
858
|
+
'name' => 'python.org',
|
|
859
|
+
],
|
|
860
|
+
[
|
|
861
|
+
'uuid' => '9fe8e8c4-aaa8-32a9-a55c-4535a88b748d',
|
|
862
|
+
'ns' => Uuid::NAMESPACE_URL,
|
|
863
|
+
'name' => 'http://python.org/',
|
|
864
|
+
],
|
|
865
|
+
[
|
|
866
|
+
'uuid' => 'dd1a1cef-13d5-368a-ad82-eca71acd4cd1',
|
|
867
|
+
'ns' => Uuid::NAMESPACE_OID,
|
|
868
|
+
'name' => '1.3.6.1',
|
|
869
|
+
],
|
|
870
|
+
[
|
|
871
|
+
'uuid' => '658d3002-db6b-3040-a1d1-8ddd7d189a4d',
|
|
872
|
+
'ns' => Uuid::NAMESPACE_X500,
|
|
873
|
+
'name' => 'c=ca',
|
|
874
|
+
],
|
|
875
|
+
];
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
public function testUuid4(): void
|
|
879
|
+
{
|
|
880
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
881
|
+
$uuid = Uuid::uuid4();
|
|
882
|
+
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
|
883
|
+
$this->assertSame(Version::Random, $uuid->getFields()->getVersion());
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Tests that generated UUID's using timestamp last COMB are sequential
|
|
888
|
+
*/
|
|
889
|
+
public function testUuid4TimestampLastComb(): void
|
|
890
|
+
{
|
|
891
|
+
$mock = $this->getMockBuilder(RandomGeneratorInterface::class)->getMock();
|
|
892
|
+
$mock->expects($this->any())
|
|
893
|
+
->method('generate')
|
|
894
|
+
->willReturnCallback(function ($length) {
|
|
895
|
+
// Makes first fields of UUIDs equal
|
|
896
|
+
return hex2bin(str_pad('', $length * 2, '0'));
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
$factory = new UuidFactory();
|
|
900
|
+
$generator = new CombGenerator($mock, $factory->getNumberConverter());
|
|
901
|
+
$codec = new TimestampLastCombCodec($factory->getUuidBuilder());
|
|
902
|
+
$factory->setRandomGenerator($generator);
|
|
903
|
+
$factory->setCodec($codec);
|
|
904
|
+
|
|
905
|
+
$previous = $factory->uuid4();
|
|
906
|
+
|
|
907
|
+
for ($i = 0; $i < 1000; $i++) {
|
|
908
|
+
usleep(100);
|
|
909
|
+
$uuid = $factory->uuid4();
|
|
910
|
+
$this->assertGreaterThan($previous->toString(), $uuid->toString());
|
|
911
|
+
|
|
912
|
+
$previous = $uuid;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Tests that generated UUID's using timestamp first COMB are sequential
|
|
918
|
+
*/
|
|
919
|
+
public function testUuid4TimestampFirstComb(): void
|
|
920
|
+
{
|
|
921
|
+
$mock = $this->getMockBuilder(RandomGeneratorInterface::class)->getMock();
|
|
922
|
+
$mock->expects($this->any())
|
|
923
|
+
->method('generate')
|
|
924
|
+
->willReturnCallback(function ($length) {
|
|
925
|
+
// Makes first fields of UUIDs equal
|
|
926
|
+
return hex2bin(str_pad('', $length * 2, '0'));
|
|
927
|
+
});
|
|
928
|
+
|
|
929
|
+
$factory = new UuidFactory();
|
|
930
|
+
$generator = new CombGenerator($mock, $factory->getNumberConverter());
|
|
931
|
+
$codec = new TimestampFirstCombCodec($factory->getUuidBuilder());
|
|
932
|
+
$factory->setRandomGenerator($generator);
|
|
933
|
+
$factory->setCodec($codec);
|
|
934
|
+
|
|
935
|
+
$previous = $factory->uuid4();
|
|
936
|
+
|
|
937
|
+
for ($i = 0; $i < 1000; $i++) {
|
|
938
|
+
usleep(100);
|
|
939
|
+
$uuid = $factory->uuid4();
|
|
940
|
+
$this->assertGreaterThan($previous->toString(), $uuid->toString());
|
|
941
|
+
|
|
942
|
+
$previous = $uuid;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* Test that COMB UUID's have a version 4 flag
|
|
948
|
+
*/
|
|
949
|
+
public function testUuid4CombVersion(): void
|
|
950
|
+
{
|
|
951
|
+
$factory = new UuidFactory();
|
|
952
|
+
$generator = new CombGenerator(
|
|
953
|
+
(new RandomGeneratorFactory())->getGenerator(),
|
|
954
|
+
$factory->getNumberConverter()
|
|
955
|
+
);
|
|
956
|
+
|
|
957
|
+
$factory->setRandomGenerator($generator);
|
|
958
|
+
|
|
959
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
960
|
+
$uuid = $factory->uuid4();
|
|
961
|
+
|
|
962
|
+
$this->assertSame(Version::Random, $uuid->getFields()->getVersion());
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* Tests known version-5 UUIDs
|
|
967
|
+
*
|
|
968
|
+
* Taken from the Python UUID tests in
|
|
969
|
+
* http://hg.python.org/cpython/file/2f4c4db9aee5/Lib/test/test_uuid.py
|
|
970
|
+
*
|
|
971
|
+
* @param non-empty-string $uuid
|
|
972
|
+
* @param non-empty-string $ns
|
|
973
|
+
*
|
|
974
|
+
* @dataProvider provideUuid5WithKnownUuids
|
|
975
|
+
*/
|
|
976
|
+
public function testUuid5WithKnownUuids(string $uuid, string $ns, string $name): void
|
|
977
|
+
{
|
|
978
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uobj1 */
|
|
979
|
+
$uobj1 = Uuid::uuid5($ns, $name);
|
|
980
|
+
|
|
981
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uobj2 */
|
|
982
|
+
$uobj2 = Uuid::uuid5(Uuid::fromString($ns), $name);
|
|
983
|
+
|
|
984
|
+
$this->assertSame(Variant::Rfc4122, $uobj1->getFields()->getVariant());
|
|
985
|
+
$this->assertSame(Version::HashSha1, $uobj1->getFields()->getVersion());
|
|
986
|
+
$this->assertSame(Uuid::fromString($uuid)->toString(), $uobj1->toString());
|
|
987
|
+
$this->assertTrue($uobj1->equals($uobj2));
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
|
|
992
|
+
*/
|
|
993
|
+
public function provideUuid5WithKnownUuids(): array
|
|
994
|
+
{
|
|
995
|
+
return [
|
|
996
|
+
[
|
|
997
|
+
'uuid' => '886313e1-3b8a-5372-9b90-0c9aee199e5d',
|
|
998
|
+
'ns' => Uuid::NAMESPACE_DNS,
|
|
999
|
+
'name' => 'python.org',
|
|
1000
|
+
],
|
|
1001
|
+
[
|
|
1002
|
+
'uuid' => '4c565f0d-3f5a-5890-b41b-20cf47701c5e',
|
|
1003
|
+
'ns' => Uuid::NAMESPACE_URL,
|
|
1004
|
+
'name' => 'http://python.org/',
|
|
1005
|
+
],
|
|
1006
|
+
[
|
|
1007
|
+
'uuid' => '1447fa61-5277-5fef-a9b3-fbc6e44f4af3',
|
|
1008
|
+
'ns' => Uuid::NAMESPACE_OID,
|
|
1009
|
+
'name' => '1.3.6.1',
|
|
1010
|
+
],
|
|
1011
|
+
[
|
|
1012
|
+
'uuid' => 'cc957dd1-a972-5349-98cd-874190002798',
|
|
1013
|
+
'ns' => Uuid::NAMESPACE_X500,
|
|
1014
|
+
'name' => 'c=ca',
|
|
1015
|
+
],
|
|
1016
|
+
];
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
public function testCompareTo(): void
|
|
1020
|
+
{
|
|
1021
|
+
// $uuid1 and $uuid2 are identical
|
|
1022
|
+
$uuid1 = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
1023
|
+
$uuid2 = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
1024
|
+
|
|
1025
|
+
// The next three UUIDs are used for comparing msb and lsb in
|
|
1026
|
+
// the compareTo() method
|
|
1027
|
+
|
|
1028
|
+
// msb are less than $uuid4, lsb are greater than $uuid5
|
|
1029
|
+
$uuid3 = Uuid::fromString('44cca71e-d13d-11e1-a959-c8bcc8a476f4');
|
|
1030
|
+
|
|
1031
|
+
// msb are greater than $uuid3, lsb are equal to those in $uuid3
|
|
1032
|
+
$uuid4 = Uuid::fromString('44cca71e-d13d-11e2-a959-c8bcc8a476f4');
|
|
1033
|
+
|
|
1034
|
+
// msb are equal to those in $uuid3, lsb are less than in $uuid3
|
|
1035
|
+
$uuid5 = Uuid::fromString('44cca71e-d13d-11e1-a959-c8bcc8a476f3');
|
|
1036
|
+
|
|
1037
|
+
$this->assertSame(0, $uuid1->compareTo($uuid2));
|
|
1038
|
+
$this->assertSame(0, $uuid2->compareTo($uuid1));
|
|
1039
|
+
$this->assertSame(-1, $uuid3->compareTo($uuid4));
|
|
1040
|
+
$this->assertSame(1, $uuid4->compareTo($uuid3));
|
|
1041
|
+
$this->assertSame(-1, $uuid5->compareTo($uuid3));
|
|
1042
|
+
$this->assertSame(1, $uuid3->compareTo($uuid5));
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
public function testCompareToReturnsZeroWhenDifferentCases(): void
|
|
1046
|
+
{
|
|
1047
|
+
$uuidString = 'ff6f8cb0-c57d-11e1-9b21-0800200c9a66';
|
|
1048
|
+
// $uuid1 and $uuid2 are identical
|
|
1049
|
+
$uuid1 = Uuid::fromString($uuidString);
|
|
1050
|
+
$uuid2 = Uuid::fromString(strtoupper($uuidString));
|
|
1051
|
+
|
|
1052
|
+
$this->assertSame(0, $uuid1->compareTo($uuid2));
|
|
1053
|
+
$this->assertSame(0, $uuid2->compareTo($uuid1));
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
public function testEqualsReturnsTrueWhenDifferentCases(): void
|
|
1057
|
+
{
|
|
1058
|
+
$uuidString = 'ff6f8cb0-c57d-11e1-9b21-0800200c9a66';
|
|
1059
|
+
// $uuid1 and $uuid2 are identical
|
|
1060
|
+
$uuid1 = Uuid::fromString($uuidString);
|
|
1061
|
+
$uuid2 = Uuid::fromString(strtoupper($uuidString));
|
|
1062
|
+
|
|
1063
|
+
$this->assertTrue($uuid1->equals($uuid2));
|
|
1064
|
+
$this->assertTrue($uuid2->equals($uuid1));
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
public function testEquals(): void
|
|
1068
|
+
{
|
|
1069
|
+
$uuid1 = Uuid::uuid5(Uuid::NAMESPACE_DNS, 'python.org');
|
|
1070
|
+
$uuid2 = Uuid::uuid5(Uuid::NAMESPACE_DNS, 'python.org');
|
|
1071
|
+
$uuid3 = Uuid::uuid5(Uuid::NAMESPACE_DNS, 'php.net');
|
|
1072
|
+
|
|
1073
|
+
$this->assertTrue($uuid1->equals($uuid2));
|
|
1074
|
+
$this->assertFalse($uuid1->equals($uuid3));
|
|
1075
|
+
$this->assertFalse($uuid1->equals(new stdClass()));
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
public function testCalculateUuidTime(): void
|
|
1079
|
+
{
|
|
1080
|
+
$timeOfDay = new FixedTimeProvider(new Time(1348845514, 277885));
|
|
1081
|
+
|
|
1082
|
+
$featureSet = new FeatureSet();
|
|
1083
|
+
$featureSet->setTimeProvider($timeOfDay);
|
|
1084
|
+
|
|
1085
|
+
// For usec = 277885
|
|
1086
|
+
Uuid::setFactory(new UuidFactory($featureSet));
|
|
1087
|
+
|
|
1088
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuidA */
|
|
1089
|
+
$uuidA = Uuid::uuid1(0x00007ffffffe, 0x1669);
|
|
1090
|
+
|
|
1091
|
+
$this->assertSame('c4dbe7e2-097f-11e2-9669-00007ffffffe', (string) $uuidA);
|
|
1092
|
+
$this->assertSame('c4dbe7e2', $uuidA->getFields()->getTimeLow()->toString());
|
|
1093
|
+
$this->assertSame('097f', $uuidA->getFields()->getTimeMid()->toString());
|
|
1094
|
+
$this->assertSame('11e2', $uuidA->getFields()->getTimeHiAndVersion()->toString());
|
|
1095
|
+
|
|
1096
|
+
// For usec = 0
|
|
1097
|
+
$timeOfDay->setUsec(0);
|
|
1098
|
+
|
|
1099
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuidB */
|
|
1100
|
+
$uuidB = Uuid::uuid1(0x00007ffffffe, 0x1669);
|
|
1101
|
+
|
|
1102
|
+
$this->assertSame('c4b18100-097f-11e2-9669-00007ffffffe', (string) $uuidB);
|
|
1103
|
+
$this->assertSame('c4b18100', $uuidB->getFields()->getTimeLow()->toString());
|
|
1104
|
+
$this->assertSame('097f', $uuidB->getFields()->getTimeMid()->toString());
|
|
1105
|
+
$this->assertSame('11e2', $uuidB->getFields()->getTimeHiAndVersion()->toString());
|
|
1106
|
+
|
|
1107
|
+
// For usec = 999999
|
|
1108
|
+
$timeOfDay->setUsec(999999);
|
|
1109
|
+
|
|
1110
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuidC */
|
|
1111
|
+
$uuidC = Uuid::uuid1(0x00007ffffffe, 0x1669);
|
|
1112
|
+
|
|
1113
|
+
$this->assertSame('c54a1776-097f-11e2-9669-00007ffffffe', (string) $uuidC);
|
|
1114
|
+
$this->assertSame('c54a1776', $uuidC->getFields()->getTimeLow()->toString());
|
|
1115
|
+
$this->assertSame('097f', $uuidC->getFields()->getTimeMid()->toString());
|
|
1116
|
+
$this->assertSame('11e2', $uuidC->getFields()->getTimeHiAndVersion()->toString());
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
public function testCalculateUuidTimeUpperLowerBounds(): void
|
|
1120
|
+
{
|
|
1121
|
+
// 5235-03-31T21:20:59+00:00
|
|
1122
|
+
$timeOfDay = new FixedTimeProvider(new Time('103072857659', '999999'));
|
|
1123
|
+
|
|
1124
|
+
$featureSet = new FeatureSet();
|
|
1125
|
+
$featureSet->setTimeProvider($timeOfDay);
|
|
1126
|
+
|
|
1127
|
+
Uuid::setFactory(new UuidFactory($featureSet));
|
|
1128
|
+
|
|
1129
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuidA */
|
|
1130
|
+
$uuidA = Uuid::uuid1(0x00007ffffffe, 0x1669);
|
|
1131
|
+
|
|
1132
|
+
$this->assertSame('ff9785f6-ffff-1fff-9669-00007ffffffe', (string) $uuidA);
|
|
1133
|
+
$this->assertSame('ff9785f6', $uuidA->getFields()->getTimeLow()->toString());
|
|
1134
|
+
$this->assertSame('ffff', $uuidA->getFields()->getTimeMid()->toString());
|
|
1135
|
+
$this->assertSame('1fff', $uuidA->getFields()->getTimeHiAndVersion()->toString());
|
|
1136
|
+
|
|
1137
|
+
// 1582-10-15T00:00:00+00:00
|
|
1138
|
+
$timeOfDay = new FixedTimeProvider(new Time('-12219292800', '0'));
|
|
1139
|
+
|
|
1140
|
+
$featureSet->setTimeProvider($timeOfDay);
|
|
1141
|
+
|
|
1142
|
+
Uuid::setFactory(new UuidFactory($featureSet));
|
|
1143
|
+
|
|
1144
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuidB */
|
|
1145
|
+
$uuidB = Uuid::uuid1(0x00007ffffffe, 0x1669);
|
|
1146
|
+
|
|
1147
|
+
$this->assertSame('00000000-0000-1000-9669-00007ffffffe', (string) $uuidB);
|
|
1148
|
+
$this->assertSame('00000000', $uuidB->getFields()->getTimeLow()->toString());
|
|
1149
|
+
$this->assertSame('0000', $uuidB->getFields()->getTimeMid()->toString());
|
|
1150
|
+
$this->assertSame('1000', $uuidB->getFields()->getTimeHiAndVersion()->toString());
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* Iterates over a 3600-second period and tests to ensure that, for each
|
|
1155
|
+
* second in the period, the 32-bit and 64-bit versions of the UUID match
|
|
1156
|
+
*/
|
|
1157
|
+
public function test32BitMatch64BitForOneHourPeriod(): void
|
|
1158
|
+
{
|
|
1159
|
+
$currentTime = strtotime('2012-12-11T00:00:00+00:00');
|
|
1160
|
+
$endTime = $currentTime + 3600;
|
|
1161
|
+
|
|
1162
|
+
$timeOfDay = new FixedTimeProvider(new Time($currentTime, 0));
|
|
1163
|
+
|
|
1164
|
+
$smallIntFeatureSet = new FeatureSet(false, true);
|
|
1165
|
+
$smallIntFeatureSet->setTimeProvider($timeOfDay);
|
|
1166
|
+
|
|
1167
|
+
$smallIntFactory = new UuidFactory($smallIntFeatureSet);
|
|
1168
|
+
|
|
1169
|
+
$featureSet = new FeatureSet();
|
|
1170
|
+
$featureSet->setTimeProvider($timeOfDay);
|
|
1171
|
+
|
|
1172
|
+
$factory = new UuidFactory($featureSet);
|
|
1173
|
+
|
|
1174
|
+
while ($currentTime <= $endTime) {
|
|
1175
|
+
foreach ([0, 50000, 250000, 500000, 750000, 999999] as $usec) {
|
|
1176
|
+
$timeOfDay->setSec($currentTime);
|
|
1177
|
+
$timeOfDay->setUsec($usec);
|
|
1178
|
+
|
|
1179
|
+
/** @var UuidV1 $uuid32 */
|
|
1180
|
+
$uuid32 = $smallIntFactory->uuid1(0x00007ffffffe, 0x1669);
|
|
1181
|
+
|
|
1182
|
+
/** @var UuidV1 $uuid64 */
|
|
1183
|
+
$uuid64 = $factory->uuid1(0x00007ffffffe, 0x1669);
|
|
1184
|
+
|
|
1185
|
+
$this->assertTrue(
|
|
1186
|
+
$uuid32->equals($uuid64),
|
|
1187
|
+
'Breaks at ' . gmdate('r', $currentTime)
|
|
1188
|
+
. "; 32-bit: {$uuid32->toString()}, 64-bit: {$uuid64->toString()}"
|
|
1189
|
+
);
|
|
1190
|
+
|
|
1191
|
+
// Assert that the time matches
|
|
1192
|
+
$usecAdd = BigDecimal::of($usec)->dividedBy('1000000', 14, RoundingMode::HALF_UP);
|
|
1193
|
+
$testTime = BigDecimal::of($currentTime)->plus($usecAdd)->toScale(0, RoundingMode::DOWN);
|
|
1194
|
+
$this->assertSame((string) $testTime, (string) $uuid64->getDateTime()->getTimestamp());
|
|
1195
|
+
$this->assertSame((string) $testTime, (string) $uuid32->getDateTime()->getTimestamp());
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
$currentTime++;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* This method should respond to the result of the factory
|
|
1204
|
+
*/
|
|
1205
|
+
public function testIsValid(): void
|
|
1206
|
+
{
|
|
1207
|
+
$argument = uniqid('passed argument ');
|
|
1208
|
+
|
|
1209
|
+
/** @var MockObject & ValidatorInterface $validator */
|
|
1210
|
+
$validator = $this->getMockBuilder(ValidatorInterface::class)->getMock();
|
|
1211
|
+
$validator->expects($this->once())->method('validate')->with($argument)->willReturn(true);
|
|
1212
|
+
|
|
1213
|
+
/** @var UuidFactory $factory */
|
|
1214
|
+
$factory = Uuid::getFactory();
|
|
1215
|
+
$factory->setValidator($validator);
|
|
1216
|
+
|
|
1217
|
+
$this->assertTrue(Uuid::isValid($argument));
|
|
1218
|
+
|
|
1219
|
+
// reset the static validator
|
|
1220
|
+
$factory->setValidator(new GenericValidator());
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
public function testUsingNilAsValidUuid(): void
|
|
1224
|
+
{
|
|
1225
|
+
self::assertSame(
|
|
1226
|
+
'0cb17687-6ec7-324b-833a-f1d101a7edb7',
|
|
1227
|
+
Uuid::uuid3(Uuid::NIL, 'randomtext')
|
|
1228
|
+
->toString()
|
|
1229
|
+
);
|
|
1230
|
+
self::assertSame(
|
|
1231
|
+
'3b24c15b-1273-5628-ade4-fc67c6ede500',
|
|
1232
|
+
Uuid::uuid5(Uuid::NIL, 'randomtext')
|
|
1233
|
+
->toString()
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
public function testFromBytes(): void
|
|
1238
|
+
{
|
|
1239
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
1240
|
+
$bytes = $uuid->getBytes();
|
|
1241
|
+
|
|
1242
|
+
$fromBytesUuid = Uuid::fromBytes($bytes);
|
|
1243
|
+
|
|
1244
|
+
$this->assertTrue($uuid->equals($fromBytesUuid));
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
public function testGuidBytesMatchesUuidWithSameString(): void
|
|
1248
|
+
{
|
|
1249
|
+
$uuidFactory = new UuidFactory(new FeatureSet(false));
|
|
1250
|
+
$guidFactory = new UuidFactory(new FeatureSet(true));
|
|
1251
|
+
|
|
1252
|
+
$uuid = $uuidFactory->fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
1253
|
+
$bytes = $uuid->getBytes();
|
|
1254
|
+
|
|
1255
|
+
// Swap the order of the bytes for a GUID.
|
|
1256
|
+
$guidBytes = $bytes[3] . $bytes[2] . $bytes[1] . $bytes[0];
|
|
1257
|
+
$guidBytes .= $bytes[5] . $bytes[4];
|
|
1258
|
+
$guidBytes .= $bytes[7] . $bytes[6];
|
|
1259
|
+
$guidBytes .= substr($bytes, 8);
|
|
1260
|
+
|
|
1261
|
+
$guid = $guidFactory->fromBytes($guidBytes);
|
|
1262
|
+
|
|
1263
|
+
$this->assertSame($uuid->toString(), $guid->toString());
|
|
1264
|
+
$this->assertTrue($uuid->equals($guid));
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
public function testGuidBytesProducesSameGuidString(): void
|
|
1268
|
+
{
|
|
1269
|
+
$guidFactory = new UuidFactory(new FeatureSet(true));
|
|
1270
|
+
|
|
1271
|
+
$guid = $guidFactory->fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
1272
|
+
$bytes = $guid->getBytes();
|
|
1273
|
+
|
|
1274
|
+
$parsedGuid = $guidFactory->fromBytes($bytes);
|
|
1275
|
+
|
|
1276
|
+
$this->assertSame($guid->toString(), $parsedGuid->toString());
|
|
1277
|
+
$this->assertTrue($guid->equals($parsedGuid));
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
public function testFromBytesArgumentTooShort(): void
|
|
1281
|
+
{
|
|
1282
|
+
$this->expectException(InvalidArgumentException::class);
|
|
1283
|
+
|
|
1284
|
+
Uuid::fromBytes('thisisveryshort');
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
public function testFromBytesArgumentTooLong(): void
|
|
1288
|
+
{
|
|
1289
|
+
$this->expectException(InvalidArgumentException::class);
|
|
1290
|
+
|
|
1291
|
+
Uuid::fromBytes('thisisabittoolong');
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
public function testFromInteger(): void
|
|
1295
|
+
{
|
|
1296
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
1297
|
+
$integer = $uuid->getInteger()->toString();
|
|
1298
|
+
|
|
1299
|
+
$fromIntegerUuid = Uuid::fromInteger($integer);
|
|
1300
|
+
|
|
1301
|
+
$this->assertTrue($uuid->equals($fromIntegerUuid));
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
public function testFromDateTime(): void
|
|
1305
|
+
{
|
|
1306
|
+
/** @var UuidV1 $uuid */
|
|
1307
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-8b21-0800200c9a66');
|
|
1308
|
+
$dateTime = $uuid->getDateTime();
|
|
1309
|
+
|
|
1310
|
+
$fromDateTimeUuid = Uuid::fromDateTime($dateTime, new Hexadecimal('0800200c9a66'), 2849);
|
|
1311
|
+
|
|
1312
|
+
$this->assertTrue($uuid->equals($fromDateTimeUuid));
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* This test ensures that Ramsey\Uuid passes the same test cases
|
|
1317
|
+
* as the Python UUID library.
|
|
1318
|
+
*
|
|
1319
|
+
* @param non-empty-string $string
|
|
1320
|
+
* @param non-empty-string $curly
|
|
1321
|
+
* @param non-empty-string $hex
|
|
1322
|
+
* @param non-empty-string $bytes
|
|
1323
|
+
* @param numeric-string $int
|
|
1324
|
+
* @param string[] $fields
|
|
1325
|
+
* @param non-empty-string $urn
|
|
1326
|
+
*
|
|
1327
|
+
* @dataProvider providePythonTests
|
|
1328
|
+
*/
|
|
1329
|
+
public function testUuidPassesPythonTests(
|
|
1330
|
+
string $string,
|
|
1331
|
+
string $curly,
|
|
1332
|
+
string $hex,
|
|
1333
|
+
string $bytes,
|
|
1334
|
+
string $int,
|
|
1335
|
+
array $fields,
|
|
1336
|
+
string $urn,
|
|
1337
|
+
string $time,
|
|
1338
|
+
string $clockSeq,
|
|
1339
|
+
Variant $variant,
|
|
1340
|
+
?Version $version
|
|
1341
|
+
): void {
|
|
1342
|
+
/** @var non-empty-string $base64DecodedBytes */
|
|
1343
|
+
$base64DecodedBytes = base64_decode($bytes);
|
|
1344
|
+
|
|
1345
|
+
$uuids = [
|
|
1346
|
+
Uuid::fromString($string),
|
|
1347
|
+
Uuid::fromString($curly),
|
|
1348
|
+
Uuid::fromString($hex),
|
|
1349
|
+
Uuid::fromBytes($base64DecodedBytes),
|
|
1350
|
+
Uuid::fromString($urn),
|
|
1351
|
+
Uuid::fromInteger($int),
|
|
1352
|
+
];
|
|
1353
|
+
|
|
1354
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
1355
|
+
foreach ($uuids as $uuid) {
|
|
1356
|
+
$this->assertSame($string, $uuid->toString());
|
|
1357
|
+
$this->assertSame($hex, $uuid->getHex()->toString());
|
|
1358
|
+
$this->assertSame($base64DecodedBytes, $uuid->getBytes());
|
|
1359
|
+
$this->assertSame($int, $uuid->getInteger()->toString());
|
|
1360
|
+
$this->assertSame($fields['time_low'], $uuid->getFields()->getTimeLow()->toString());
|
|
1361
|
+
$this->assertSame($fields['time_mid'], $uuid->getFields()->getTimeMid()->toString());
|
|
1362
|
+
$this->assertSame($fields['time_hi_and_version'], $uuid->getFields()->getTimeHiAndVersion()->toString());
|
|
1363
|
+
$this->assertSame(
|
|
1364
|
+
$fields['clock_seq_hi_and_reserved'],
|
|
1365
|
+
$uuid->getFields()->getClockSeqHiAndReserved()->toString(),
|
|
1366
|
+
);
|
|
1367
|
+
$this->assertSame(
|
|
1368
|
+
$fields['clock_seq_low'],
|
|
1369
|
+
$uuid->getFields()->getClockSeqLow()->toString(),
|
|
1370
|
+
);
|
|
1371
|
+
$this->assertSame($fields['node'], $uuid->getFields()->getNode()->toString());
|
|
1372
|
+
$this->assertSame($urn, $uuid->getUrn());
|
|
1373
|
+
$this->assertSame($time, $uuid->getFields()->getTimestamp()->toString());
|
|
1374
|
+
$this->assertSame($clockSeq, $uuid->getFields()->getClockSeq()->toString());
|
|
1375
|
+
$this->assertSame($variant, $uuid->getFields()->getVariant());
|
|
1376
|
+
$this->assertSame($version, $uuid->getFields()->getVersion());
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
/**
|
|
1381
|
+
* Taken from the Python UUID tests in
|
|
1382
|
+
* http://hg.python.org/cpython/file/2f4c4db9aee5/Lib/test/test_uuid.py
|
|
1383
|
+
*
|
|
1384
|
+
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
|
|
1385
|
+
*/
|
|
1386
|
+
public function providePythonTests(): array
|
|
1387
|
+
{
|
|
1388
|
+
// This array is taken directly from the Python tests, more or less.
|
|
1389
|
+
return [
|
|
1390
|
+
[
|
|
1391
|
+
'string' => '00000000-0000-0000-0000-000000000000',
|
|
1392
|
+
'curly' => '{00000000-0000-0000-0000-000000000000}',
|
|
1393
|
+
'hex' => '00000000000000000000000000000000',
|
|
1394
|
+
'bytes' => 'AAAAAAAAAAAAAAAAAAAAAA==',
|
|
1395
|
+
'int' => '0',
|
|
1396
|
+
'fields' => [
|
|
1397
|
+
'time_low' => '00000000',
|
|
1398
|
+
'time_mid' => '0000',
|
|
1399
|
+
'time_hi_and_version' => '0000',
|
|
1400
|
+
'clock_seq_hi_and_reserved' => '00',
|
|
1401
|
+
'clock_seq_low' => '00',
|
|
1402
|
+
'node' => '000000000000',
|
|
1403
|
+
],
|
|
1404
|
+
'urn' => 'urn:uuid:00000000-0000-0000-0000-000000000000',
|
|
1405
|
+
'time' => '000000000000000',
|
|
1406
|
+
'clock_seq' => '0000',
|
|
1407
|
+
// This is a departure from the Python tests. The Python tests
|
|
1408
|
+
// are technically "correct" because all bits are set to zero,
|
|
1409
|
+
// so it stands to reason that the variant is also zero, but
|
|
1410
|
+
// that leads to this being considered a "Reserved NCS" variant,
|
|
1411
|
+
// and that is not the case. RFC 4122 defines this special UUID,
|
|
1412
|
+
// so it is an RFC 4122 variant.
|
|
1413
|
+
'variant' => Variant::Rfc4122,
|
|
1414
|
+
'version' => null,
|
|
1415
|
+
],
|
|
1416
|
+
[
|
|
1417
|
+
'string' => '00010203-0405-0607-0809-0a0b0c0d0e0f',
|
|
1418
|
+
'curly' => '{00010203-0405-0607-0809-0a0b0c0d0e0f}',
|
|
1419
|
+
'hex' => '000102030405060708090a0b0c0d0e0f',
|
|
1420
|
+
'bytes' => 'AAECAwQFBgcICQoLDA0ODw==',
|
|
1421
|
+
'int' => '5233100606242806050955395731361295',
|
|
1422
|
+
'fields' => [
|
|
1423
|
+
'time_low' => '00010203',
|
|
1424
|
+
'time_mid' => '0405',
|
|
1425
|
+
'time_hi_and_version' => '0607',
|
|
1426
|
+
'clock_seq_hi_and_reserved' => '08',
|
|
1427
|
+
'clock_seq_low' => '09',
|
|
1428
|
+
'node' => '0a0b0c0d0e0f',
|
|
1429
|
+
],
|
|
1430
|
+
'urn' => 'urn:uuid:00010203-0405-0607-0809-0a0b0c0d0e0f',
|
|
1431
|
+
'time' => '607040500010203',
|
|
1432
|
+
'clock_seq' => '0809',
|
|
1433
|
+
'variant' => Variant::ReservedNcs,
|
|
1434
|
+
'version' => null,
|
|
1435
|
+
],
|
|
1436
|
+
[
|
|
1437
|
+
'string' => '02d9e6d5-9467-382e-8f9b-9300a64ac3cd',
|
|
1438
|
+
'curly' => '{02d9e6d5-9467-382e-8f9b-9300a64ac3cd}',
|
|
1439
|
+
'hex' => '02d9e6d59467382e8f9b9300a64ac3cd',
|
|
1440
|
+
'bytes' => 'Atnm1ZRnOC6Pm5MApkrDzQ==',
|
|
1441
|
+
'int' => '3789866285607910888100818383505376205',
|
|
1442
|
+
'fields' => [
|
|
1443
|
+
'time_low' => '02d9e6d5',
|
|
1444
|
+
'time_mid' => '9467',
|
|
1445
|
+
'time_hi_and_version' => '382e',
|
|
1446
|
+
'clock_seq_hi_and_reserved' => '8f',
|
|
1447
|
+
'clock_seq_low' => '9b',
|
|
1448
|
+
'node' => '9300a64ac3cd',
|
|
1449
|
+
],
|
|
1450
|
+
'urn' => 'urn:uuid:02d9e6d5-9467-382e-8f9b-9300a64ac3cd',
|
|
1451
|
+
'time' => '82e946702d9e6d5',
|
|
1452
|
+
'clock_seq' => '0f9b',
|
|
1453
|
+
'variant' => Variant::Rfc4122,
|
|
1454
|
+
'version' => Version::HashMd5,
|
|
1455
|
+
],
|
|
1456
|
+
[
|
|
1457
|
+
'string' => '12345678-1234-5678-1234-567812345678',
|
|
1458
|
+
'curly' => '{12345678-1234-5678-1234-567812345678}',
|
|
1459
|
+
'hex' => '12345678123456781234567812345678',
|
|
1460
|
+
'bytes' => 'EjRWeBI0VngSNFZ4EjRWeA==',
|
|
1461
|
+
'int' => '24197857161011715162171839636988778104',
|
|
1462
|
+
'fields' => [
|
|
1463
|
+
'time_low' => '12345678',
|
|
1464
|
+
'time_mid' => '1234',
|
|
1465
|
+
'time_hi_and_version' => '5678',
|
|
1466
|
+
'clock_seq_hi_and_reserved' => '12',
|
|
1467
|
+
'clock_seq_low' => '34',
|
|
1468
|
+
'node' => '567812345678',
|
|
1469
|
+
],
|
|
1470
|
+
'urn' => 'urn:uuid:12345678-1234-5678-1234-567812345678',
|
|
1471
|
+
'time' => '678123412345678',
|
|
1472
|
+
'clock_seq' => '1234',
|
|
1473
|
+
'variant' => Variant::ReservedNcs,
|
|
1474
|
+
'version' => null,
|
|
1475
|
+
],
|
|
1476
|
+
[
|
|
1477
|
+
'string' => '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
|
|
1478
|
+
'curly' => '{6ba7b810-9dad-11d1-80b4-00c04fd430c8}',
|
|
1479
|
+
'hex' => '6ba7b8109dad11d180b400c04fd430c8',
|
|
1480
|
+
'bytes' => 'a6e4EJ2tEdGAtADAT9QwyA==',
|
|
1481
|
+
'int' => '143098242404177361603877621312831893704',
|
|
1482
|
+
'fields' => [
|
|
1483
|
+
'time_low' => '6ba7b810',
|
|
1484
|
+
'time_mid' => '9dad',
|
|
1485
|
+
'time_hi_and_version' => '11d1',
|
|
1486
|
+
'clock_seq_hi_and_reserved' => '80',
|
|
1487
|
+
'clock_seq_low' => 'b4',
|
|
1488
|
+
'node' => '00c04fd430c8',
|
|
1489
|
+
],
|
|
1490
|
+
'urn' => 'urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8',
|
|
1491
|
+
'time' => '1d19dad6ba7b810',
|
|
1492
|
+
'clock_seq' => '00b4',
|
|
1493
|
+
'variant' => Variant::Rfc4122,
|
|
1494
|
+
'version' => Version::Time,
|
|
1495
|
+
],
|
|
1496
|
+
[
|
|
1497
|
+
'string' => '6ba7b811-9dad-11d1-80b4-00c04fd430c8',
|
|
1498
|
+
'curly' => '{6ba7b811-9dad-11d1-80b4-00c04fd430c8}',
|
|
1499
|
+
'hex' => '6ba7b8119dad11d180b400c04fd430c8',
|
|
1500
|
+
'bytes' => 'a6e4EZ2tEdGAtADAT9QwyA==',
|
|
1501
|
+
'int' => '143098242483405524118141958906375844040',
|
|
1502
|
+
'fields' => [
|
|
1503
|
+
'time_low' => '6ba7b811',
|
|
1504
|
+
'time_mid' => '9dad',
|
|
1505
|
+
'time_hi_and_version' => '11d1',
|
|
1506
|
+
'clock_seq_hi_and_reserved' => '80',
|
|
1507
|
+
'clock_seq_low' => 'b4',
|
|
1508
|
+
'node' => '00c04fd430c8',
|
|
1509
|
+
],
|
|
1510
|
+
'urn' => 'urn:uuid:6ba7b811-9dad-11d1-80b4-00c04fd430c8',
|
|
1511
|
+
'time' => '1d19dad6ba7b811',
|
|
1512
|
+
'clock_seq' => '00b4',
|
|
1513
|
+
'variant' => Variant::Rfc4122,
|
|
1514
|
+
'version' => Version::Time,
|
|
1515
|
+
],
|
|
1516
|
+
[
|
|
1517
|
+
'string' => '6ba7b812-9dad-11d1-80b4-00c04fd430c8',
|
|
1518
|
+
'curly' => '{6ba7b812-9dad-11d1-80b4-00c04fd430c8}',
|
|
1519
|
+
'hex' => '6ba7b8129dad11d180b400c04fd430c8',
|
|
1520
|
+
'bytes' => 'a6e4Ep2tEdGAtADAT9QwyA==',
|
|
1521
|
+
'int' => '143098242562633686632406296499919794376',
|
|
1522
|
+
'fields' => [
|
|
1523
|
+
'time_low' => '6ba7b812',
|
|
1524
|
+
'time_mid' => '9dad',
|
|
1525
|
+
'time_hi_and_version' => '11d1',
|
|
1526
|
+
'clock_seq_hi_and_reserved' => '80',
|
|
1527
|
+
'clock_seq_low' => 'b4',
|
|
1528
|
+
'node' => '00c04fd430c8',
|
|
1529
|
+
],
|
|
1530
|
+
'urn' => 'urn:uuid:6ba7b812-9dad-11d1-80b4-00c04fd430c8',
|
|
1531
|
+
'time' => '1d19dad6ba7b812',
|
|
1532
|
+
'clock_seq' => '00b4',
|
|
1533
|
+
'variant' => Variant::Rfc4122,
|
|
1534
|
+
'version' => Version::Time,
|
|
1535
|
+
],
|
|
1536
|
+
[
|
|
1537
|
+
'string' => '6ba7b814-9dad-11d1-80b4-00c04fd430c8',
|
|
1538
|
+
'curly' => '{6ba7b814-9dad-11d1-80b4-00c04fd430c8}',
|
|
1539
|
+
'hex' => '6ba7b8149dad11d180b400c04fd430c8',
|
|
1540
|
+
'bytes' => 'a6e4FJ2tEdGAtADAT9QwyA==',
|
|
1541
|
+
'int' => '143098242721090011660934971687007695048',
|
|
1542
|
+
'fields' => [
|
|
1543
|
+
'time_low' => '6ba7b814',
|
|
1544
|
+
'time_mid' => '9dad',
|
|
1545
|
+
'time_hi_and_version' => '11d1',
|
|
1546
|
+
'clock_seq_hi_and_reserved' => '80',
|
|
1547
|
+
'clock_seq_low' => 'b4',
|
|
1548
|
+
'node' => '00c04fd430c8',
|
|
1549
|
+
],
|
|
1550
|
+
'urn' => 'urn:uuid:6ba7b814-9dad-11d1-80b4-00c04fd430c8',
|
|
1551
|
+
'time' => '1d19dad6ba7b814',
|
|
1552
|
+
'clock_seq' => '00b4',
|
|
1553
|
+
'variant' => Variant::Rfc4122,
|
|
1554
|
+
'version' => Version::Time,
|
|
1555
|
+
],
|
|
1556
|
+
[
|
|
1557
|
+
'string' => '7d444840-9dc0-11d1-b245-5ffdce74fad2',
|
|
1558
|
+
'curly' => '{7d444840-9dc0-11d1-b245-5ffdce74fad2}',
|
|
1559
|
+
'hex' => '7d4448409dc011d1b2455ffdce74fad2',
|
|
1560
|
+
'bytes' => 'fURIQJ3AEdGyRV/9znT60g==',
|
|
1561
|
+
'int' => '166508041112410060672666770310773930706',
|
|
1562
|
+
'fields' => [
|
|
1563
|
+
'time_low' => '7d444840',
|
|
1564
|
+
'time_mid' => '9dc0',
|
|
1565
|
+
'time_hi_and_version' => '11d1',
|
|
1566
|
+
'clock_seq_hi_and_reserved' => 'b2',
|
|
1567
|
+
'clock_seq_low' => '45',
|
|
1568
|
+
'node' => '5ffdce74fad2',
|
|
1569
|
+
],
|
|
1570
|
+
'urn' => 'urn:uuid:7d444840-9dc0-11d1-b245-5ffdce74fad2',
|
|
1571
|
+
'time' => '1d19dc07d444840',
|
|
1572
|
+
'clock_seq' => '3245',
|
|
1573
|
+
'variant' => Variant::Rfc4122,
|
|
1574
|
+
'version' => Version::Time,
|
|
1575
|
+
],
|
|
1576
|
+
[
|
|
1577
|
+
'string' => 'e902893a-9d22-3c7e-a7b8-d6e313b71d9f',
|
|
1578
|
+
'curly' => '{e902893a-9d22-3c7e-a7b8-d6e313b71d9f}',
|
|
1579
|
+
'hex' => 'e902893a9d223c7ea7b8d6e313b71d9f',
|
|
1580
|
+
'bytes' => '6QKJOp0iPH6nuNbjE7cdnw==',
|
|
1581
|
+
'int' => '309723290945582129846206211755626405279',
|
|
1582
|
+
'fields' => [
|
|
1583
|
+
'time_low' => 'e902893a',
|
|
1584
|
+
'time_mid' => '9d22',
|
|
1585
|
+
'time_hi_and_version' => '3c7e',
|
|
1586
|
+
'clock_seq_hi_and_reserved' => 'a7',
|
|
1587
|
+
'clock_seq_low' => 'b8',
|
|
1588
|
+
'node' => 'd6e313b71d9f',
|
|
1589
|
+
],
|
|
1590
|
+
'urn' => 'urn:uuid:e902893a-9d22-3c7e-a7b8-d6e313b71d9f',
|
|
1591
|
+
'time' => 'c7e9d22e902893a',
|
|
1592
|
+
'clock_seq' => '27b8',
|
|
1593
|
+
'variant' => Variant::Rfc4122,
|
|
1594
|
+
'version' => Version::HashMd5,
|
|
1595
|
+
],
|
|
1596
|
+
[
|
|
1597
|
+
'string' => 'eb424026-6f54-4ef8-a4d0-bb658a1fc6cf',
|
|
1598
|
+
'curly' => '{eb424026-6f54-4ef8-a4d0-bb658a1fc6cf}',
|
|
1599
|
+
'hex' => 'eb4240266f544ef8a4d0bb658a1fc6cf',
|
|
1600
|
+
'bytes' => '60JAJm9UTvik0Ltlih/Gzw==',
|
|
1601
|
+
'int' => '312712571721458096795100956955942831823',
|
|
1602
|
+
'fields' => [
|
|
1603
|
+
'time_low' => 'eb424026',
|
|
1604
|
+
'time_mid' => '6f54',
|
|
1605
|
+
'time_hi_and_version' => '4ef8',
|
|
1606
|
+
'clock_seq_hi_and_reserved' => 'a4',
|
|
1607
|
+
'clock_seq_low' => 'd0',
|
|
1608
|
+
'node' => 'bb658a1fc6cf',
|
|
1609
|
+
],
|
|
1610
|
+
'urn' => 'urn:uuid:eb424026-6f54-4ef8-a4d0-bb658a1fc6cf',
|
|
1611
|
+
'time' => 'ef86f54eb424026',
|
|
1612
|
+
'clock_seq' => '24d0',
|
|
1613
|
+
'variant' => Variant::Rfc4122,
|
|
1614
|
+
'version' => Version::Random,
|
|
1615
|
+
],
|
|
1616
|
+
[
|
|
1617
|
+
'string' => 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
|
|
1618
|
+
'curly' => '{f81d4fae-7dec-11d0-a765-00a0c91e6bf6}',
|
|
1619
|
+
'hex' => 'f81d4fae7dec11d0a76500a0c91e6bf6',
|
|
1620
|
+
'bytes' => '+B1Prn3sEdCnZQCgyR5r9g==',
|
|
1621
|
+
'int' => '329800735698586629295641978511506172918',
|
|
1622
|
+
'fields' => [
|
|
1623
|
+
'time_low' => 'f81d4fae',
|
|
1624
|
+
'time_mid' => '7dec',
|
|
1625
|
+
'time_hi_and_version' => '11d0',
|
|
1626
|
+
'clock_seq_hi_and_reserved' => 'a7',
|
|
1627
|
+
'clock_seq_low' => '65',
|
|
1628
|
+
'node' => '00a0c91e6bf6',
|
|
1629
|
+
],
|
|
1630
|
+
'urn' => 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
|
|
1631
|
+
'time' => '1d07decf81d4fae',
|
|
1632
|
+
'clock_seq' => '2765',
|
|
1633
|
+
'variant' => Variant::Rfc4122,
|
|
1634
|
+
'version' => Version::Time,
|
|
1635
|
+
],
|
|
1636
|
+
[
|
|
1637
|
+
'string' => 'fffefdfc-fffe-fffe-fffe-fffefdfcfbfa',
|
|
1638
|
+
'curly' => '{fffefdfc-fffe-fffe-fffe-fffefdfcfbfa}',
|
|
1639
|
+
'hex' => 'fffefdfcfffefffefffefffefdfcfbfa',
|
|
1640
|
+
'bytes' => '//79/P/+//7//v/+/fz7+g==',
|
|
1641
|
+
'int' => '340277133821575024845345576078114880506',
|
|
1642
|
+
'fields' => [
|
|
1643
|
+
'time_low' => 'fffefdfc',
|
|
1644
|
+
'time_mid' => 'fffe',
|
|
1645
|
+
'time_hi_and_version' => 'fffe',
|
|
1646
|
+
'clock_seq_hi_and_reserved' => 'ff',
|
|
1647
|
+
'clock_seq_low' => 'fe',
|
|
1648
|
+
'node' => 'fffefdfcfbfa',
|
|
1649
|
+
],
|
|
1650
|
+
'urn' => 'urn:uuid:fffefdfc-fffe-fffe-fffe-fffefdfcfbfa',
|
|
1651
|
+
'time' => 'ffefffefffefdfc',
|
|
1652
|
+
'clock_seq' => '3ffe',
|
|
1653
|
+
'variant' => Variant::ReservedFuture,
|
|
1654
|
+
'version' => null,
|
|
1655
|
+
],
|
|
1656
|
+
[
|
|
1657
|
+
'string' => 'ffffffff-ffff-ffff-ffff-ffffffffffff',
|
|
1658
|
+
'curly' => '{ffffffff-ffff-ffff-ffff-ffffffffffff}',
|
|
1659
|
+
'hex' => 'ffffffffffffffffffffffffffffffff',
|
|
1660
|
+
'bytes' => '/////////////////////w==',
|
|
1661
|
+
'int' => '340282366920938463463374607431768211455',
|
|
1662
|
+
'fields' => [
|
|
1663
|
+
'time_low' => 'ffffffff',
|
|
1664
|
+
'time_mid' => 'ffff',
|
|
1665
|
+
'time_hi_and_version' => 'ffff',
|
|
1666
|
+
'clock_seq_hi_and_reserved' => 'ff',
|
|
1667
|
+
'clock_seq_low' => 'ff',
|
|
1668
|
+
'node' => 'ffffffffffff',
|
|
1669
|
+
],
|
|
1670
|
+
'urn' => 'urn:uuid:ffffffff-ffff-ffff-ffff-ffffffffffff',
|
|
1671
|
+
'time' => 'fffffffffffffff',
|
|
1672
|
+
// This is a departure from the Python tests. The Python tests
|
|
1673
|
+
// are technically "correct" because all bits are set to one,
|
|
1674
|
+
// which ends up calculating the variant as 7, or "Reserved
|
|
1675
|
+
// Future," but that is not the case, and now that max UUIDs
|
|
1676
|
+
// are defined as a special type, within the RFC 4122 variant
|
|
1677
|
+
// rules, we also consider it an RFC 4122 variant.
|
|
1678
|
+
//
|
|
1679
|
+
// Similarly, Python's tests think the clock sequence should be
|
|
1680
|
+
// 0x3fff because of the bit shifting performed on this field.
|
|
1681
|
+
// However, since all the bits in this UUID are defined as being
|
|
1682
|
+
// set to one, we will consider the clock sequence as 0xffff,
|
|
1683
|
+
// which all bits set to one.
|
|
1684
|
+
'clock_seq' => 'ffff',
|
|
1685
|
+
'variant' => Variant::Rfc4122,
|
|
1686
|
+
'version' => null,
|
|
1687
|
+
],
|
|
1688
|
+
];
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
/**
|
|
1692
|
+
* @covers \Ramsey\Uuid\Uuid::jsonSerialize
|
|
1693
|
+
*/
|
|
1694
|
+
public function testJsonSerialize(): void
|
|
1695
|
+
{
|
|
1696
|
+
$uuid = Uuid::uuid1();
|
|
1697
|
+
|
|
1698
|
+
$this->assertSame('"' . $uuid->toString() . '"', json_encode($uuid));
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
public function testSerialize(): void
|
|
1702
|
+
{
|
|
1703
|
+
$uuid = Uuid::uuid4();
|
|
1704
|
+
$serialized = serialize($uuid);
|
|
1705
|
+
|
|
1706
|
+
/** @var UuidInterface $unserializedUuid */
|
|
1707
|
+
$unserializedUuid = unserialize($serialized);
|
|
1708
|
+
|
|
1709
|
+
$this->assertTrue($uuid->equals($unserializedUuid));
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
public function testUuid3WithEmptyNamespace(): void
|
|
1713
|
+
{
|
|
1714
|
+
$this->expectException(InvalidArgumentException::class);
|
|
1715
|
+
$this->expectExceptionMessage('Invalid UUID string:');
|
|
1716
|
+
|
|
1717
|
+
/** @phpstan-ignore-next-line */
|
|
1718
|
+
Uuid::uuid3('', '');
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
public function testUuid3WithEmptyName(): void
|
|
1722
|
+
{
|
|
1723
|
+
$uuid = Uuid::uuid3(Uuid::NIL, '');
|
|
1724
|
+
|
|
1725
|
+
$this->assertSame('4ae71336-e44b-39bf-b9d2-752e234818a5', $uuid->toString());
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
public function testUuid3WithZeroName(): void
|
|
1729
|
+
{
|
|
1730
|
+
$uuid = Uuid::uuid3(Uuid::NIL, '0');
|
|
1731
|
+
|
|
1732
|
+
$this->assertSame('19826852-5007-3022-a72a-212f66e9fac3', $uuid->toString());
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
public function testUuid5WithEmptyNamespace(): void
|
|
1736
|
+
{
|
|
1737
|
+
$this->expectException(InvalidArgumentException::class);
|
|
1738
|
+
$this->expectExceptionMessage('Invalid UUID string:');
|
|
1739
|
+
|
|
1740
|
+
/** @phpstan-ignore-next-line */
|
|
1741
|
+
Uuid::uuid5('', '');
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
public function testUuid5WithEmptyName(): void
|
|
1745
|
+
{
|
|
1746
|
+
$uuid = Uuid::uuid5(Uuid::NIL, '');
|
|
1747
|
+
|
|
1748
|
+
$this->assertSame('e129f27c-5103-5c5c-844b-cdf0a15e160d', $uuid->toString());
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
public function testUuid5WithZeroName(): void
|
|
1752
|
+
{
|
|
1753
|
+
$uuid = Uuid::uuid5(Uuid::NIL, '0');
|
|
1754
|
+
|
|
1755
|
+
$this->assertSame('b6c54489-38a0-5f50-a60a-fd8d76219cae', $uuid->toString());
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
/**
|
|
1759
|
+
* @depends testGetVersionForVersion1
|
|
1760
|
+
*/
|
|
1761
|
+
public function testUuidVersionConstantForVersion1(): void
|
|
1762
|
+
{
|
|
1763
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
1764
|
+
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
|
|
1765
|
+
$this->assertSame($uuid->getFields()->getVersion(), Version::Time);
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* @depends testGetVersionForVersion2
|
|
1770
|
+
*/
|
|
1771
|
+
public function testUuidVersionConstantForVersion2(): void
|
|
1772
|
+
{
|
|
1773
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
1774
|
+
$uuid = Uuid::fromString('6fa459ea-ee8a-2ca4-894e-db77e160355e');
|
|
1775
|
+
$this->assertSame($uuid->getFields()->getVersion(), Version::DceSecurity);
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* @depends testGetVersionForVersion3
|
|
1780
|
+
*/
|
|
1781
|
+
public function testUuidVersionConstantForVersion3(): void
|
|
1782
|
+
{
|
|
1783
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
1784
|
+
$uuid = Uuid::fromString('6fa459ea-ee8a-3ca4-894e-db77e160355e');
|
|
1785
|
+
$this->assertSame($uuid->getFields()->getVersion(), Version::HashMd5);
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
/**
|
|
1789
|
+
* @depends testGetVersionForVersion4
|
|
1790
|
+
*/
|
|
1791
|
+
public function testUuidVersionConstantForVersion4(): void
|
|
1792
|
+
{
|
|
1793
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
1794
|
+
$uuid = Uuid::fromString('6fabf0bc-603a-42f2-925b-d9f779bd0032');
|
|
1795
|
+
$this->assertSame($uuid->getFields()->getVersion(), Version::Random);
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
/**
|
|
1799
|
+
* @depends testGetVersionForVersion5
|
|
1800
|
+
*/
|
|
1801
|
+
public function testUuidVersionConstantForVersion5(): void
|
|
1802
|
+
{
|
|
1803
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
1804
|
+
$uuid = Uuid::fromString('886313e1-3b8a-5372-9b90-0c9aee199e5d');
|
|
1805
|
+
$this->assertSame($uuid->getFields()->getVersion(), Version::HashSha1);
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
public function testUuidVersionConstantForVersion6(): void
|
|
1809
|
+
{
|
|
1810
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
1811
|
+
$uuid = Uuid::fromString('886313e1-3b8a-6372-9b90-0c9aee199e5d');
|
|
1812
|
+
$this->assertSame($uuid->getFields()->getVersion(), Version::ReorderedTime);
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
public function testUuidVersionConstantForVersion7(): void
|
|
1816
|
+
{
|
|
1817
|
+
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
|
1818
|
+
$uuid = Uuid::fromString('886313e1-3b8a-7372-9b90-0c9aee199e5d');
|
|
1819
|
+
$this->assertSame($uuid->getFields()->getVersion(), Version::UnixTime);
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
public function testGetDateTimeThrowsExceptionWhenDateTimeCannotParseDate(): void
|
|
1823
|
+
{
|
|
1824
|
+
$numberConverter = new GenericNumberConverter(new BrickMathCalculator());
|
|
1825
|
+
$timeConverter = Mockery::mock(TimeConverterInterface::class);
|
|
1826
|
+
|
|
1827
|
+
$timeConverter
|
|
1828
|
+
->shouldReceive('convertTime')
|
|
1829
|
+
->once()
|
|
1830
|
+
->andReturn(new Time(1234567890, '1234567'));
|
|
1831
|
+
|
|
1832
|
+
$builder = new UuidBuilder($numberConverter, $timeConverter);
|
|
1833
|
+
$codec = new StringCodec($builder);
|
|
1834
|
+
|
|
1835
|
+
$factory = new UuidFactory();
|
|
1836
|
+
$factory->setCodec($codec);
|
|
1837
|
+
|
|
1838
|
+
$uuid = $factory->fromString('b1484596-25dc-11ea-978f-2e728ce88125');
|
|
1839
|
+
|
|
1840
|
+
$this->expectException(DateTimeException::class);
|
|
1841
|
+
$this->expectExceptionMessage(
|
|
1842
|
+
'Failed to parse time string (@1234567890.1234567) at position 18 (7): Unexpected character'
|
|
1843
|
+
);
|
|
1844
|
+
|
|
1845
|
+
/**
|
|
1846
|
+
* @phpstan-ignore-next-line
|
|
1847
|
+
*/
|
|
1848
|
+
$uuid->getDateTime();
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
/**
|
|
1852
|
+
* @param mixed[] $args
|
|
1853
|
+
*
|
|
1854
|
+
* @dataProvider provideStaticMethods
|
|
1855
|
+
*/
|
|
1856
|
+
public function testStaticCreationMethodsReturnSpecificUuidInstances(
|
|
1857
|
+
string $staticMethod,
|
|
1858
|
+
array $args = []
|
|
1859
|
+
): void {
|
|
1860
|
+
$this->assertInstanceOf(LazyUuidFromString::class, Uuid::$staticMethod(...$args));
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
/**
|
|
1864
|
+
* @param mixed[] $args
|
|
1865
|
+
*
|
|
1866
|
+
* @dataProvider provideStaticMethods
|
|
1867
|
+
*/
|
|
1868
|
+
public function testUuidInstancesBuiltFromStringAreEquivalentToTheirGeneratedCounterparts(
|
|
1869
|
+
string $staticMethod,
|
|
1870
|
+
array $args = []
|
|
1871
|
+
): void {
|
|
1872
|
+
$generated = Uuid::$staticMethod(...$args);
|
|
1873
|
+
|
|
1874
|
+
self::assertSame(
|
|
1875
|
+
(string) $generated,
|
|
1876
|
+
(string) Uuid::fromString($generated->toString())
|
|
1877
|
+
);
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* @param mixed[] $args
|
|
1882
|
+
*
|
|
1883
|
+
* @dataProvider provideStaticMethods
|
|
1884
|
+
*/
|
|
1885
|
+
public function testUuidInstancesBuiltFromBytesAreEquivalentToTheirGeneratedCounterparts(
|
|
1886
|
+
string $staticMethod,
|
|
1887
|
+
array $args = []
|
|
1888
|
+
): void {
|
|
1889
|
+
$generated = Uuid::$staticMethod(...$args);
|
|
1890
|
+
|
|
1891
|
+
self::assertSame(
|
|
1892
|
+
(string) $generated,
|
|
1893
|
+
(string) Uuid::fromBytes($generated->getBytes())
|
|
1894
|
+
);
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
/**
|
|
1898
|
+
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
|
|
1899
|
+
*/
|
|
1900
|
+
public function provideStaticMethods(): array
|
|
1901
|
+
{
|
|
1902
|
+
return [
|
|
1903
|
+
['uuid1'],
|
|
1904
|
+
['uuid2', [Uuid::DCE_DOMAIN_PERSON]],
|
|
1905
|
+
['uuid3', [Uuid::NIL, 'foobar']],
|
|
1906
|
+
['uuid4'],
|
|
1907
|
+
['uuid5', [Uuid::NIL, 'foobar']],
|
|
1908
|
+
];
|
|
1909
|
+
}
|
|
1910
|
+
}
|