1<?php
2declare(strict_types=1);
3
4use PHPUnit\Framework\TestCase;
5
6require_once 'syntax/PlantUmlDiagram.php';
7
8final class PlantUMLDiagramTest extends TestCase
9{
10
11    public function testSvgUrlGeneratedCorrectly()
12    {
13        $diagramObject = new PlantUmlDiagram("@startuml\nalice -> bob: yo what up\nbob->alice: not much\n@enduml","https://www.plantuml.com/plantuml/");
14
15        $this->assertEquals(
16            'https://www.plantuml.com/plantuml/svg/SoWkIImgAStDuKhCoKnELT2rKqZAJx9IgCnNACz8B54eBU02ydNjmB9M2ddv9GgvfSaPN0wfUIb0NG00',
17            $diagramObject->getSVGDiagramUrl()
18        );
19    }
20
21    public function testPngUrlGeneratedCorrectly()
22    {
23        $diagramObject = new PlantUmlDiagram("@startuml\nalice -> bob: yo what up\nbob->alice: not much\n@enduml","https://www.plantuml.com/plantuml/");
24
25        $this->assertEquals(
26            'https://www.plantuml.com/plantuml/png/SoWkIImgAStDuKhCoKnELT2rKqZAJx9IgCnNACz8B54eBU02ydNjmB9M2ddv9GgvfSaPN0wfUIb0NG00',
27            $diagramObject->getPNGDiagramUrl()
28        );
29    }
30
31    public function testTxtUrlGeneratedCorrectly()
32    {
33        $diagramObject = new PlantUmlDiagram("@startuml\nalice -> bob: yo what up\nbob->alice: not much\n@enduml","https://www.plantuml.com/plantuml/");
34
35        $this->assertEquals(
36            'https://www.plantuml.com/plantuml/txt/SoWkIImgAStDuKhCoKnELT2rKqZAJx9IgCnNACz8B54eBU02ydNjmB9M2ddv9GgvfSaPN0wfUIb0NG00',
37            $diagramObject->getTXTDiagramUrl()
38        );
39    }
40
41    public function testForeignCharacterGeneratedCorrectly()
42    {
43        $diagramObject = new PlantUmlDiagram("@startuml\nThomas -> Petra : bitte aus Spaß die Türe öffnen\n@enduml","https://www.plantuml.com/plantuml/");
44
45        $this->assertEquals(
46            'https://www.plantuml.com/plantuml/png/SoWkIImgAStDuGh9oCzDB5RGjLC8I2qfIbImKaZAB2b9LKWiBLO8BaWyF5yX9JDL8UJmdg9KXSFRqjBoKlEu75BpKe1w0G00',
47            $diagramObject->getPNGDiagramUrl()
48        );
49    }
50
51    public function testGetMarkup()
52    {
53        $diagramObject = new PlantUmlDiagram("@startuml\nalice -> bob: yo what up\nbob->alice: not much\n@enduml","https://www.plantuml.com/plantuml/");
54
55        $this->assertEquals(
56            '@startuml<br />
57alice -> bob: yo what up<br />
58bob->alice: not much<br />
59@enduml',
60            $diagramObject->getMarkup()
61        );
62    }
63}
64