| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * PHP version 7.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * This source file is subject to the license that is bundled with this package in the file LICENSE. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Lupka\PHPUnitCompareImages\CompareImagesTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  | class PhUmlDiagramWithGraphvizAndDotTest extends TestCase | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |     use CompareImagesTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |     /** @test */ | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |     function it_generates_a_class_diagram_using_graphviz_and_dot_processors() | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |         $success = <<<MESSAGE | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  | phUML Version 0.2 (Jakob Westhoff <[email protected]>) | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  | [|] Running... (This may take some time) | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | [|] Parsing class structure | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | [|] Running 'Graphviz' processor | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | [|] Running 'Dot' processor | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  | [|] Writing generated data to disk | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | MESSAGE; | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |         $diagram = __DIR__ . '/../../tests/.output/graphviz-dot.png'; | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |         passthru(sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |             'php %s %s -graphviz -dot %s', | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |             __DIR__ . '/../../src/app/phuml', | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |             __DIR__ . '/../.code/classes', | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |             $diagram | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         )); | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         $expectedDiagram = __DIR__ . '/../images/graphviz-dot.png'; | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |         $this->expectOutputString($success); | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |         $this->assertImagesSame($expectedDiagram, $diagram); | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |     /** @test */ | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |     function it_generates_a_class_diagram_using_graphviz_and_dot_processors_using_the_recursive_option() | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |         $success = <<<MESSAGE | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  | phUML Version 0.2 (Jakob Westhoff <[email protected]>) | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | [|] Running... (This may take some time) | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  | [|] Parsing class structure | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  | [|] Running 'Graphviz' processor | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  | [|] Running 'Dot' processor | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  | [|] Writing generated data to disk | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  | MESSAGE; | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |         $diagram = __DIR__ . '/../../tests/.output/graphviz-dot-recursive.png'; | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |         passthru(sprintf( | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |             'php %s -r %s -graphviz -dot %s', | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |             __DIR__ . '/../../src/app/phuml', | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |             __DIR__ . '/../.code', | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |             $diagram | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |         )); | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |         $expectedDiagram = __DIR__ . '/../images/graphviz-dot-recursive.png'; | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |         $this->expectOutputString($success); | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |         $this->assertImagesSame($expectedDiagram, $diagram); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 66 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 67 |  |  |  |