diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67d292d..2f3eecb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,6 @@ on: [push, pull_request] jobs: blackbox: uses: innmind/github-workflows/.github/workflows/black-box-matrix.yml@main - with: - scenarii: 20 # optional coverage: uses: innmind/github-workflows/.github/workflows/coverage-matrix.yml@main secrets: inherit @@ -14,5 +12,3 @@ jobs: uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main cs: uses: innmind/github-workflows/.github/workflows/cs.yml@main - with: - php-version: '8.2' diff --git a/.github/workflows/extensive.yml b/.github/workflows/extensive.yml new file mode 100644 index 0000000..257f139 --- /dev/null +++ b/.github/workflows/extensive.yml @@ -0,0 +1,12 @@ +name: Extensive CI + +on: + push: + tags: + - '*' + paths: + - '.github/workflows/extensive.yml' + +jobs: + blackbox: + uses: innmind/github-workflows/.github/workflows/extensive.yml@main diff --git a/CHANGELOG.md b/CHANGELOG.md index 0927f49..e739d19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [Unreleased] + +### Changed + +- Requires PHP `8.4` +- Requires `innmind/filesystem:~9.0` + ## 4.0.0 - 2025-04-18 ### Added diff --git a/README.md b/README.md index f743176..f4da697 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Graphviz -[![Build Status](https://github.com/innmind/graphviz/workflows/CI/badge.svg?branch=master)](https://github.com/innmind/graphviz/actions?query=workflow%3ACI) +[![CI](https://github.com/Innmind/Graphviz/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Innmind/Graphviz/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/innmind/graphviz/branch/develop/graph/badge.svg)](https://codecov.io/gh/innmind/graphviz) [![Type Coverage](https://shepherd.dev/github/innmind/graphviz/coverage.svg)](https://shepherd.dev/github/innmind/graphviz) @@ -8,7 +8,8 @@ Graphviz model to help build graphs. This model goal is to express the possibili All objects of this package are immutable. -**Important**: you must use [`vimeo/psalm`](https://packagist.org/packages/vimeo/psalm) to make sure you use this library correctly. +> [!IMPORTANT] +> You must use [`vimeo/psalm`](https://packagist.org/packages/vimeo/psalm) to make sure you use this library correctly. ## Installation @@ -66,6 +67,7 @@ Factory::build() ->withShortOption('o', 'graph.svg') ->withInput($output), ) + ->unwrap() ->wait(); ``` diff --git a/blackbox.php b/blackbox.php index d38765c..78fee2e 100644 --- a/blackbox.php +++ b/blackbox.php @@ -10,6 +10,10 @@ }; Application::new($argv) + ->when( + \getenv('BLACKBOX_SET_SIZE') !== false, + static fn(Application $app) => $app->scenariiPerProof((int) \getenv('BLACKBOX_SET_SIZE')), + ) ->when( \getenv('ENABLE_COVERAGE') !== false, static fn(Application $app) => $app->codeCoverage( diff --git a/composer.json b/composer.json index 9a59ef6..009352b 100644 --- a/composer.json +++ b/composer.json @@ -14,11 +14,11 @@ "issues": "http://github.com/Innmind/Graphviz/issues" }, "require": { - "php": "~8.2", - "innmind/immutable": "~5.0", - "innmind/url": "~4.0", - "innmind/colour": "~4.0", - "innmind/filesystem": "~7.0|~8.0" + "php": "~8.4", + "innmind/immutable": "~6.0", + "innmind/url": "~5.0", + "innmind/colour": "~5.0", + "innmind/filesystem": "~9.0" }, "autoload": { "psr-4": { @@ -31,8 +31,8 @@ } }, "require-dev": { - "innmind/static-analysis": "^1.2.1", - "innmind/black-box": "~6.1", + "innmind/static-analysis": "~1.3", + "innmind/black-box": "~6.5", "innmind/coding-standard": "~2.0" } } diff --git a/tests/Attribute/ValueTest.php b/tests/Attribute/ValueTest.php index 9a88b69..3f20685 100644 --- a/tests/Attribute/ValueTest.php +++ b/tests/Attribute/ValueTest.php @@ -17,24 +17,24 @@ class ValueTest extends TestCase { use BlackBox; - public function testInterface() + public function testInterface(): BlackBox\Proof { - $this + return $this ->forAll( Set::sequence( Set::strings()->unicode()->char()->filter(static fn($s) => $s !== "\x00"), )->map(static fn($chars) => \implode('', $chars)), ) - ->then(function(string $string): void { + ->prove(function(string $string): void { $this->assertSame($string, Value::of($string)->toString()); }); } public function testThrowWhenItContainsANullCharacter() { - $this->expectException(DomainException::class); - $this->expectExceptionMessage("foo\x00bar"); - - Value::of("foo\x00bar"); + $this->assert()->throws( + static fn() => Value::of("foo\x00bar"), + DomainException::class, + ); } } diff --git a/tests/Edge/ShapeTest.php b/tests/Edge/ShapeTest.php index 7a411d3..b2c449f 100644 --- a/tests/Edge/ShapeTest.php +++ b/tests/Edge/ShapeTest.php @@ -14,11 +14,11 @@ class ShapeTest extends TestCase { use BlackBox; - public function testShape() + public function testShape(): BlackBox\Proof { - $this + return $this ->forAll($this->shapes()) - ->then(function(string $shape): void { + ->prove(function(string $shape): void { $this->assertInstanceOf(Shape::class, Shape::$shape()); $this->assertSame($shape, Shape::$shape()->toString()); }); diff --git a/tests/EdgeTest.php b/tests/EdgeTest.php index a0072cf..3d7db14 100644 --- a/tests/EdgeTest.php +++ b/tests/EdgeTest.php @@ -43,7 +43,7 @@ public function testAsBidirectional() Name::of('b'), )->asBidirectional(); - $this->assertCount(1, $edge->attributes()); + $this->assertSame(1, $edge->attributes()->size()); $this->assertSame('both', $edge->attributes()->get('dir')->match( static fn($value) => $value, static fn() => null, @@ -57,7 +57,7 @@ public function testWithoutDirection() Name::of('b'), )->withoutDirection(); - $this->assertCount(1, $edge->attributes()); + $this->assertSame(1, $edge->attributes()->size()); $this->assertSame('none', $edge->attributes()->get('dir')->match( static fn($value) => $value, static fn() => null, @@ -77,7 +77,7 @@ public function testShaped() Shape::dot(), ); - $this->assertCount(1, $edge->attributes()); + $this->assertSame(1, $edge->attributes()->size()); $this->assertSame('boxveeteedot', $edge->attributes()->get('arrowhead')->match( static fn($value) => $value, static fn() => null, @@ -98,7 +98,7 @@ public function testShapedWhenBidirectional() Shape::dot(), ); - $this->assertCount(3, $edge->attributes()); + $this->assertSame(3, $edge->attributes()->size()); $this->assertSame('boxveeteedot', $edge->attributes()->get('arrowtail')->match( static fn($value) => $value, static fn() => null, @@ -116,7 +116,7 @@ public function testDisplayAs() Name::of('b'), )->displayAs('foo'); - $this->assertCount(1, $edge->attributes()); + $this->assertSame(1, $edge->attributes()->size()); $this->assertSame('foo', $edge->attributes()->get('label')->match( static fn($value) => $value, static fn() => null, @@ -130,7 +130,7 @@ public function testUseColor() Name::of('b'), )->useColor(Colour::red->toRGBA()); - $this->assertCount(1, $edge->attributes()); + $this->assertSame(1, $edge->attributes()->size()); $this->assertSame('#ff0000', $edge->attributes()->get('color')->match( static fn($value) => $value, static fn() => null, @@ -144,7 +144,7 @@ public function testTarget() Name::of('b'), )->target(Url::of('example.com')); - $this->assertCount(1, $edge->attributes()); + $this->assertSame(1, $edge->attributes()->size()); $this->assertSame('example.com', $edge->attributes()->get('URL')->match( static fn($value) => $value, static fn() => null, @@ -158,7 +158,7 @@ public function testDotted() Name::of('b'), )->dotted(); - $this->assertCount(1, $edge->attributes()); + $this->assertSame(1, $edge->attributes()->size()); $this->assertSame('dotted', $edge->attributes()->get('style')->match( static fn($value) => $value, static fn() => null, @@ -172,7 +172,7 @@ public function testBold() Name::of('b'), )->bold(); - $this->assertCount(1, $edge->attributes()); + $this->assertSame(1, $edge->attributes()->size()); $this->assertSame('bold', $edge->attributes()->get('style')->match( static fn($value) => $value, static fn() => null, @@ -186,7 +186,7 @@ public function testFilled() Name::of('b'), )->filled(); - $this->assertCount(1, $edge->attributes()); + $this->assertSame(1, $edge->attributes()->size()); $this->assertSame('filled', $edge->attributes()->get('style')->match( static fn($value) => $value, static fn() => null, diff --git a/tests/Graph/NameTest.php b/tests/Graph/NameTest.php index ab13a29..d8b2aa5 100644 --- a/tests/Graph/NameTest.php +++ b/tests/Graph/NameTest.php @@ -17,26 +17,26 @@ class NameTest extends TestCase { use BlackBox; - public function testInterface() + public function testInterface(): BlackBox\Proof { - $this + return $this ->forAll(Set::strings()) ->filter(static function(string $string): bool { return (bool) \preg_match('~[a-zA-Z0-9_]+~', $string); }) - ->then(function(string $string): void { + ->prove(function(string $string): void { $this->assertSame($string, Name::of($string)->toString()); }); } - public function testThrowWhenContainingInvalidCharacters() + public function testThrowWhenContainingInvalidCharacters(): BlackBox\Proof { - $this + return $this ->forAll(Set::strings()) ->filter(static function(string $string): bool { return !\preg_match('~[a-zA-Z0-9_]+~', $string); }) - ->then(function(string $string): void { + ->prove(function(string $string): void { $this->expectException(DomainException::class); Name::of($string); diff --git a/tests/GraphTest.php b/tests/GraphTest.php index b73e801..2b0373b 100644 --- a/tests/GraphTest.php +++ b/tests/GraphTest.php @@ -39,9 +39,9 @@ public function testAdd() $graph = Graph::directed(); $this->assertInstanceOf(Set::class, $graph->roots()); - $this->assertCount(0, $graph->roots()); + $this->assertSame(0, $graph->roots()->size()); $this->assertInstanceOf(Set::class, $graph->nodes()); - $this->assertCount(0, $graph->nodes()); + $this->assertSame(0, $graph->nodes()->size()); $third = Node::named('third'); $root = Node::named('main')->linkedTo(Node\Name::of('second')); @@ -52,12 +52,12 @@ public function testAdd() ->add($second) ->add($third); - $this->assertCount(1, $graph->roots()); + $this->assertSame(1, $graph->roots()->size()); $this->assertSame($root, $graph->roots()->find(static fn() => true)->match( static fn($root) => $root, static fn() => null, )); - $this->assertCount(3, $graph->nodes()); + $this->assertSame(3, $graph->nodes()->size()); $this->assertSame([$root, $second, $third], $graph->nodes()->toList()); } @@ -66,11 +66,11 @@ public function testCluster() $root = Graph::directed(); $this->assertInstanceOf(Set::class, $root->clusters()); - $this->assertCount(0, $root->clusters()); + $this->assertSame(0, $root->clusters()->size()); $cluster = Graph::directed('foo'); $root = $root->cluster($cluster); - $this->assertCount(1, $root->clusters()); + $this->assertSame(1, $root->clusters()->size()); $this->assertSame($cluster, $root->clusters()->find(static fn() => true)->match( static fn($cluster) => $cluster, static fn() => null, @@ -82,14 +82,14 @@ public function testAttributes() $graph = Graph::directed(); $this->assertInstanceOf(Map::class, $graph->attributes()); - $this->assertCount(0, $graph->attributes()); + $this->assertSame(0, $graph->attributes()->size()); } public function testDisplayAs() { $graph = Graph::directed()->displayAs('watev'); - $this->assertCount(1, $graph->attributes()); + $this->assertSame(1, $graph->attributes()->size()); $this->assertSame('watev', $graph->attributes()->get('label')->match( static fn($value) => $value, static fn() => null, @@ -100,7 +100,7 @@ public function testFillWithColor() { $graph = Graph::directed()->fillWithColor(Colour::red->toRGBA()); - $this->assertCount(2, $graph->attributes()); + $this->assertSame(2, $graph->attributes()->size()); $this->assertSame('filled', $graph->attributes()->get('style')->match( static fn($value) => $value, static fn() => null, @@ -115,7 +115,7 @@ public function testColorizeBorderWith() { $graph = Graph::directed()->colorizeBorderWith(Colour::red->toRGBA()); - $this->assertCount(1, $graph->attributes()); + $this->assertSame(1, $graph->attributes()->size()); $this->assertSame('#ff0000', $graph->attributes()->get('color')->match( static fn($value) => $value, static fn() => null, @@ -126,7 +126,7 @@ public function testTarget() { $graph = Graph::directed()->target(Url::of('example.com')); - $this->assertCount(1, $graph->attributes()); + $this->assertSame(1, $graph->attributes()->size()); $this->assertSame('example.com', $graph->attributes()->get('URL')->match( static fn($value) => $value, static fn() => null, diff --git a/tests/Layout/DPITest.php b/tests/Layout/DPITest.php index 17063dc..d152a5b 100644 --- a/tests/Layout/DPITest.php +++ b/tests/Layout/DPITest.php @@ -14,11 +14,11 @@ class DPITest extends TestCase { use BlackBox; - public function testInterface() + public function testInterface(): BlackBox\Proof { - $this + return $this ->forAll(Set::integers()->above(1)) - ->then(function(int $int): void { + ->prove(function(int $int): void { $this->assertSame($int, DPI::of($int)->toInt()); }); } diff --git a/tests/Node/NameTest.php b/tests/Node/NameTest.php index c71cff1..fd41804 100644 --- a/tests/Node/NameTest.php +++ b/tests/Node/NameTest.php @@ -17,43 +17,47 @@ class NameTest extends TestCase { use BlackBox; - public function testInterface() + public function testInterface(): BlackBox\Proof { - $this + return $this ->forAll(Set::strings()) ->filter(static function(string $string): bool { return \strlen($string) > 0 && \strpos($string, '->') === false && \strpos($string, '-') === false && \strpos($string, '.') === false && \strpos($string, "\x00") === false; }) - ->then(function(string $string): void { + ->prove(function(string $string): void { $this->assertSame($string, Name::of($string)->toString()); }); } public function testThrowWhenContainingAnArrow() { - $this->expectException(DomainException::class); - - Name::of('->'); + $this->assert()->throws( + static fn() => Name::of('->'), + DomainException::class, + ); } public function testThrowWhenContainingAnDash() { - $this->expectException(DomainException::class); - - Name::of('-'); + $this->assert()->throws( + static fn() => Name::of('-'), + DomainException::class, + ); } public function testThrowWhenContainingADot() { - $this->expectException(DomainException::class); - - Name::of('.'); + $this->assert()->throws( + static fn() => Name::of('.'), + DomainException::class, + ); } public function testThrowWhenContainingANullCharacter() { - $this->expectException(DomainException::class); - - Name::of("\x00"); + $this->assert()->throws( + static fn() => Name::of("\x00"), + DomainException::class, + ); } } diff --git a/tests/Node/ShapeTest.php b/tests/Node/ShapeTest.php index bd758d9..167e39d 100644 --- a/tests/Node/ShapeTest.php +++ b/tests/Node/ShapeTest.php @@ -14,7 +14,7 @@ public function testBox() { $this->assertInstanceOf(Shape::class, Shape::box()); $this->assertInstanceOf(Map::class, Shape::box()->attributes()); - $this->assertCount(1, Shape::box()->attributes()); + $this->assertSame(1, Shape::box()->attributes()->size()); $this->assertSame('box', Shape::box()->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -26,14 +26,14 @@ public function testPolygon() $this->assertInstanceOf(Shape::class, Shape::polygon()); $shape = Shape::polygon(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('polygon', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, )); $shape = Shape::polygon(5, 3, 0.74, -0.15); - $this->assertCount(5, $shape->attributes()); + $this->assertSame(5, $shape->attributes()->size()); $this->assertSame('polygon', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -61,7 +61,7 @@ public function testEllipse() $this->assertInstanceOf(Shape::class, Shape::ellipse()); $shape = Shape::ellipse(); - $this->assertCount(3, $shape->attributes()); + $this->assertSame(3, $shape->attributes()->size()); $this->assertSame('ellipse', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -76,7 +76,7 @@ public function testEllipse() )); $shape = Shape::ellipse(.2, 2); - $this->assertCount(3, $shape->attributes()); + $this->assertSame(3, $shape->attributes()->size()); $this->assertSame('ellipse', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -95,7 +95,7 @@ public function testCircle() { $this->assertInstanceOf(Shape::class, Shape::circle()); $shape = Shape::circle(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('circle', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -106,7 +106,7 @@ public function testPoint() { $this->assertInstanceOf(Shape::class, Shape::point()); $shape = Shape::point(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('point', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -117,7 +117,7 @@ public function testEgg() { $this->assertInstanceOf(Shape::class, Shape::egg()); $shape = Shape::egg(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('egg', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -128,7 +128,7 @@ public function testTriangle() { $this->assertInstanceOf(Shape::class, Shape::triangle()); $shape = Shape::triangle(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('triangle', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -139,7 +139,7 @@ public function testPlaintext() { $this->assertInstanceOf(Shape::class, Shape::plaintext()); $shape = Shape::plaintext(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('plaintext', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -150,7 +150,7 @@ public function testDiamond() { $this->assertInstanceOf(Shape::class, Shape::diamond()); $shape = Shape::diamond(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('diamond', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -161,7 +161,7 @@ public function testTrapezium() { $this->assertInstanceOf(Shape::class, Shape::trapezium()); $shape = Shape::trapezium(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('trapezium', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -172,7 +172,7 @@ public function testParallelogram() { $this->assertInstanceOf(Shape::class, Shape::parallelogram()); $shape = Shape::parallelogram(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('parallelogram', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -183,7 +183,7 @@ public function testHouse() { $this->assertInstanceOf(Shape::class, Shape::house()); $shape = Shape::house(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('house', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -194,7 +194,7 @@ public function testHexagon() { $this->assertInstanceOf(Shape::class, Shape::hexagon()); $shape = Shape::hexagon(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('hexagon', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -205,7 +205,7 @@ public function testOctagon() { $this->assertInstanceOf(Shape::class, Shape::octagon()); $shape = Shape::octagon(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('octagon', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -216,7 +216,7 @@ public function testDoublecircle() { $this->assertInstanceOf(Shape::class, Shape::doublecircle()); $shape = Shape::doublecircle(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('doublecircle', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -227,7 +227,7 @@ public function testDoubleoctagon() { $this->assertInstanceOf(Shape::class, Shape::doubleoctagon()); $shape = Shape::doubleoctagon(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('doubleoctagon', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -238,7 +238,7 @@ public function testTripleoctagon() { $this->assertInstanceOf(Shape::class, Shape::tripleoctagon()); $shape = Shape::tripleoctagon(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('tripleoctagon', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -249,7 +249,7 @@ public function testInvtriangle() { $this->assertInstanceOf(Shape::class, Shape::invtriangle()); $shape = Shape::invtriangle(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('invtriangle', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -260,7 +260,7 @@ public function testInvtrapezium() { $this->assertInstanceOf(Shape::class, Shape::invtrapezium()); $shape = Shape::invtrapezium(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('invtrapezium', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -271,7 +271,7 @@ public function testInvhouse() { $this->assertInstanceOf(Shape::class, Shape::invhouse()); $shape = Shape::invhouse(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('invhouse', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -282,7 +282,7 @@ public function testMdiamond() { $this->assertInstanceOf(Shape::class, Shape::Mdiamond()); $shape = Shape::Mdiamond(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('Mdiamond', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -293,7 +293,7 @@ public function testMsquare() { $this->assertInstanceOf(Shape::class, Shape::Msquare()); $shape = Shape::Msquare(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('Msquare', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -304,7 +304,7 @@ public function testMcircle() { $this->assertInstanceOf(Shape::class, Shape::Mcircle()); $shape = Shape::Mcircle(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('Mcircle', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -315,7 +315,7 @@ public function testNone() { $this->assertInstanceOf(Shape::class, Shape::none()); $shape = Shape::none(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('none', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -326,7 +326,7 @@ public function testRecord() { $this->assertInstanceOf(Shape::class, Shape::record()); $shape = Shape::record(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('record', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -337,7 +337,7 @@ public function testMrecord() { $this->assertInstanceOf(Shape::class, Shape::Mrecord()); $shape = Shape::Mrecord(); - $this->assertCount(1, $shape->attributes()); + $this->assertSame(1, $shape->attributes()->size()); $this->assertSame('Mrecord', $shape->attributes()->get('shape')->match( static fn($value) => $value, static fn() => null, @@ -351,8 +351,8 @@ public function testWithColor() $this->assertInstanceOf(Shape::class, $shape2); $this->assertNotSame($shape2, $shape); - $this->assertCount(1, $shape->attributes()); - $this->assertCount(2, $shape2->attributes()); + $this->assertSame(1, $shape->attributes()->size()); + $this->assertSame(2, $shape2->attributes()->size()); $this->assertSame('#0000ff', $shape2->attributes()->get('color')->match( static fn($value) => $value, static fn() => null, @@ -366,8 +366,8 @@ public function testFillWithColor() $this->assertInstanceOf(Shape::class, $shape2); $this->assertNotSame($shape2, $shape); - $this->assertCount(1, $shape->attributes()); - $this->assertCount(3, $shape2->attributes()); + $this->assertSame(1, $shape->attributes()->size()); + $this->assertSame(3, $shape2->attributes()->size()); $this->assertSame('#0000ff', $shape2->attributes()->get('fillcolor')->match( static fn($value) => $value, static fn() => null, diff --git a/tests/NodeTest.php b/tests/NodeTest.php index c719c7f..628b92f 100644 --- a/tests/NodeTest.php +++ b/tests/NodeTest.php @@ -42,7 +42,7 @@ public function testEdges() $to = Name::of('bar'); $this->assertInstanceOf(Set::class, $node->edges()); - $this->assertCount(0, $node->edges()); + $this->assertSame(0, $node->edges()->size()); $node = $node->linkedTo( $to, @@ -55,7 +55,7 @@ function($edge) use ($node, $to) { }, ); - $this->assertCount(1, $node->edges()); + $this->assertSame(1, $node->edges()->size()); } public function testAttributes() @@ -63,14 +63,14 @@ public function testAttributes() $node = Node::of(Name::of('foo')); $this->assertInstanceOf(Map::class, $node->attributes()); - $this->assertCount(0, $node->attributes()); + $this->assertSame(0, $node->attributes()->size()); } public function testTarget() { $node = Node::of(Name::of('foo'))->target($url = Url::of('example.com')); - $this->assertCount(1, $node->attributes()); + $this->assertSame(1, $node->attributes()->size()); $this->assertSame($url->toString(), $node->attributes()->get('URL')->match( static fn($value) => $value, static fn() => null, @@ -81,7 +81,7 @@ public function testLabel() { $node = Node::of(Name::of('foo'))->displayAs('watev'); - $this->assertCount(1, $node->attributes()); + $this->assertSame(1, $node->attributes()->size()); $this->assertSame('watev', $node->attributes()->get('label')->match( static fn($value) => $value, static fn() => null,