Commit Graph

260 Commits

Author SHA1 Message Date
Ben Ramsey 5d7ee63f1c Update dev requirements and test suite for PHP 7+ only 2020-01-18 12:13:07 -06:00
Martin Hujer 049d5acf7a Use ::class constants where possible
It helps with refactorings and static analysis, because you can easily
tell if the class is missing or not.
2020-01-18 12:13:07 -06:00
Jildert Miedema 225eb3b4c1 Set minimum version to PHP 5.6 and use PHP 5.5 style ::class constants 2020-01-18 12:13:07 -06:00
Ben Ramsey eb1645bc72 Add behavior test for TimestampFirstCombCodec 2020-01-13 10:49:53 -06:00
Ben Ramsey da6fcde177 Add tests to ensure consistent behavior from 3.x to 4.x 2020-01-08 16:47:00 -06:00
Ben Ramsey b39ec78f6e Check whether sysfs is readable before attempting to read it
Fixes #260
2019-12-17 02:01:14 -06:00
Ben Ramsey 2ed5a60a61 Fix "access array offset on value of type null" errors 2019-12-06 21:24:32 -08:00
Ben Ramsey e1761af875 Disable deprecation messages for now 2019-12-06 17:55:09 -08:00
Ben Ramsey 231027100a Increase microseconds in another test to ensure enough time passes 2019-12-06 14:54:08 -08:00
Ben Ramsey 9e48187656 Add slightly more sleep to ensure timestamps don't collide 2019-12-04 17:09:13 -08:00
Ben Ramsey 692175901d Fix RandomNodeProvider behavior on 32-bit systems
The 6 bytes obtained from `random_bytes()` is a 48-bit integer, which
cannot be converted to decimal on a 32-bit system, without being
implicitly cast to a float by PHP. This was causing problems with
setting the multicast bit, and it led to non-random node values.

This new approach splits the 6 bytes up into two 3-byte values, each a
24-bit integer, and applies the multicast bit to the most significant
bits before re-combining the bytes as a string.
2019-11-30 20:26:42 -08:00
Ben Ramsey 35cf50d7b4 Add tests for the function API 2019-11-30 14:26:27 -08:00
Viktor Szépe bc201fe3e4 Add uuid PECL stubs 2019-11-30 13:33:54 -08:00
Ben Ramsey 64ba9a2767 Clean up code according to PhpStorm inspections report 2019-11-30 13:14:52 -08:00
Ben Ramsey 3f43661fdc Create stubs for testing uuid_* methods for environments without pecl/uuid 2019-11-30 12:19:43 -08:00
Ben Ramsey 555e5c1102 Test usage of PHP_OS constant 2019-11-30 12:18:43 -08:00
Ben Ramsey 657add4b3c Fix mock invocation assertions 2019-11-30 09:10:09 -08:00
Ben Ramsey 466629a399 Use a high-strength generator by default, when using RandomLibAdapter 2019-11-30 09:10:09 -08:00
Martin Hujer bfc4afdf1f Tests: configure cacheDir for AspectMock 2019-11-30 09:10:09 -08:00
Martin Hujer f3e0fed2d7 Drop remnants of HHVM from tests
It was removed from Travis in c479cdd42f
2019-11-30 09:10:09 -08:00
Ben Ramsey 1b608e7e01 Remove test that fails because of qualified function call 2019-11-30 09:10:09 -08:00
Ben Ramsey 93a19b8133 Fix failing build due to coding standards violation 2018-07-19 17:19:38 -05:00
Ben Ramsey 8d621488c4 Check whether passthru() is disabled
If passthru() is disabled in php.ini, this will force the
SystemNodeProvider to return `false` for the node. Using the default
FallbackNodeProvider, ramsey/uuid will default to the
RandomNodeProvider, in these cases.

