diff --git a/composer.lock b/composer.lock index c778e2d..d9af61f 100644 --- a/composer.lock +++ b/composer.lock @@ -484,12 +484,12 @@ "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "6a18fd75962f12db61384991797ba7c99de19bf4" + "reference": "7f8dd8a93eb89d87de39e04ca9c284c60e1ef807" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/6a18fd75962f12db61384991797ba7c99de19bf4", - "reference": "6a18fd75962f12db61384991797ba7c99de19bf4", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/7f8dd8a93eb89d87de39e04ca9c284c60e1ef807", + "reference": "7f8dd8a93eb89d87de39e04ca9c284c60e1ef807", "shasum": "" }, "require": { @@ -556,6 +556,7 @@ "tests/Test/IntegrationCaseFactoryInterface.php", "tests/Test/InternalIntegrationCaseFactory.php", "tests/Test/IsIdenticalConstraint.php", + "tests/Test/TokensWithObservedTransformers.php", "tests/TestCase.php" ] }, @@ -584,7 +585,7 @@ "type": "github" } ], - "time": "2021-02-18T17:03:44+00:00" + "time": "2021-03-03T16:08:57+00:00" }, { "name": "myclabs/deep-copy", @@ -2578,16 +2579,16 @@ }, { "name": "symfony/console", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a" + "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/89d4b176d12a2946a1ae4e34906a025b7b6b135a", - "reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a", + "url": "https://api.github.com/repos/symfony/console/zipball/d6d0cc30d8c0fda4e7b213c20509b0159a8f4556", + "reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556", "shasum": "" }, "require": { @@ -2655,7 +2656,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.2.3" + "source": "https://github.com/symfony/console/tree/v5.2.4" }, "funding": [ { @@ -2671,7 +2672,7 @@ "type": "tidelift" } ], - "time": "2021-01-28T22:06:19+00:00" + "time": "2021-02-23T10:08:49+00:00" }, { "name": "symfony/deprecation-contracts", @@ -2742,16 +2743,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "4f9760f8074978ad82e2ce854dff79a71fe45367" + "reference": "d08d6ec121a425897951900ab692b612a61d6240" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4f9760f8074978ad82e2ce854dff79a71fe45367", - "reference": "4f9760f8074978ad82e2ce854dff79a71fe45367", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d08d6ec121a425897951900ab692b612a61d6240", + "reference": "d08d6ec121a425897951900ab692b612a61d6240", "shasum": "" }, "require": { @@ -2807,7 +2808,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.2.3" + "source": "https://github.com/symfony/event-dispatcher/tree/v5.2.4" }, "funding": [ { @@ -2823,7 +2824,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T10:36:42+00:00" + "time": "2021-02-18T17:12:37+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -2906,16 +2907,16 @@ }, { "name": "symfony/filesystem", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "262d033b57c73e8b59cd6e68a45c528318b15038" + "reference": "710d364200997a5afde34d9fe57bd52f3cc1e108" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/262d033b57c73e8b59cd6e68a45c528318b15038", - "reference": "262d033b57c73e8b59cd6e68a45c528318b15038", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/710d364200997a5afde34d9fe57bd52f3cc1e108", + "reference": "710d364200997a5afde34d9fe57bd52f3cc1e108", "shasum": "" }, "require": { @@ -2948,7 +2949,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.2.3" + "source": "https://github.com/symfony/filesystem/tree/v5.2.4" }, "funding": [ { @@ -2964,20 +2965,20 @@ "type": "tidelift" } ], - "time": "2021-01-27T10:01:46+00:00" + "time": "2021-02-12T10:38:38+00:00" }, { "name": "symfony/finder", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "4adc8d172d602008c204c2e16956f99257248e03" + "reference": "0d639a0943822626290d169965804f79400e6a04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/4adc8d172d602008c204c2e16956f99257248e03", - "reference": "4adc8d172d602008c204c2e16956f99257248e03", + "url": "https://api.github.com/repos/symfony/finder/zipball/0d639a0943822626290d169965804f79400e6a04", + "reference": "0d639a0943822626290d169965804f79400e6a04", "shasum": "" }, "require": { @@ -3009,7 +3010,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.2.3" + "source": "https://github.com/symfony/finder/tree/v5.2.4" }, "funding": [ { @@ -3025,11 +3026,11 @@ "type": "tidelift" } ], - "time": "2021-01-28T22:06:19+00:00" + "time": "2021-02-15T18:55:04+00:00" }, { "name": "symfony/options-resolver", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", @@ -3078,7 +3079,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v5.2.3" + "source": "https://github.com/symfony/options-resolver/tree/v5.2.4" }, "funding": [ { @@ -3728,7 +3729,7 @@ }, { "name": "symfony/process", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -3770,7 +3771,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.2.3" + "source": "https://github.com/symfony/process/tree/v5.2.4" }, "funding": [ { @@ -3869,7 +3870,7 @@ }, { "name": "symfony/stopwatch", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", @@ -3911,7 +3912,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.2.3" + "source": "https://github.com/symfony/stopwatch/tree/v5.2.4" }, "funding": [ { @@ -3931,16 +3932,16 @@ }, { "name": "symfony/string", - "version": "v5.2.3", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "c95468897f408dd0aca2ff582074423dd0455122" + "reference": "4e78d7d47061fa183639927ec40d607973699609" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/c95468897f408dd0aca2ff582074423dd0455122", - "reference": "c95468897f408dd0aca2ff582074423dd0455122", + "url": "https://api.github.com/repos/symfony/string/zipball/4e78d7d47061fa183639927ec40d607973699609", + "reference": "4e78d7d47061fa183639927ec40d607973699609", "shasum": "" }, "require": { @@ -3994,7 +3995,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.2.3" + "source": "https://github.com/symfony/string/tree/v5.2.4" }, "funding": [ { @@ -4010,7 +4011,7 @@ "type": "tidelift" } ], - "time": "2021-01-25T15:14:59+00:00" + "time": "2021-02-16T10:20:28+00:00" }, { "name": "theseer/tokenizer", diff --git a/src/Collection.php b/src/Collection.php index dfecee6..1930111 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -55,7 +55,7 @@ class Collection implements * @param int $modifier * @param int $multiplier */ - public function __construct(int $amount, int $sides, int $modifier, int $multiplier) + public function __construct(int $amount, int $sides, int $modifier = 1, int $multiplier = 1) { if ($amount < 1) { throw new OutOfRangeException('A collection must have at least one dice.'); diff --git a/tests/src/Unit/CupTest.php b/tests/src/Unit/CupTest.php new file mode 100644 index 0000000..0aee306 --- /dev/null +++ b/tests/src/Unit/CupTest.php @@ -0,0 +1,127 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Ouxsoft\LivingMarkup\Tests\Unit; + +use Ouxsoft\LuckByDice\Cup; +use Ouxsoft\LuckByDice\Collection; +use PHPUnit\Framework\TestCase; + +class CupTest extends TestCase +{ + private $cup; + + public function setUp(): void + { + $this->cup = new Cup(); + $this->cup[] = new Collection(1, 6, 1, 1); + $this->cup[] = new Collection(1, 8, 1, 1); + } + + public function tearDown(): void + { + unset($this->cup); + } + + /** + * @covers \Ouxsoft\LuckByDice\Cup::offsetExists + */ + public function testOffsetExists() + { + $this->assertTrue($this->cup->offsetExists(1)); + } + + /** + * @covers \Ouxsoft\LuckByDice\Cup::offsetGet + */ + public function testOffsetGet() + { + $collection = new Collection(1, 8, 1, 1); + $this->assertEquals($collection, $this->cup->offsetGet(1)); + } + + /** + * @covers \Ouxsoft\LuckByDice\Cup::offsetSet + */ + public function testOffsetSet() + { + $collection = new Collection(1, 8, 1, 1); + $this->cup[] = $collection; + $this->assertEquals($collection, $this->cup->offsetGet(2)); + } + + /** + * @covers \Ouxsoft\LuckByDice\Cup::offsetUnset + */ + public function testOffsetUnset() + { + $this->cup->offsetUnset('k'); + $this->assertArrayNotHasKey('k', $this->cup); + } + + /** + * @covers \Ouxsoft\LuckByDice\Cup::current + */ + public function testCurrent() + { + $current = $this->cup->current(); + $this->assertInstanceOf(Collection::class, $current); + } + + /** + * @covers \Ouxsoft\LuckByDice\Cup::next + */ + public function testNext() + { + $this->cup->next(); + $key = $this->cup->key(); + $this->assertEquals(1, $key); + } + + /** + * @covers \Ouxsoft\LuckByDice\Cup::key + */ + public function testKey() + { + $key = $this->cup->key(); + $this->assertEquals(0, $key); + } + + /** + * @covers \Ouxsoft\LuckByDice\Cup::valid + */ + public function testValid() + { + $this->assertTrue($this->cup->valid()); + } + + /** + * @covers \Ouxsoft\LuckByDice\Cup::rewind + */ + public function testRewind() + { + $this->cup->next(); + $this->cup->rewind(); + $key = $this->cup->key(); + $this->assertEquals(0, $key); + } + + /** + * @covers \Ouxsoft\LuckByDice\Cup::reverse + */ + public function testReverse() + { + $this->cup->reverse(); + + $key = $this->cup->key(); + $this->assertEquals(0, $key); + } + +} diff --git a/tests/src/Unit/DiceTest.php b/tests/src/Unit/DiceTest.php index ee4dea2..01b2e6a 100644 --- a/tests/src/Unit/DiceTest.php +++ b/tests/src/Unit/DiceTest.php @@ -1,5 +1,4 @@