From 30d71f250d235a47362f1aac9d99348d6181d028 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Sun, 13 Mar 2016 11:04:17 -0400 Subject: [PATCH 01/20] Tests for RandomLibAdapter - Requires Mockery for overloading creation of factory - Tests for the constructor of the adapter. --- composer.json | 3 +- tests/src/Generator/RandomLibAdapterTest.php | 42 ++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/src/Generator/RandomLibAdapterTest.php diff --git a/composer.json b/composer.json index e267680..4f7a5c4 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "source": "https://github.com/ramsey/uuid" }, "require": { - "php": ">=5.4" + "php": ">=5.4", + "mockery/mockery": "^0.9.4" }, "require-dev": { "moontoast/math": "^1.1", diff --git a/tests/src/Generator/RandomLibAdapterTest.php b/tests/src/Generator/RandomLibAdapterTest.php new file mode 100644 index 0000000..fb4f29e --- /dev/null +++ b/tests/src/Generator/RandomLibAdapterTest.php @@ -0,0 +1,42 @@ +shouldNotReceive('getMediumStrengthGenerator') + ->getMock(); + + $generator = $this->getMockBuilder('RandomLib\Generator') + ->disableOriginalConstructor() + ->getMock(); + new RandomLibAdapter($generator); + } + + public function testAdapterWithoutGeneratorGreatesGenerator() + { + $factory = Mockery::mock('overload:RandomLib\Factory'); + $factory->shouldReceive('getMediumStrengthGenerator') + ->once() + ->getMock(); + + new RandomLibAdapter(); + } +} \ No newline at end of file From cd00a9cb778a3fa5f269c6b94bf5e19580708894 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Sun, 13 Mar 2016 11:09:51 -0400 Subject: [PATCH 02/20] Add coverage of generate method --- tests/src/Generator/RandomLibAdapterTest.php | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/src/Generator/RandomLibAdapterTest.php b/tests/src/Generator/RandomLibAdapterTest.php index fb4f29e..ce2ca99 100644 --- a/tests/src/Generator/RandomLibAdapterTest.php +++ b/tests/src/Generator/RandomLibAdapterTest.php @@ -39,4 +39,32 @@ class RandomLibAdapterTest extends TestCase new RandomLibAdapter(); } + + public function testGenerateUsesGenerator() + { + $length = 10; + $generator = $this->getMockBuilder('RandomLib\Generator') + ->disableOriginalConstructor() + ->getMock(); + $generator->expects($this->once()) + ->method('generate') + ->with($length); + + $adapter = new RandomLibAdapter($generator); + $adapter->generate($length); + } + + public function testGenerateReturnsString() + { + $generator = $this->getMockBuilder('RandomLib\Generator') + ->disableOriginalConstructor() + ->getMock(); + $generator->expects($this->once()) + ->method('generate') + ->willReturn('random-string'); + + $adapter = new RandomLibAdapter($generator); + $result = $adapter->generate(1); + $this->assertEquals('random-string', $result); + } } \ No newline at end of file From 3290885a9c8d328ea1190dc3cbf36288439abc31 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Sun, 13 Mar 2016 11:40:15 -0400 Subject: [PATCH 03/20] Test Coverage for PeclUuidTimeGenerator - Uses namespaced function override to "mock" the pecl extension methods. - Tests that method will create a uuid when extension methods exist. --- tests/src/Generator/PeclUuidTestHelper.php | 22 +++++++++++++++++++ .../Generator/PeclUuidTimeGeneratorTest.php | 18 +++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/src/Generator/PeclUuidTestHelper.php create mode 100644 tests/src/Generator/PeclUuidTimeGeneratorTest.php diff --git a/tests/src/Generator/PeclUuidTestHelper.php b/tests/src/Generator/PeclUuidTestHelper.php new file mode 100644 index 0000000..bf4c142 --- /dev/null +++ b/tests/src/Generator/PeclUuidTestHelper.php @@ -0,0 +1,22 @@ +generate(); + $this->assertEquals(PeclUuidHelper::EXAMPLE_UUID, $uuid); + } +} \ No newline at end of file From 48027c3fdaef36a2dac1f43966131a681f22a522 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Sun, 13 Mar 2016 11:42:30 -0400 Subject: [PATCH 04/20] Add new lines to end of file --- tests/src/Generator/PeclUuidTestHelper.php | 2 +- tests/src/Generator/PeclUuidTimeGeneratorTest.php | 2 +- tests/src/Generator/RandomLibAdapterTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/src/Generator/PeclUuidTestHelper.php b/tests/src/Generator/PeclUuidTestHelper.php index bf4c142..2350423 100644 --- a/tests/src/Generator/PeclUuidTestHelper.php +++ b/tests/src/Generator/PeclUuidTestHelper.php @@ -19,4 +19,4 @@ function uuid_create($type) function uuid_parse($uuid) { return PeclUuidHelper::EXAMPLE_UUID; -} \ No newline at end of file +} diff --git a/tests/src/Generator/PeclUuidTimeGeneratorTest.php b/tests/src/Generator/PeclUuidTimeGeneratorTest.php index 20d78f6..d111abf 100644 --- a/tests/src/Generator/PeclUuidTimeGeneratorTest.php +++ b/tests/src/Generator/PeclUuidTimeGeneratorTest.php @@ -15,4 +15,4 @@ class PeclUuidTimeGeneratorTest extends TestCase $uuid = $generator->generate(); $this->assertEquals(PeclUuidHelper::EXAMPLE_UUID, $uuid); } -} \ No newline at end of file +} diff --git a/tests/src/Generator/RandomLibAdapterTest.php b/tests/src/Generator/RandomLibAdapterTest.php index ce2ca99..b34918a 100644 --- a/tests/src/Generator/RandomLibAdapterTest.php +++ b/tests/src/Generator/RandomLibAdapterTest.php @@ -67,4 +67,4 @@ class RandomLibAdapterTest extends TestCase $result = $adapter->generate(1); $this->assertEquals('random-string', $result); } -} \ No newline at end of file +} From 689940ec00b9cf45d5ac6900904df63c190b2999 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Sun, 13 Mar 2016 11:56:57 -0400 Subject: [PATCH 05/20] Ignore side-effect problem This file is only used for testing, and is for overriding an extension's global function for the test. --- tests/src/Generator/PeclUuidTimeGeneratorTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/src/Generator/PeclUuidTimeGeneratorTest.php b/tests/src/Generator/PeclUuidTimeGeneratorTest.php index d111abf..c6c0374 100644 --- a/tests/src/Generator/PeclUuidTimeGeneratorTest.php +++ b/tests/src/Generator/PeclUuidTimeGeneratorTest.php @@ -5,7 +5,9 @@ use Ramsey\Uuid\Generator\PeclUuidTimeGenerator; use Ramsey\Uuid\Test\TestCase; use Ramsey\Uuid\Generator\PeclUuidHelper; +// @codingStandardsIgnoreStart require_once 'PeclUuidTestHelper.php'; +// @codingStandardsIgnoreEnd class PeclUuidTimeGeneratorTest extends TestCase { From 3764478b6b78b78d4c76245b94f697b50d514cbc Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Sun, 13 Mar 2016 12:12:16 -0400 Subject: [PATCH 06/20] Ignoring side effect issue --- tests/src/Generator/PeclUuidTestHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Generator/PeclUuidTestHelper.php b/tests/src/Generator/PeclUuidTestHelper.php index 2350423..8d61d5c 100644 --- a/tests/src/Generator/PeclUuidTestHelper.php +++ b/tests/src/Generator/PeclUuidTestHelper.php @@ -1,5 +1,5 @@ Date: Sun, 13 Mar 2016 17:35:35 -0400 Subject: [PATCH 07/20] remove files since phpcs doesn't tolerate them --- tests/src/Generator/PeclUuidTestHelper.php | 22 ------------------- .../Generator/PeclUuidTimeGeneratorTest.php | 20 ----------------- 2 files changed, 42 deletions(-) delete mode 100644 tests/src/Generator/PeclUuidTestHelper.php delete mode 100644 tests/src/Generator/PeclUuidTimeGeneratorTest.php diff --git a/tests/src/Generator/PeclUuidTestHelper.php b/tests/src/Generator/PeclUuidTestHelper.php deleted file mode 100644 index 8d61d5c..0000000 --- a/tests/src/Generator/PeclUuidTestHelper.php +++ /dev/null @@ -1,22 +0,0 @@ -generate(); - $this->assertEquals(PeclUuidHelper::EXAMPLE_UUID, $uuid); - } -} From 3ac0506203ccb0c346cb0e278fe2517e5ab874c3 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Wed, 16 Mar 2016 10:26:16 -0400 Subject: [PATCH 08/20] Tests for UUID Builder classes. --- tests/src/Builder/DefaultUuidBuilderTest.php | 28 +++++++++++++++++++ tests/src/Builder/DegradedUuidBuilderTest.php | 28 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/src/Builder/DefaultUuidBuilderTest.php create mode 100644 tests/src/Builder/DegradedUuidBuilderTest.php diff --git a/tests/src/Builder/DefaultUuidBuilderTest.php b/tests/src/Builder/DefaultUuidBuilderTest.php new file mode 100644 index 0000000..a5cf4f8 --- /dev/null +++ b/tests/src/Builder/DefaultUuidBuilderTest.php @@ -0,0 +1,28 @@ +getMock('Ramsey\Uuid\Converter\NumberConverterInterface'); + $builder = new DefaultUuidBuilder($converter); + $codec = $this->getMock('Ramsey\Uuid\Codec\CodecInterface'); + + $fields = [ + 'time_low' => '754cd475', + 'time_mid' => '7e58', + 'time_hi_and_version' => '5411', + 'clock_seq_hi_and_reserved' => '73', + 'clock_seq_low' => '22', + 'node' => 'be0725c8ce01' + ]; + + $result = $builder->build($codec, $fields); + $this->assertInstanceOf('Ramsey\Uuid\Uuid', $result); + } +} \ No newline at end of file diff --git a/tests/src/Builder/DegradedUuidBuilderTest.php b/tests/src/Builder/DegradedUuidBuilderTest.php new file mode 100644 index 0000000..b268071 --- /dev/null +++ b/tests/src/Builder/DegradedUuidBuilderTest.php @@ -0,0 +1,28 @@ +getMock('Ramsey\Uuid\Converter\NumberConverterInterface'); + $builder = new DegradedUuidBuilder($converter); + $codec = $this->getMock('Ramsey\Uuid\Codec\CodecInterface'); + + $fields = [ + 'time_low' => '754cd475', + 'time_mid' => '7e58', + 'time_hi_and_version' => '5411', + 'clock_seq_hi_and_reserved' => '73', + 'clock_seq_low' => '22', + 'node' => 'be0725c8ce01' + ]; + + $result = $builder->build($codec, $fields); + $this->assertInstanceOf('Ramsey\Uuid\DegradedUuid', $result); + } +} \ No newline at end of file From d290d45ae7147f487cc3e6fb05f7d9b9578f1b91 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Wed, 16 Mar 2016 11:47:59 -0400 Subject: [PATCH 09/20] add test for phptimeconverter --- .../Converter/Time/PhpTimeConverterTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/src/Converter/Time/PhpTimeConverterTest.php diff --git a/tests/src/Converter/Time/PhpTimeConverterTest.php b/tests/src/Converter/Time/PhpTimeConverterTest.php new file mode 100644 index 0000000..a083774 --- /dev/null +++ b/tests/src/Converter/Time/PhpTimeConverterTest.php @@ -0,0 +1,25 @@ + sprintf('%08x', $calculatedTime & 0xffffffff), + 'mid' => sprintf('%04x', ($calculatedTime >> 32) & 0xffff), + 'hi' => sprintf('%04x', ($calculatedTime >> 48) & 0x0fff) + ]; + + $converter = new PhpTimeConverter(); + $returned = $converter->calculateTime($seconds, $microSeconds); + $this->assertEquals($expectedArray, $returned); + } +} \ No newline at end of file From 392137b0a4c01d8d2ca6410a1d55f73445c5d54b Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Wed, 16 Mar 2016 12:10:07 -0400 Subject: [PATCH 10/20] added test with multiple cases for generate --- tests/src/Generator/MtRandGeneratorTest.php | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/src/Generator/MtRandGeneratorTest.php diff --git a/tests/src/Generator/MtRandGeneratorTest.php b/tests/src/Generator/MtRandGeneratorTest.php new file mode 100644 index 0000000..00501e3 --- /dev/null +++ b/tests/src/Generator/MtRandGeneratorTest.php @@ -0,0 +1,29 @@ +generate($length); + $this->assertEquals($length, strlen($returned)); + } +} \ No newline at end of file From 6b7241c5fc9f2b803735e31573c5c1e92d077496 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Wed, 16 Mar 2016 13:07:04 -0400 Subject: [PATCH 11/20] Comb Generator coverage --- tests/src/Builder/CombGeneratorTest.php | 89 +++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 tests/src/Builder/CombGeneratorTest.php diff --git a/tests/src/Builder/CombGeneratorTest.php b/tests/src/Builder/CombGeneratorTest.php new file mode 100644 index 0000000..cef8d61 --- /dev/null +++ b/tests/src/Builder/CombGeneratorTest.php @@ -0,0 +1,89 @@ +timestampBytes); + $randomGenerator = $this->getMock('Ramsey\Uuid\Generator\RandomGeneratorInterface'); + $randomGenerator->expects($this->once()) + ->method('generate') + ->with($expectedLength); + $converter = $this->getMock('Ramsey\Uuid\Converter\NumberConverterInterface'); + $generator = new CombGenerator($randomGenerator, $converter); + $generator->generate($length); + } + + public function testGenerateCalculatesPaddedHexStringFromCurrentTimestamp() + { + $randomGenerator = $this->getMock('Ramsey\Uuid\Generator\RandomGeneratorInterface'); + $converter = $this->getMock('Ramsey\Uuid\Converter\NumberConverterInterface'); + $converter->expects($this->once()) + ->method('toHex') + ->with($this->isType('string')); + $generator = new CombGenerator($randomGenerator, $converter); + $generator->generate(10); + } + + public function testGenerateReturnsBinaryStringCreatedFromGeneratorAndConverter() + { + $length = 20; + $hash = dechex(1234567891); + $timeHash = dechex(1458147405); + + $randomGenerator = $this->getMock('Ramsey\Uuid\Generator\RandomGeneratorInterface'); + $randomGenerator->method('generate') + ->with(($length - $this->timestampBytes)) + ->willReturn($hash); + + $converter = $this->getMock('Ramsey\Uuid\Converter\NumberConverterInterface'); + $converter->method('toHex') + ->with($this->isType('string')) + ->willReturn($timeHash); + + $time = str_pad($timeHash, 12, '0', STR_PAD_LEFT); + $expected = hex2bin(str_pad(bin2hex($hash), $length - $this->timestampBytes, '0')) . hex2bin($time); + + $generator = new CombGenerator($randomGenerator, $converter); + $returned = $generator->generate($length); + $this->assertInternalType('string', $returned); + $this->assertEquals($expected, $returned); + } + + public function lengthLessThanSix() + { + return [[0], [1], [2], [3], [4], [5]]; + } + + /** + * @dataProvider lengthLessThanSix + */ + public function testGenerateWithLessThanTimestampBytesThrowsException($length) + { + $this->expectException('InvalidArgumentException'); + $randomGenerator = $this->getMock('Ramsey\Uuid\Generator\RandomGeneratorInterface'); + $converter = $this->getMock('Ramsey\Uuid\Converter\NumberConverterInterface'); + $generator = new CombGenerator($randomGenerator, $converter); + $generator->generate($length); + } + + /** + * PHP Unit converts the error to an exception so we can test it. + */ + public function testGenerateWithOddNumberOverTimestampBytesCausesError() + { + $this->expectException('PHPUnit_Framework_Error'); + $randomGenerator = $this->getMock('Ramsey\Uuid\Generator\RandomGeneratorInterface'); + $converter = $this->getMock('Ramsey\Uuid\Converter\NumberConverterInterface'); + $generator = new CombGenerator($randomGenerator, $converter); + $generator->generate(7); + } +} \ No newline at end of file From c16b4f0cf2ad7adbd38c5101cab81bcb88cfb473 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Wed, 16 Mar 2016 15:45:05 -0400 Subject: [PATCH 12/20] add new line --- tests/src/Builder/DegradedUuidBuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Builder/DegradedUuidBuilderTest.php b/tests/src/Builder/DegradedUuidBuilderTest.php index b268071..584ff02 100644 --- a/tests/src/Builder/DegradedUuidBuilderTest.php +++ b/tests/src/Builder/DegradedUuidBuilderTest.php @@ -25,4 +25,4 @@ class DegradedUuidBuilderTest extends \PHPUnit_Framework_TestCase $result = $builder->build($codec, $fields); $this->assertInstanceOf('Ramsey\Uuid\DegradedUuid', $result); } -} \ No newline at end of file +} From 16bf69ad396c8b9bf7eef223e50b41b7d224603c Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Wed, 16 Mar 2016 15:50:19 -0400 Subject: [PATCH 13/20] more new lines --- tests/src/Builder/CombGeneratorTest.php | 2 +- tests/src/Converter/Time/PhpTimeConverterTest.php | 2 +- tests/src/Generator/MtRandGeneratorTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/src/Builder/CombGeneratorTest.php b/tests/src/Builder/CombGeneratorTest.php index cef8d61..7ff351c 100644 --- a/tests/src/Builder/CombGeneratorTest.php +++ b/tests/src/Builder/CombGeneratorTest.php @@ -86,4 +86,4 @@ class CombGeneratorTest extends \PHPUnit_Framework_TestCase $generator = new CombGenerator($randomGenerator, $converter); $generator->generate(7); } -} \ No newline at end of file +} diff --git a/tests/src/Converter/Time/PhpTimeConverterTest.php b/tests/src/Converter/Time/PhpTimeConverterTest.php index a083774..80cfa9e 100644 --- a/tests/src/Converter/Time/PhpTimeConverterTest.php +++ b/tests/src/Converter/Time/PhpTimeConverterTest.php @@ -22,4 +22,4 @@ class PhpTimeConverterTest extends \PHPUnit_Framework_TestCase $returned = $converter->calculateTime($seconds, $microSeconds); $this->assertEquals($expectedArray, $returned); } -} \ No newline at end of file +} diff --git a/tests/src/Generator/MtRandGeneratorTest.php b/tests/src/Generator/MtRandGeneratorTest.php index 00501e3..75eeb0c 100644 --- a/tests/src/Generator/MtRandGeneratorTest.php +++ b/tests/src/Generator/MtRandGeneratorTest.php @@ -26,4 +26,4 @@ class MtRandGeneratorTest extends \PHPUnit_Framework_TestCase $returned = $generator->generate($length); $this->assertEquals($length, strlen($returned)); } -} \ No newline at end of file +} From ab0b2c5fa922ca7bbedd809a330877cd8637d868 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Wed, 16 Mar 2016 15:58:31 -0400 Subject: [PATCH 14/20] more new lines --- tests/src/Builder/DefaultUuidBuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Builder/DefaultUuidBuilderTest.php b/tests/src/Builder/DefaultUuidBuilderTest.php index a5cf4f8..10db9b2 100644 --- a/tests/src/Builder/DefaultUuidBuilderTest.php +++ b/tests/src/Builder/DefaultUuidBuilderTest.php @@ -25,4 +25,4 @@ class DefaultUuidBuilderTest extends \PHPUnit_Framework_TestCase $result = $builder->build($codec, $fields); $this->assertInstanceOf('Ramsey\Uuid\Uuid', $result); } -} \ No newline at end of file +} From c0a6f9d426c99441304aedeab3a659f3fbdcdf55 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Wed, 16 Mar 2016 16:06:35 -0400 Subject: [PATCH 15/20] apparently the phpunit on travis is older --- tests/src/Builder/CombGeneratorTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/Builder/CombGeneratorTest.php b/tests/src/Builder/CombGeneratorTest.php index 7ff351c..fbff687 100644 --- a/tests/src/Builder/CombGeneratorTest.php +++ b/tests/src/Builder/CombGeneratorTest.php @@ -68,7 +68,7 @@ class CombGeneratorTest extends \PHPUnit_Framework_TestCase */ public function testGenerateWithLessThanTimestampBytesThrowsException($length) { - $this->expectException('InvalidArgumentException'); + $this->setExpectedException('InvalidArgumentException'); $randomGenerator = $this->getMock('Ramsey\Uuid\Generator\RandomGeneratorInterface'); $converter = $this->getMock('Ramsey\Uuid\Converter\NumberConverterInterface'); $generator = new CombGenerator($randomGenerator, $converter); @@ -80,7 +80,7 @@ class CombGeneratorTest extends \PHPUnit_Framework_TestCase */ public function testGenerateWithOddNumberOverTimestampBytesCausesError() { - $this->expectException('PHPUnit_Framework_Error'); + $this->setExpectedException('PHPUnit_Framework_Error'); $randomGenerator = $this->getMock('Ramsey\Uuid\Generator\RandomGeneratorInterface'); $converter = $this->getMock('Ramsey\Uuid\Converter\NumberConverterInterface'); $generator = new CombGenerator($randomGenerator, $converter); From 76a6ac3dce673b9c7e65764be0af8f5d6b741257 Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Thu, 17 Mar 2016 01:14:25 -0400 Subject: [PATCH 16/20] Move Mockery to dev --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 4f7a5c4..b2df6a5 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,7 @@ "source": "https://github.com/ramsey/uuid" }, "require": { - "php": ">=5.4", - "mockery/mockery": "^0.9.4" + "php": ">=5.4" }, "require-dev": { "moontoast/math": "^1.1", @@ -35,7 +34,8 @@ "squizlabs/php_codesniffer": "^2.3", "jakub-onderka/php-parallel-lint": "^0.9.0", "satooshi/php-coveralls": "^0.6.1", - "apigen/apigen": "^4.1" + "apigen/apigen": "^4.1", + "mockery/mockery": "^0.9.4" }, "suggest": { "ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter", From 5afe09caea7bf494f9cf0d50956ae75b6b39625c Mon Sep 17 00:00:00 2001 From: Jessica Mauerhan Date: Thu, 17 Mar 2016 01:16:00 -0400 Subject: [PATCH 17/20] Tests using overload should be run in separate process --- tests/src/Generator/RandomLibAdapterTest.php | 34 +++++++++++--------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tests/src/Generator/RandomLibAdapterTest.php b/tests/src/Generator/RandomLibAdapterTest.php index b34918a..b91ed12 100644 --- a/tests/src/Generator/RandomLibAdapterTest.php +++ b/tests/src/Generator/RandomLibAdapterTest.php @@ -22,33 +22,37 @@ class RandomLibAdapterTest extends TestCase { $factory = Mockery::mock('overload:RandomLib\Factory'); $factory->shouldNotReceive('getMediumStrengthGenerator') - ->getMock(); + ->getMock(); $generator = $this->getMockBuilder('RandomLib\Generator') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); new RandomLibAdapter($generator); } + /** + * @runInSeparateProcess + * @preserveGlobalState disabled + */ public function testAdapterWithoutGeneratorGreatesGenerator() { $factory = Mockery::mock('overload:RandomLib\Factory'); $factory->shouldReceive('getMediumStrengthGenerator') - ->once() - ->getMock(); + ->once() + ->getMock(); new RandomLibAdapter(); } public function testGenerateUsesGenerator() { - $length = 10; + $length = 10; $generator = $this->getMockBuilder('RandomLib\Generator') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $generator->expects($this->once()) - ->method('generate') - ->with($length); + ->method('generate') + ->with($length); $adapter = new RandomLibAdapter($generator); $adapter->generate($length); @@ -57,14 +61,14 @@ class RandomLibAdapterTest extends TestCase public function testGenerateReturnsString() { $generator = $this->getMockBuilder('RandomLib\Generator') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $generator->expects($this->once()) - ->method('generate') - ->willReturn('random-string'); + ->method('generate') + ->willReturn('random-string'); $adapter = new RandomLibAdapter($generator); - $result = $adapter->generate(1); + $result = $adapter->generate(1); $this->assertEquals('random-string', $result); } } From 89b9a33431d27c8a27b500692bc0e83c2348d566 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Thu, 17 Mar 2016 11:04:58 -0500 Subject: [PATCH 18/20] Rename conduct file, according to Contributor Covenant recommendations --- CONDUCT.md => CODE_OF_CONDUCT.md | 0 CONTRIBUTING.md | 2 +- README.md | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename CONDUCT.md => CODE_OF_CONDUCT.md (100%) diff --git a/CONDUCT.md b/CODE_OF_CONDUCT.md similarity index 100% rename from CONDUCT.md rename to CODE_OF_CONDUCT.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0977458..6dabe40 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Contributions are welcome. We accept pull requests on [GitHub](https://github.com/ramsey/uuid). -This project adheres to a [Contributor Code of Conduct](https://github.com/ramsey/uuid/blob/master/CONDUCT.md). By participating in this project and its community, you are expected to uphold this code. +This project adheres to a [Contributor Code of Conduct](https://github.com/ramsey/uuid/blob/master/CODE_OF_CONDUCT.md). By participating in this project and its community, you are expected to uphold this code. ## Team members diff --git a/README.md b/README.md index 7e9fc7c..8ca2849 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ The ramsey/uuid library is copyright © [Ben Ramsey](https://benramsey.com/) and [rfc4122]: http://tools.ietf.org/html/rfc4122 -[conduct]: https://github.com/ramsey/uuid/blob/master/CONDUCT.md +[conduct]: https://github.com/ramsey/uuid/blob/master/CODE_OF_CONDUCT.md [javauuid]: http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html [pyuuid]: http://docs.python.org/3/library/uuid.html [packagist]: https://packagist.org/packages/ramsey/uuid From 3c636a7e65949a998a1a25d03b9036e185d5cca1 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Thu, 17 Mar 2016 11:11:46 -0500 Subject: [PATCH 19/20] Update code to conduct to version 1.4 of the Contributor Covenant --- CODE_OF_CONDUCT.md | 74 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 01b8644..9c20725 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,22 +1,74 @@ # Contributor Code of Conduct -As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. +## Our Pledge -We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment -* Publishing other's private information, such as physical or electronic addresses, without explicit permission -* Other unethical or unprofessional conduct. +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. +## Our Responsibilities -This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. -This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project maintainer at . All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ From 8d94d71d182d049d8c58a1e2086dac6729b9bc03 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Thu, 17 Mar 2016 11:19:53 -0500 Subject: [PATCH 20/20] Add code of conduct to the 2.8 branch for inclusion in new 2.x releases --- CODE_OF_CONDUCT.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 2 +- README.md | 2 ++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..9c20725 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project maintainer at . All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3cd9dc1..1696f88 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Contributions are welcome. We accept pull requests on [GitHub](https://github.com/ramsey/uuid). -_**Please note:** Currently, all active development is working towards the major 3.0 release. This work is taking place in the `master` branch. If you have patches for the 2.x series, please send those to the `2.8` branch._ +This project adheres to a [Contributor Code of Conduct](https://github.com/ramsey/uuid/blob/master/CODE_OF_CONDUCT.md). By participating in this project and its community, you are expected to uphold this code. ## Team members diff --git a/README.md b/README.md index d5b3e56..c289c58 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ [![Total Downloads](https://poser.pugx.org/rhumsaa/uuid/downloads.png)](https://packagist.org/packages/rhumsaa/uuid) [![HHVM Status](http://hhvm.h4cc.de/badge/rhumsaa/uuid.png)](http://hhvm.h4cc.de/package/rhumsaa/uuid) +This project adheres to a [Contributor Code of Conduct](https://github.com/ramsey/uuid/blob/master/CODE_OF_CONDUCT.md). By participating in this project and its community, you are expected to uphold this code. + ## About Rhumsaa\Uuid is a PHP 5.3+ library for generating and working with