Skip to content

Commit

Permalink
Merge pull request #191 from alps-asd/title
Browse files Browse the repository at this point in the history
Display the title correctly
  • Loading branch information
koriym authored Oct 5, 2024
2 parents 3ac6fe9 + 89ce997 commit 4d12465
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Edge.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ private function multipleLink(array $links): string
assert(isset($links[0]));
$trs = '';
foreach ($links as $link) {
$trs .= sprintf('<tr><td align="left" href="#%s" tooltip="%s (%s)" >%s (%s)</td></tr>', $link->transDescriptor->id, $link->transDescriptor->id, $link->transDescriptor->type, $link->transDescriptor->id, $link->transDescriptor->type);
$trs .= sprintf(
'<tr><td align="left" href="#%s" tooltip="%s (%s)" >%s (%s)</td></tr>',
$link->transDescriptor->id,
$link->transDescriptor->id,
$link->transDescriptor->type,
$link->label,
$link->transDescriptor->type
);
}

$base = ' %s -> %s [label=<<table border="0">%s</table>> fontsize=13';
Expand Down
9 changes: 9 additions & 0 deletions tests/DrawDiagramTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,13 @@ public function testTaggedProfileWithoutTag(): void
$this->assertStringContainsString('s3 -> s4 [label = <t3 (safe)', $dot);
$this->assertStringContainsString('s5 -> s6 [label = <t6 (safe)', $dot);
}

public function testRenderTitle(): void
{
$alpsFile = __DIR__ . '/Fake/alps.title.xml';
$profile = new Profile($alpsFile, new LabelNameTitle());
$dot = ($this->drawDiagram)($profile, new LabelNameTitle());
$expected = ' State -> State [label=<<table border="0"><tr><td align="left" href="#goNext" tooltip="goNext (safe)" >go next state (safe)</td></tr><tr><td align="left" href="#goPrev" tooltip="goPrev (safe)" >go prev state (safe)</td></tr></table>>';
$this->assertStringContainsString($expected, $dot);
}
}
15 changes: 15 additions & 0 deletions tests/Fake/alps.title.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<alps
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://alps-io.github.io/schemas/alps.xsd">
<descriptor id="Home" title="Home">
<descriptor href="#goState" />
</descriptor>
<descriptor id="State" title="State">
<descriptor href="#goNext" />
<descriptor href="#goPrev" />
</descriptor>
<descriptor id="goState" title="go state" type="safe" rt="#State" />
<descriptor id="goNext" title="go next state" type="safe" rt="#State" />
<descriptor id="goPrev" title="go prev state" type="safe" rt="#State" />
</alps>
131 changes: 131 additions & 0 deletions tests/Fake/config/profile.title.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4d12465

Please sign in to comment.