@@ -28,16 +28,6 @@ protected function setUp(): void
2828 $ this ->classDigagramBuilder = new ClassDiagramBuilder ($ this ->nodeParser );
2929 }
3030
31- public function testDump (): void
32- {
33- $ path = __DIR__ . '/../data/Project ' ;
34-
35- $ classDiagram = $ this ->classDigagramBuilder
36- ->build ($ path );
37- $ dumper = new ClassDiagramDumper ($ classDiagram );
38- echo $ dumper ->toYaml ();
39- }
40-
4131 public function testBuildFromSampleProject (): void
4232 {
4333 $ path = __DIR__ . '/../data/Project ' ;
@@ -195,6 +185,66 @@ class UserStatus {
195185 UserRepositoryInterface <|.. UserRepository: realization
196186 UserService --> RepositoryAwareTrait: use
197187
188+ EOT;
189+
190+ $ this ->assertSame ($ expectedDiagram , $ classDiagram );
191+ }
192+
193+ public function testTraitUsesTrait_WithTraits (): void
194+ {
195+ $ path = __DIR__ . '/../data/TraitChain ' ;
196+
197+ $ classDiagram = $ this ->classDigagramBuilder
198+ ->build ($ path )
199+ ->render (new RenderOptions (true , true , true , true , \Tasuku43 \MermaidClassDiagram \ClassDiagramRenderer \TraitRenderMode::WithTraits));
200+
201+ $ expectedDiagram = <<<'EOT'
202+ classDiagram
203+ class ChainUser {
204+ }
205+ class DepClass {
206+ }
207+ class DepInterface {
208+ <<interface>>
209+ }
210+ class TraitA {
211+ <<trait>>
212+ }
213+ class TraitB {
214+ <<trait>>
215+ }
216+
217+ ChainUser --> TraitA: use
218+ TraitA --> TraitB: use
219+ TraitB *-- DepClass: composition
220+ TraitB ..> DepInterface: dependency
221+
222+ EOT;
223+
224+ $ this ->assertSame ($ expectedDiagram , $ classDiagram );
225+ }
226+
227+ public function testTraitUsesTrait_Flatten (): void
228+ {
229+ $ path = __DIR__ . '/../data/TraitChain ' ;
230+
231+ $ classDiagram = $ this ->classDigagramBuilder
232+ ->build ($ path )
233+ ->render (new RenderOptions (true , true , true , true , \Tasuku43 \MermaidClassDiagram \ClassDiagramRenderer \TraitRenderMode::Flatten));
234+
235+ $ expectedDiagram = <<<'EOT'
236+ classDiagram
237+ class ChainUser {
238+ }
239+ class DepClass {
240+ }
241+ class DepInterface {
242+ <<interface>>
243+ }
244+
245+ ChainUser *-- DepClass: composition
246+ ChainUser ..> DepInterface: dependency
247+
198248EOT;
199249
200250 $ this ->assertSame ($ expectedDiagram , $ classDiagram );
0 commit comments