Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ 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
psalm:
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'
12 changes: 12 additions & 0 deletions .github/workflows/extensive.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [Unreleased]

### Changed

- Requires PHP `8.4`
- Requires `innmind/filesystem:~9.0`

## 4.0.0 - 2025-04-18

### Added
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# 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)

Graphviz model to help build graphs. This model goal is to express the possibilities offered by Graphviz (though note that all features are not implemented).

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

Expand Down Expand Up @@ -66,6 +67,7 @@ Factory::build()
->withShortOption('o', 'graph.svg')
->withInput($output),
)
->unwrap()
->wait();
```

Expand Down
4 changes: 4 additions & 0 deletions blackbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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"
}
}
14 changes: 7 additions & 7 deletions tests/Attribute/ValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
}
6 changes: 3 additions & 3 deletions tests/Edge/ShapeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
Expand Down
20 changes: 10 additions & 10 deletions tests/EdgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions tests/Graph/NameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 11 additions & 11 deletions tests/GraphTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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());
}

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions tests/Layout/DPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
}
Expand Down
Loading
Loading