Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 91f71bf

Browse files
committed
feat: Enhance ClassDiagramBuilderTest with additional tests for TraitRenderMode handling
1 parent 71fa4bd commit 91f71bf

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

tests/ClassDiagramRenderer/ClassDiagramBuilderTest.php

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ class UserController {
9797
$this->assertSame($expectedDiagram, $classDiagram);
9898
}
9999

100-
public function testBuildFromSampleProjectOnlyPropertiesDeps(): void
100+
public function testBuildFromSampleProjectOnlyPropertiesDepsFlatten(): void
101101
{
102102
$path = __DIR__ . '/../data/Project';
103103

104104
$classDiagram = $this->classDigagramBuilder
105105
->build($path)
106-
->render(new RenderOptions(false, true, true, true));
106+
->render(new RenderOptions(false, true, true, true, \Tasuku43\MermaidClassDiagram\ClassDiagramRenderer\TraitRenderMode::Flatten));
107107

108108
$expectedDiagram = <<<'EOT'
109109
classDiagram
@@ -136,6 +136,55 @@ class UserStatus {
136136
UserService *-- AuditLogger: composition
137137
UserService *-- UserRepositoryInterface: composition
138138

139+
EOT;
140+
141+
$this->assertSame($expectedDiagram, $classDiagram);
142+
}
143+
144+
public function testBuildFromSampleProjectOnlyPropertiesDepsWithTraits(): void
145+
{
146+
$path = __DIR__ . '/../data/Project';
147+
148+
$classDiagram = $this->classDigagramBuilder
149+
->build($path)
150+
->render(new RenderOptions(false, true, true, true, \Tasuku43\MermaidClassDiagram\ClassDiagramRenderer\TraitRenderMode::WithTraits));
151+
152+
$expectedDiagram = <<<'EOT'
153+
classDiagram
154+
class AbstractController {
155+
<<abstract>>
156+
}
157+
class AuditLogger {
158+
}
159+
class AuditTarget {
160+
}
161+
class RepositoryAwareTrait {
162+
<<trait>>
163+
}
164+
class User {
165+
}
166+
class UserController {
167+
}
168+
class UserRepository {
169+
}
170+
class UserRepositoryInterface {
171+
<<interface>>
172+
}
173+
class UserService {
174+
}
175+
class UserStatus {
176+
<<enum>>
177+
}
178+
179+
RepositoryAwareTrait *-- AuditLogger: composition
180+
RepositoryAwareTrait *-- UserRepositoryInterface: composition
181+
User *-- UserStatus: composition
182+
AbstractController <|-- UserController: inheritance
183+
UserController *-- UserService: composition
184+
UserRepositoryInterface <|.. UserRepository: realization
185+
UserService *-- AuditLogger: composition
186+
UserService *-- UserRepositoryInterface: composition
187+
139188
EOT;
140189

141190
$this->assertSame($expectedDiagram, $classDiagram);

0 commit comments

Comments
 (0)