Closes #114
2018-07-19 16:53:00 -05:00
Ben Ramsey b8cac9278c Merge branch 'SystemNodeProvider-FreeBSD-support' of https://github.com/kalifg/uuid into kalifg-SystemNodeProvider-FreeBSD-support 2018-07-19 15:08:45 -05:00
Lee Boynton 2804748423 Don't allow UUIDs to have trailing newline 2018-05-02 18:54:33 +01:00
peter279k 8fab36d995 Use class-based PHPUnit namespace 2018-04-25 18:43:33 +08:00
Ben Peachey 62628862df Improvements to the SystemNodeProviderTest class (#211)
* Changes location of providers in the SystemNodeProviderTest

  They are now grouped at the bottom of the class.

* Adds logic to SystemNodeProviderTest.

* Changes call to `file_get_contents` SystemNodeProvider so it can be
  mocked.

* Changes SystemNodeProviderTest so native PHP functions are mocked
  instead of the class under test.

* Changes SystemNodeProviderTest so "\n" is used instead of PHP_EOL

  As the (input or output) of the tests is not system dependant it does
  not make sense to use PHP_EOL. All of these instance have been
  replaced for the sake of readability and stating intent more clearly.

* Adds dataprovider to SystemNodeProvider main test for input
  variations.

* Adds OS to SystemNodeProviderTest dataprovider for Linux fail
  scenario.

* Adds test for SystemNodeProvider to ensure invalid values are not
  accepted.

* Changes names of dataproviders in SystemNodeProviderTest for
  consistency.

* Changes SystemNodeProviderTest by grouping dataproviders together.

* Changes method in SystemNodeProviderTest to use the provided mock
  functions.

* Fixes PSR-2 coding conventions in SystemNodeProviderTest.

* Minor change to SystemNodeProviderTest based on review.
2018-02-07 17:28:02 -06:00
kalifg a7492800e2 Add support for determining MAC address on FreeBSD systems 2018-02-07 15:15:49 -06:00
Marcel Hernandez 76efebe0ac generate random clockSeq with random_int() instead of mt_rand() 2018-01-19 16:17:49 -06:00
Marcel Hernandez 3567caf3f9 fixed off-by-one error on DefaultTimeGenerator 2018-01-19 16:17:36 -06:00
Ben Ramsey f203f13921 Fix broken build on PHP 5.4 2018-01-19 16:00:06 -06:00
Ben Ramsey e67d6bfdc2 Revert to pre-1.x series of mockery/mockery for ramsey/uuid 3.x 2018-01-16 19:45:47 -06:00
Ben Ramsey 89c3c1777e Fix capitalization of the getSysfs() method 2018-01-16 14:14:34 -06:00
Ben Ramsey 901c3e540d Handle cases where glob() returns false
Fixes #203
2018-01-16 14:11:58 -06:00
Gabriel Caruso f65471fb5c Use assertSame 2017-12-10 05:51:10 -02:00
Robbert Müller 8a540b78a1 mock glob function to get assertions work 2017-11-17 16:16:29 +01:00
Robbert Müller 70346f5da3 Fix whitespace 2017-11-17 15:00:23 +01:00
Robbert Müller a9154c4c27 add testcase for getsysfs 2017-11-17 14:52:51 +01:00
Ben Ramsey 6b0445588c Merge branch 'master' into add-sysfs-option 2017-11-10 16:04:30 -06:00
Robbert Müller 3572bf8755 adapt testcases to also mock getsysfs, to get the old code path tested 2017-10-18 11:33:26 +02:00
Ben Peachey 58658b8f4d Merge branch 'master' into fix/replace-deprecated-getMock 2017-10-18 08:57:31 +02:00
Ben Peachey dbb9a8b6d1 Changes all usage in Tests of getMock with getMockBuilder. 2017-10-17 12:46:25 +02:00
Ben Ramsey 749b30e3f9 Add random node test that asserts multicast bit against random values 2017-09-22 15:46:04 -05:00
Ben Ramsey 5c38d41ccb Use sprintf() to prefix zeros on the returned node hex string 2017-09-22 13:03:41 -05:00
Ben Ramsey 1ec0826a40 Set the multicast bit for random nodes, according to RFC 4122, §4.5
Borrows the idea from cf1c981414 to
properly set the multicast bit to the "least significant bit of the
first octet of the node ID."

When merged, this will close #171 and #170
2017-09-22 12:54:15 -05:00
Ben Ramsey aab08bb08a Use random_bytes() to generate a random node 2017-09-22 12:26:34 -05:00
Davis Peixoto 46071e69a1 173 - Expose UUID versions - Alternative 1
https://github.com/ramsey/uuid/issues/173

Creating constants on Uuid object, so they can be used as
- Uuid::UUID_TYPE_TIME
- Uuid::UUID_TYPE_RANDOM

# Alternative 1
Create constants on Uuid class

Signed-off-by: Davis Peixoto <davis.peixoto@gmail.com>
2017-08-03 21:12:10 -03:00
Davis Peixoto 0915c7bdc2 173 - Expose UUID versions - Alternative 1
https://github.com/ramsey/uuid/issues/173

Creating constants on Uuid object, so they can be used as
- UUID::UUID_TYPE_TIME
- UUID::UUID_TYPE_RANDOM

# Alternative 1
Create constants on Uuid class

Signed-off-by: Davis Peixoto <davis.peixoto@gmail.com>
2017-08-02 08:55:26 -03:00
Massimiliano Arione a2647abc14 add a specific exception for invalid UUID string 2017-03-11 10:52:53 +01:00
Ben Ramsey 2f7d4ff00f Add tests for uuid3() and uuid4() to test behavior for empty strings 2017-02-02 15:30:40 -06:00